blob: 4f97d99359658b57fba471b20ed9980642c6d7b7 [file] [log] [blame]
Jani Nikuladfda0b62014-12-10 14:27:07 +02001/*
2 * Copyright © 2006,2009,2015 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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 *
26 */
27
28#include <errno.h>
29#include <stdbool.h>
30#include <stdint.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include "intel_chipset.h"
36#include "intel_reg.h"
37
38#include "intel_reg_spec.h"
39
40#define _DEBUGSTRING(func) \
41 void func(char *result, int len, int reg, uint32_t val, uint32_t devid)
42#define DEBUGSTRING(func) static _DEBUGSTRING(func)
43
44DEBUGSTRING(i830_16bit_func)
45{
46 snprintf(result, len, "0x%04x", (uint16_t) val);
47}
48
49DEBUGSTRING(i830_debug_dcc)
50{
51 const char *addressing = NULL;
52
53 if (!IS_MOBILE(devid))
54 return;
55
56 if (IS_965(devid)) {
57 if (val & (1 << 1))
58 addressing = "dual channel interleaved";
59 else
60 addressing = "single or dual channel asymmetric";
61 } else {
62 switch (val & 3) {
63 case 0:
64 addressing = "single channel";
65 break;
66 case 1:
67 addressing = "dual channel asymmetric";
68 break;
69 case 2:
70 addressing = "dual channel interleaved";
71 break;
72 case 3:
73 addressing = "unknown channel layout";
74 break;
75 }
76 }
77
78 snprintf(result, len, "%s, XOR randomization: %sabled, XOR bit: %d",
79 addressing,
80 (val & (1 << 10)) ? "dis" : "en",
81 (val & (1 << 9)) ? 17 : 11);
82}
83
84DEBUGSTRING(i830_debug_chdecmisc)
85{
86 const char *enhmodesel = NULL;
87
88 switch ((val >> 5) & 3) {
89 case 1:
90 enhmodesel = "XOR bank/rank";
91 break;
92 case 2:
93 enhmodesel = "swap bank";
94 break;
95 case 3:
96 enhmodesel = "XOR bank";
97 break;
98 case 0:
99 enhmodesel = "none";
100 break;
101 }
102
103 snprintf(result, len,
104 "%s, ch2 enh %sabled, ch1 enh %sabled, "
105 "ch0 enh %sabled, "
106 "flex %sabled, ep %spresent", enhmodesel,
107 (val & (1 << 4)) ? "en" : "dis",
108 (val & (1 << 3)) ? "en" : "dis",
109 (val & (1 << 2)) ? "en" : "dis",
110 (val & (1 << 1)) ? "en" : "dis",
111 (val & (1 << 0)) ? "" : "not ");
112}
113
114DEBUGSTRING(i830_debug_xyminus1)
115{
116 snprintf(result, len, "%d, %d", (val & 0xffff) + 1,
117 ((val & 0xffff0000) >> 16) + 1);
118}
119
120DEBUGSTRING(i830_debug_yxminus1)
121{
122 snprintf(result, len, "%d, %d", ((val & 0xffff0000) >> 16) + 1,
123 (val & 0xffff) + 1);
124}
125
126DEBUGSTRING(i830_debug_xy)
127{
128 snprintf(result, len, "%d, %d", (val & 0xffff), ((val & 0xffff0000) >> 16));
129}
130
131DEBUGSTRING(i830_debug_dspstride)
132{
133 snprintf(result, len, "%d bytes", val);
134}
135
136DEBUGSTRING(i830_debug_dspcntr)
137{
138 const char *enabled = val & DISPLAY_PLANE_ENABLE ? "enabled" : "disabled";
139 char plane = val & DISPPLANE_SEL_PIPE_B ? 'B' : 'A';
140 if (HAS_PCH_SPLIT(devid) || IS_BROXTON(devid))
141 snprintf(result, len, "%s", enabled);
142 else
143 snprintf(result, len, "%s, pipe %c", enabled, plane);
144}
145
146DEBUGSTRING(i830_debug_pipeconf)
147{
148 const char *enabled = val & PIPEACONF_ENABLE ? "enabled" : "disabled";
149 const char *bit30;
150 char buf[256];
151 int buf_len;
152
153 if (IS_965(devid))
154 bit30 = val & I965_PIPECONF_ACTIVE ? "active" : "inactive";
155 else
156 bit30 =
157 val & PIPEACONF_DOUBLE_WIDE ? "double-wide" : "single-wide";
158
159 buf_len = snprintf(buf, sizeof(buf), "%s, %s", enabled, bit30);
160
161 if (HAS_PCH_SPLIT(devid) || IS_BROXTON(devid)) {
162 const char *interlace;
163 int interlace_mode;
164
165 if ((IS_IVYBRIDGE(devid) || IS_HASWELL(devid) ||
166 IS_BROADWELL(devid) || IS_GEN9(devid)))
167 interlace_mode = (val >> 21) & 3;
168 else
169 interlace_mode = (val >> 21) & 7;
170
171 switch (interlace_mode) {
172 case 0:
173 interlace = "pf-pd";
174 break;
175 case 1:
176 interlace = "pf-id";
177 break;
178 case 3:
179 interlace = "if-id";
180 break;
181 case 4:
182 interlace = "if-id-dbl";
183 break;
184 case 5:
185 interlace = "pf-id-dbl";
186 break;
187 default:
188 interlace = "rsvd";
189 break;
190 }
191 if (buf_len < sizeof(buf))
192 buf_len += snprintf(&buf[buf_len], sizeof(buf) - buf_len,
193 ", %s", interlace);
194 } else if (IS_GEN4(devid) || IS_VALLEYVIEW(devid) ||
195 IS_CHERRYVIEW(devid)) {
196 const char *interlace;
197
198 switch ((val >> 21) & 7) {
199 case 0:
200 case 1:
201 case 2:
202 case 3:
203 interlace = "progressive";
204 break;
205 case 4:
206 interlace = "interlaced embedded";
207 break;
208 case 5:
209 interlace = "interlaced";
210 break;
211 case 6:
212 interlace = "interlaced sdvo";
213 break;
214 case 7:
215 interlace = "interlaced legacy";
216 break;
217 }
218 if (buf_len < sizeof(buf))
219 buf_len += snprintf(&buf[buf_len], sizeof(buf) - buf_len,
220 ", %s", interlace);
221 }
222
223 if (IS_HASWELL(devid) || IS_IVYBRIDGE(devid) ||
224 IS_GEN6(devid) || IS_GEN5(devid)) {
225 const char *rotation;
226
227 switch ((val >> 14) & 3) {
228 case 0:
229 rotation = "rotate 0";
230 break;
231 case 1:
232 rotation = "rotate 90";
233 break;
234 case 2:
235 rotation = "rotate 180";
236 break;
237 case 3:
238 rotation = "rotate 270";
239 break;
240 }
241 if (buf_len < sizeof(buf))
242 buf_len += snprintf(&buf[buf_len], sizeof(buf) - buf_len,
243 ", %s", rotation);
244 }
245
246 if (IS_IVYBRIDGE(devid) || IS_GEN6(devid) || IS_GEN5(devid)) {
247 const char *bpc;
248
249 switch (val & (7 << 5)) {
250 case PIPECONF_8BPP:
251 bpc = "8bpc";
252 break;
253 case PIPECONF_10BPP:
254 bpc = "10bpc";
255 break;
256 case PIPECONF_6BPP:
257 bpc = "6bpc";
258 break;
259 case PIPECONF_12BPP:
260 bpc = "12bpc";
261 break;
262 default:
263 bpc = "invalid bpc";
264 break;
265 }
266 if (buf_len < sizeof(buf))
267 buf_len += snprintf(&buf[buf_len], sizeof(buf) - buf_len,
268 ", %s", bpc);
269 }
270
271 snprintf(result, len, "%s", buf);
272}
273
274DEBUGSTRING(i830_debug_pipestat)
275{
276 const char *_FIFO_UNDERRUN = val & FIFO_UNDERRUN ? " FIFO_UNDERRUN" : "";
277 const char *_CRC_ERROR_ENABLE =
278 val & CRC_ERROR_ENABLE ? " CRC_ERROR_ENABLE" : "";
279 const char *_CRC_DONE_ENABLE =
280 val & CRC_DONE_ENABLE ? " CRC_DONE_ENABLE" : "";
281 const char *_GMBUS_EVENT_ENABLE =
282 val & GMBUS_EVENT_ENABLE ? " GMBUS_EVENT_ENABLE" : "";
283 const char *_VSYNC_INT_ENABLE =
284 val & VSYNC_INT_ENABLE ? " VSYNC_INT_ENABLE" : "";
285 const char *_DLINE_COMPARE_ENABLE =
286 val & DLINE_COMPARE_ENABLE ? " DLINE_COMPARE_ENABLE" : "";
287 const char *_DPST_EVENT_ENABLE =
288 val & DPST_EVENT_ENABLE ? " DPST_EVENT_ENABLE" : "";
289 const char *_LBLC_EVENT_ENABLE =
290 val & LBLC_EVENT_ENABLE ? " LBLC_EVENT_ENABLE" : "";
291 const char *_OFIELD_INT_ENABLE =
292 val & OFIELD_INT_ENABLE ? " OFIELD_INT_ENABLE" : "";
293 const char *_EFIELD_INT_ENABLE =
294 val & EFIELD_INT_ENABLE ? " EFIELD_INT_ENABLE" : "";
295 const char *_SVBLANK_INT_ENABLE =
296 val & SVBLANK_INT_ENABLE ? " SVBLANK_INT_ENABLE" : "";
297 const char *_VBLANK_INT_ENABLE =
298 val & VBLANK_INT_ENABLE ? " VBLANK_INT_ENABLE" : "";
299 const char *_OREG_UPDATE_ENABLE =
300 val & OREG_UPDATE_ENABLE ? " OREG_UPDATE_ENABLE" : "";
301 const char *_CRC_ERROR_INT_STATUS =
302 val & CRC_ERROR_INT_STATUS ? " CRC_ERROR_INT_STATUS" : "";
303 const char *_CRC_DONE_INT_STATUS =
304 val & CRC_DONE_INT_STATUS ? " CRC_DONE_INT_STATUS" : "";
305 const char *_GMBUS_INT_STATUS =
306 val & GMBUS_INT_STATUS ? " GMBUS_INT_STATUS" : "";
307 const char *_VSYNC_INT_STATUS =
308 val & VSYNC_INT_STATUS ? " VSYNC_INT_STATUS" : "";
309 const char *_DLINE_COMPARE_STATUS =
310 val & DLINE_COMPARE_STATUS ? " DLINE_COMPARE_STATUS" : "";
311 const char *_DPST_EVENT_STATUS =
312 val & DPST_EVENT_STATUS ? " DPST_EVENT_STATUS" : "";
313 const char *_LBLC_EVENT_STATUS =
314 val & LBLC_EVENT_STATUS ? " LBLC_EVENT_STATUS" : "";
315 const char *_OFIELD_INT_STATUS =
316 val & OFIELD_INT_STATUS ? " OFIELD_INT_STATUS" : "";
317 const char *_EFIELD_INT_STATUS =
318 val & EFIELD_INT_STATUS ? " EFIELD_INT_STATUS" : "";
319 const char *_SVBLANK_INT_STATUS =
320 val & SVBLANK_INT_STATUS ? " SVBLANK_INT_STATUS" : "";
321 const char *_VBLANK_INT_STATUS =
322 val & VBLANK_INT_STATUS ? " VBLANK_INT_STATUS" : "";
323 const char *_OREG_UPDATE_STATUS =
324 val & OREG_UPDATE_STATUS ? " OREG_UPDATE_STATUS" : "";
325 snprintf(result, len,
326 "status:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
327 _FIFO_UNDERRUN,
328 _CRC_ERROR_ENABLE,
329 _CRC_DONE_ENABLE,
330 _GMBUS_EVENT_ENABLE,
331 _VSYNC_INT_ENABLE,
332 _DLINE_COMPARE_ENABLE,
333 _DPST_EVENT_ENABLE,
334 _LBLC_EVENT_ENABLE,
335 _OFIELD_INT_ENABLE,
336 _EFIELD_INT_ENABLE,
337 _SVBLANK_INT_ENABLE,
338 _VBLANK_INT_ENABLE,
339 _OREG_UPDATE_ENABLE,
340 _CRC_ERROR_INT_STATUS,
341 _CRC_DONE_INT_STATUS,
342 _GMBUS_INT_STATUS,
343 _VSYNC_INT_STATUS,
344 _DLINE_COMPARE_STATUS,
345 _DPST_EVENT_STATUS,
346 _LBLC_EVENT_STATUS,
347 _OFIELD_INT_STATUS,
348 _EFIELD_INT_STATUS,
349 _SVBLANK_INT_STATUS,
350 _VBLANK_INT_STATUS,
351 _OREG_UPDATE_STATUS);
352}
353
354DEBUGSTRING(ivb_debug_port)
355{
356 const char *drrs = NULL;
357 switch (val & (2 << 30)) {
358 case PORT_DBG_DRRS_HW_STATE_OFF:
359 drrs = "off";
360 break;
361 case PORT_DBG_DRRS_HW_STATE_LOW:
362 drrs = "low";
363 break;
364 case PORT_DBG_DRRS_HW_STATE_HIGH:
365 drrs = "high";
366 break;
367 }
368 snprintf(result, len, "HW DRRS %s",
369 drrs);
370}
371
372DEBUGSTRING(i830_debug_hvtotal)
373{
374 snprintf(result, len, "%d active, %d total",
375 (val & 0xffff) + 1,
376 ((val & 0xffff0000) >> 16) + 1);
377}
378
379DEBUGSTRING(i830_debug_hvsyncblank)
380{
381 snprintf(result, len, "%d start, %d end",
382 (val & 0xffff) + 1,
383 ((val & 0xffff0000) >> 16) + 1);
384}
385
386DEBUGSTRING(i830_debug_vgacntrl)
387{
388 snprintf(result, len, "%s",
389 val & VGA_DISP_DISABLE ? "disabled" : "enabled");
390}
391
392DEBUGSTRING(i830_debug_fp)
393{
394 if (IS_IGD(devid)) {
395 snprintf(result, len, "n = %d, m1 = %d, m2 = %d",
396 ffs((val & FP_N_IGD_DIV_MASK) >>
397 FP_N_DIV_SHIFT) - 1,
398 ((val & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT),
399 ((val & FP_M2_IGD_DIV_MASK) >>
400 FP_M2_DIV_SHIFT));
401 }
402 snprintf(result, len, "n = %d, m1 = %d, m2 = %d",
403 ((val & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT),
404 ((val & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT),
405 ((val & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT));
406}
407
408DEBUGSTRING(i830_debug_vga_pd)
409{
410 int vga0_p1, vga0_p2, vga1_p1, vga1_p2;
411
412 /* XXX: i9xx version */
413
414 if (val & VGA0_PD_P1_DIV_2)
415 vga0_p1 = 2;
416 else
417 vga0_p1 = ((val & VGA0_PD_P1_MASK) >> VGA0_PD_P1_SHIFT) + 2;
418 vga0_p2 = (val & VGA0_PD_P2_DIV_4) ? 4 : 2;
419
420 if (val & VGA1_PD_P1_DIV_2)
421 vga1_p1 = 2;
422 else
423 vga1_p1 = ((val & VGA1_PD_P1_MASK) >> VGA1_PD_P1_SHIFT) + 2;
424 vga1_p2 = (val & VGA1_PD_P2_DIV_4) ? 4 : 2;
425
426 snprintf(result, len, "vga0 p1 = %d, p2 = %d, vga1 p1 = %d, p2 = %d",
427 vga0_p1, vga0_p2, vga1_p1, vga1_p2);
428}
429
430DEBUGSTRING(i830_debug_pp_status)
431{
432 const char *status = val & PP_ON ? "on" : "off";
433 const char *ready = val & PP_READY ? "ready" : "not ready";
434 const char *seq = "unknown";
435
436 switch (val & PP_SEQUENCE_MASK) {
437 case PP_SEQUENCE_NONE:
438 seq = "idle";
439 break;
440 case PP_SEQUENCE_ON:
441 seq = "on";
442 break;
443 case PP_SEQUENCE_OFF:
444 seq = "off";
445 break;
446 }
447
448 snprintf(result, len, "%s, %s, sequencing %s", status, ready, seq);
449}
450
451DEBUGSTRING(i830_debug_pp_control)
452{
453 snprintf(result, len, "power target: %s",
454 val & POWER_TARGET_ON ? "on" : "off");
455}
456
457DEBUGSTRING(i830_debug_dpll)
458{
459 const char *enabled = val & DPLL_VCO_ENABLE ? "enabled" : "disabled";
460 const char *dvomode = val & DPLL_DVO_HIGH_SPEED ? "dvo" : "non-dvo";
461 const char *vgamode = val & DPLL_VGA_MODE_DIS ? "" : ", VGA";
462 const char *mode = "unknown";
463 const char *clock = "unknown";
464 const char *fpextra = val & DISPLAY_RATE_SELECT_FPA1 ? ", using FPx1!" : "";
465 char sdvoextra[20];
466 int p1 = 0, p2 = 0;
467
468 if (IS_GEN2(devid)) {
469#if 0 /* removed due to use of INREG */
470 char is_lvds = (INREG(LVDS) & LVDS_PORT_EN) && (reg == DPLL_B);
471
472 if (is_lvds) {
473 mode = "LVDS";
474 p1 = ffs((val & DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS)
475 >> DPLL_FPA01_P1_POST_DIV_SHIFT);
476 if ((INREG(LVDS) & LVDS_CLKB_POWER_MASK) ==
477 LVDS_CLKB_POWER_UP)
478 p2 = 7;
479 else
480 p2 = 14;
481
482 } else {
483 mode = "DAC/serial";
484 if (val & PLL_P1_DIVIDE_BY_TWO) {
485 p1 = 2;
486 } else {
487 /* Map the number in the field to (3, 33) */
488 p1 = ((val & DPLL_FPA01_P1_POST_DIV_MASK_I830)
489 >> DPLL_FPA01_P1_POST_DIV_SHIFT) + 2;
490 }
491 if (val & PLL_P2_DIVIDE_BY_4)
492 p2 = 4;
493 else
494 p2 = 2;
495 }
496#endif
497 } else {
498 if (IS_IGD(devid)) {
499 p1 = ffs((val & DPLL_FPA01_P1_POST_DIV_MASK_IGD) >>
500 DPLL_FPA01_P1_POST_DIV_SHIFT_IGD);
501 } else {
502 p1 = ffs((val & DPLL_FPA01_P1_POST_DIV_MASK) >>
503 DPLL_FPA01_P1_POST_DIV_SHIFT);
504 }
505 switch (val & DPLL_MODE_MASK) {
506 case DPLLB_MODE_DAC_SERIAL:
507 mode = "DAC/serial";
508 p2 = val & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 ? 5 : 10;
509 break;
510 case DPLLB_MODE_LVDS:
511 mode = "LVDS";
512 p2 = val & DPLLB_LVDS_P2_CLOCK_DIV_7 ? 7 : 14;
513 break;
514 }
515 }
516
517 switch (val & PLL_REF_INPUT_MASK) {
518 case PLL_REF_INPUT_DREFCLK:
519 clock = "default";
520 break;
521 case PLL_REF_INPUT_TVCLKINA:
522 clock = "TV A";
523 break;
524 case PLL_REF_INPUT_TVCLKINBC:
525 clock = "TV B/C";
526 break;
527 case PLLB_REF_INPUT_SPREADSPECTRUMIN:
528 if (reg == DPLL_B)
529 clock = "spread spectrum";
530 break;
531 }
532
533 if (IS_945(devid)) {
534 sprintf(sdvoextra, ", SDVO mult %d",
535 (int)((val & SDVO_MULTIPLIER_MASK) >>
536 SDVO_MULTIPLIER_SHIFT_HIRES) + 1);
537 } else {
538 sdvoextra[0] = '\0';
539 }
540
541 snprintf(result, len, "%s, %s%s, %s clock, %s mode, p1 = %d, "
542 "p2 = %d%s%s",
543 enabled, dvomode, vgamode, clock, mode, p1, p2,
544 fpextra, sdvoextra);
545}
546
547DEBUGSTRING(i830_debug_dpll_test)
548{
549 const char *dpllandiv = val & DPLLA_TEST_N_BYPASS ? ", DPLLA N bypassed" : "";
550 const char *dpllamdiv = val & DPLLA_TEST_M_BYPASS ? ", DPLLA M bypassed" : "";
551 const char *dpllainput = val & DPLLA_INPUT_BUFFER_ENABLE ?
552 "" : ", DPLLA input buffer disabled";
553 const char *dpllbndiv = val & DPLLB_TEST_N_BYPASS ? ", DPLLB N bypassed" : "";
554 const char *dpllbmdiv = val & DPLLB_TEST_M_BYPASS ? ", DPLLB M bypassed" : "";
555 const char *dpllbinput = val & DPLLB_INPUT_BUFFER_ENABLE ?
556 "" : ", DPLLB input buffer disabled";
557
558 snprintf(result, len, "%s%s%s%s%s%s",
559 dpllandiv, dpllamdiv, dpllainput,
560 dpllbndiv, dpllbmdiv, dpllbinput);
561}
562
563DEBUGSTRING(i830_debug_adpa)
564{
565 char disp_pipe = (val & ADPA_PIPE_B_SELECT) ? 'B' : 'A';
566 const char *enable = (val & ADPA_DAC_ENABLE) ? "enabled" : "disabled";
567 char hsync = (val & ADPA_HSYNC_ACTIVE_HIGH) ? '+' : '-';
568 char vsync = (val & ADPA_VSYNC_ACTIVE_HIGH) ? '+' : '-';
569
570 if (HAS_CPT)
571 disp_pipe = val & (1<<29) ? 'B' : 'A';
572
573 if (HAS_PCH_SPLIT(devid))
574 snprintf(result, len, "%s, transcoder %c, %chsync, %cvsync",
575 enable, disp_pipe, hsync, vsync);
576 else
577 snprintf(result, len, "%s, pipe %c, %chsync, %cvsync",
578 enable, disp_pipe, hsync, vsync);
579}
580
581DEBUGSTRING(i830_debug_lvds)
582{
583 char disp_pipe = val & LVDS_PIPEB_SELECT ? 'B' : 'A';
584 const char *enable = val & LVDS_PORT_EN ? "enabled" : "disabled";
585 int depth;
586 const char *channels;
587
588 if ((val & LVDS_A3_POWER_MASK) == LVDS_A3_POWER_UP)
589 depth = 24;
590 else
591 depth = 18;
592 if ((val & LVDS_B0B3_POWER_MASK) == LVDS_B0B3_POWER_UP)
593 channels = "2 channels";
594 else
595 channels = "1 channel";
596
597 if (HAS_CPT)
598 disp_pipe = val & (1<<29) ? 'B' : 'A';
599
600 snprintf(result, len, "%s, pipe %c, %d bit, %s",
601 enable, disp_pipe, depth, channels);
602}
603
604DEBUGSTRING(i830_debug_dvo)
605{
606 const char *enable = val & DVO_ENABLE ? "enabled" : "disabled";
607 char disp_pipe = val & DVO_PIPE_B_SELECT ? 'B' : 'A';
608 const char *stall;
609 char hsync = val & DVO_HSYNC_ACTIVE_HIGH ? '+' : '-';
610 char vsync = val & DVO_VSYNC_ACTIVE_HIGH ? '+' : '-';
611
612 switch (val & DVO_PIPE_STALL_MASK) {
613 case DVO_PIPE_STALL_UNUSED:
614 stall = "no stall";
615 break;
616 case DVO_PIPE_STALL:
617 stall = "stall";
618 break;
619 case DVO_PIPE_STALL_TV:
620 stall = "TV stall";
621 break;
622 default:
623 stall = "unknown stall";
624 break;
625 }
626
627 snprintf(result, len, "%s, pipe %c, %s, %chsync, %cvsync",
628 enable, disp_pipe, stall, hsync, vsync);
629}
630
631DEBUGSTRING(i830_debug_sdvo)
632{
633 const char *enable = val & SDVO_ENABLE ? "enabled" : "disabled";
634 char disp_pipe = val & SDVO_PIPE_B_SELECT ? 'B' : 'A';
635 const char *stall = val & SDVO_STALL_SELECT ? "enabled" : "disabled";
636 const char *detected = val & SDVO_DETECTED ? "" : "not ";
637 const char *gang = val & SDVOC_GANG_MODE ? ", gang mode" : "";
638 char sdvoextra[20];
639
640 if (IS_915(devid)) {
641 sprintf(sdvoextra, ", SDVO mult %d",
642 (int)((val & SDVO_PORT_MULTIPLY_MASK) >>
643 SDVO_PORT_MULTIPLY_SHIFT) + 1);
644 } else {
645 sdvoextra[0] = '\0';
646 }
647
648 snprintf(result, len, "%s, pipe %c, stall %s, %sdetected%s%s",
649 enable, disp_pipe, stall, detected, sdvoextra, gang);
650}
651
652DEBUGSTRING(i830_debug_dspclk_gate_d)
653{
654 const char *DPUNIT_B = val & DPUNIT_B_CLOCK_GATE_DISABLE ? " DPUNIT_B" : "";
655 const char *VSUNIT = val & VSUNIT_CLOCK_GATE_DISABLE ? " VSUNIT" : "";
656 const char *VRHUNIT = val & VRHUNIT_CLOCK_GATE_DISABLE ? " VRHUNIT" : "";
657 const char *VRDUNIT = val & VRDUNIT_CLOCK_GATE_DISABLE ? " VRDUNIT" : "";
658 const char *AUDUNIT = val & AUDUNIT_CLOCK_GATE_DISABLE ? " AUDUNIT" : "";
659 const char *DPUNIT_A = val & DPUNIT_A_CLOCK_GATE_DISABLE ? " DPUNIT_A" : "";
660 const char *DPCUNIT = val & DPCUNIT_CLOCK_GATE_DISABLE ? " DPCUNIT" : "";
661 const char *TVRUNIT = val & TVRUNIT_CLOCK_GATE_DISABLE ? " TVRUNIT" : "";
662 const char *TVCUNIT = val & TVCUNIT_CLOCK_GATE_DISABLE ? " TVCUNIT" : "";
663 const char *TVFUNIT = val & TVFUNIT_CLOCK_GATE_DISABLE ? " TVFUNIT" : "";
664 const char *TVEUNIT = val & TVEUNIT_CLOCK_GATE_DISABLE ? " TVEUNIT" : "";
665 const char *DVSUNIT = val & DVSUNIT_CLOCK_GATE_DISABLE ? " DVSUNIT" : "";
666 const char *DSSUNIT = val & DSSUNIT_CLOCK_GATE_DISABLE ? " DSSUNIT" : "";
667 const char *DDBUNIT = val & DDBUNIT_CLOCK_GATE_DISABLE ? " DDBUNIT" : "";
668 const char *DPRUNIT = val & DPRUNIT_CLOCK_GATE_DISABLE ? " DPRUNIT" : "";
669 const char *DPFUNIT = val & DPFUNIT_CLOCK_GATE_DISABLE ? " DPFUNIT" : "";
670 const char *DPBMUNIT = val & DPBMUNIT_CLOCK_GATE_DISABLE ? " DPBMUNIT" : "";
671 const char *DPLSUNIT = val & DPLSUNIT_CLOCK_GATE_DISABLE ? " DPLSUNIT" : "";
672 const char *DPLUNIT = val & DPLUNIT_CLOCK_GATE_DISABLE ? " DPLUNIT" : "";
673 const char *DPOUNIT = val & DPOUNIT_CLOCK_GATE_DISABLE ? " DPOUNIT" : "";
674 const char *DPBUNIT = val & DPBUNIT_CLOCK_GATE_DISABLE ? " DPBUNIT" : "";
675 const char *DCUNIT = val & DCUNIT_CLOCK_GATE_DISABLE ? " DCUNIT" : "";
676 const char *DPUNIT = val & DPUNIT_CLOCK_GATE_DISABLE ? " DPUNIT" : "";
677 const char *VRUNIT = val & VRUNIT_CLOCK_GATE_DISABLE ? " VRUNIT" : "";
678 const char *OVHUNIT = val & OVHUNIT_CLOCK_GATE_DISABLE ? " OVHUNIT" : "";
679 const char *DPIOUNIT = val & DPIOUNIT_CLOCK_GATE_DISABLE ? " DPIOUNIT" : "";
680 const char *OVFUNIT = val & OVFUNIT_CLOCK_GATE_DISABLE ? " OVFUNIT" : "";
681 const char *OVBUNIT = val & OVBUNIT_CLOCK_GATE_DISABLE ? " OVBUNIT" : "";
682 const char *OVRUNIT = val & OVRUNIT_CLOCK_GATE_DISABLE ? " OVRUNIT" : "";
683 const char *OVCUNIT = val & OVCUNIT_CLOCK_GATE_DISABLE ? " OVCUNIT" : "";
684 const char *OVUUNIT = val & OVUUNIT_CLOCK_GATE_DISABLE ? " OVUUNIT" : "";
685 const char *OVLUNIT = val & OVLUNIT_CLOCK_GATE_DISABLE ? " OVLUNIT" : "";
686
687 snprintf(result, len,
688 "clock gates disabled:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
689 DPUNIT_B, VSUNIT, VRHUNIT, VRDUNIT, AUDUNIT, DPUNIT_A, DPCUNIT,
690 TVRUNIT, TVCUNIT, TVFUNIT, TVEUNIT, DVSUNIT, DSSUNIT, DDBUNIT,
691 DPRUNIT, DPFUNIT, DPBMUNIT, DPLSUNIT, DPLUNIT, DPOUNIT, DPBUNIT,
692 DCUNIT, DPUNIT, VRUNIT, OVHUNIT, DPIOUNIT, OVFUNIT, OVBUNIT,
693 OVRUNIT, OVCUNIT, OVUUNIT, OVLUNIT);
694}
695
696DEBUGSTRING(i810_debug_915_fence)
697{
698 char format = (val & 1 << 12) ? 'Y' : 'X';
699 int pitch = 128 << ((val & 0x70) >> 4);
700 unsigned int offset = val & 0x0ff00000;
701 int size = (1024 * 1024) << ((val & 0x700) >> 8);
702
703 if (IS_965(devid) || (IS_915(devid) && reg >= FENCE_NEW))
704 return;
705
706 if (format == 'X')
707 pitch *= 4;
708 if (val & 1) {
709 snprintf(result, len, "enabled, %c tiled, %4d pitch, 0x%08x - 0x%08x (%dkb)",
710 format, pitch, offset, offset + size,
711 size / 1024);
712 } else {
713 snprintf(result, len, "disabled");
714 }
715}
716
717DEBUGSTRING(i810_debug_965_fence_start)
718{
719 const char *enable = (val & FENCE_VALID) ? " enabled" : "disabled";
720 char format = (val & I965_FENCE_Y_MAJOR) ? 'Y' : 'X';
721 int pitch = ((val & 0xffc) >> 2) * 128 + 128;
722 unsigned int offset = val & 0xfffff000;
723
724 if (!IS_965(devid))
725 return;
726
727 snprintf(result, len, "%s, %c tile walk, %4d pitch, 0x%08x start",
728 enable, format, pitch, offset);
729}
730
731DEBUGSTRING(i810_debug_965_fence_end)
732{
733 unsigned int end = val & 0xfffff000;
734
735 if (!IS_965(devid))
736 return;
737
738 snprintf(result, len, " 0x%08x end", end);
739}
740
741#define DEFINEREG(reg) \
742 { reg, #reg, NULL }
743#define DEFINEREG_16BIT(reg) \
744 { reg, #reg, i830_16bit_func }
745#define DEFINEREG2(reg, func) \
746 { reg, #reg, func }
747
748struct reg_debug {
749 int reg;
750 const char *name;
751 _DEBUGSTRING((*debug_output));
752};
753
754static const struct reg_debug intel_debug_regs[] = {
755 DEFINEREG2(DCC, i830_debug_dcc),
756 DEFINEREG2(CHDECMISC, i830_debug_chdecmisc),
757 DEFINEREG_16BIT(C0DRB0),
758 DEFINEREG_16BIT(C0DRB1),
759 DEFINEREG_16BIT(C0DRB2),
760 DEFINEREG_16BIT(C0DRB3),
761 DEFINEREG_16BIT(C1DRB0),
762 DEFINEREG_16BIT(C1DRB1),
763 DEFINEREG_16BIT(C1DRB2),
764 DEFINEREG_16BIT(C1DRB3),
765 DEFINEREG_16BIT(C0DRA01),
766 DEFINEREG_16BIT(C0DRA23),
767 DEFINEREG_16BIT(C1DRA01),
768 DEFINEREG_16BIT(C1DRA23),
769
770 DEFINEREG(PGETBL_CTL),
771
772 DEFINEREG2(VCLK_DIVISOR_VGA0, i830_debug_fp),
773 DEFINEREG2(VCLK_DIVISOR_VGA1, i830_debug_fp),
774 DEFINEREG2(VCLK_POST_DIV, i830_debug_vga_pd),
775 DEFINEREG2(DPLL_TEST, i830_debug_dpll_test),
776 DEFINEREG(CACHE_MODE_0),
777 DEFINEREG(D_STATE),
778 DEFINEREG2(DSPCLK_GATE_D, i830_debug_dspclk_gate_d),
779 DEFINEREG(RENCLK_GATE_D1),
780 DEFINEREG(RENCLK_GATE_D2),
781/* DEFINEREG(RAMCLK_GATE_D), CRL only */
782 DEFINEREG2(SDVOB, i830_debug_sdvo),
783 DEFINEREG2(SDVOC, i830_debug_sdvo),
784/* DEFINEREG(UDIB_SVB_SHB_CODES), CRL only */
785/* DEFINEREG(UDIB_SHA_BLANK_CODES), CRL only */
786 DEFINEREG(SDVOUDI),
787 DEFINEREG(DSPARB),
788 DEFINEREG(FW_BLC),
789 DEFINEREG(FW_BLC2),
790 DEFINEREG(FW_BLC_SELF),
791 DEFINEREG(DSPFW1),
792 DEFINEREG(DSPFW2),
793 DEFINEREG(DSPFW3),
794
795 DEFINEREG2(ADPA, i830_debug_adpa),
796 DEFINEREG2(LVDS, i830_debug_lvds),
797 DEFINEREG2(DVOA, i830_debug_dvo),
798 DEFINEREG2(DVOB, i830_debug_dvo),
799 DEFINEREG2(DVOC, i830_debug_dvo),
800 DEFINEREG(DVOA_SRCDIM),
801 DEFINEREG(DVOB_SRCDIM),
802 DEFINEREG(DVOC_SRCDIM),
803
804 DEFINEREG(BLC_PWM_CTL),
805 DEFINEREG(BLC_PWM_CTL2),
806
807 DEFINEREG2(PP_CONTROL, i830_debug_pp_control),
808 DEFINEREG2(PP_STATUS, i830_debug_pp_status),
809 DEFINEREG(PP_ON_DELAYS),
810 DEFINEREG(PP_OFF_DELAYS),
811 DEFINEREG(PP_DIVISOR),
812 DEFINEREG(PFIT_CONTROL),
813 DEFINEREG(PFIT_PGM_RATIOS),
814 DEFINEREG(PORT_HOTPLUG_EN),
815 DEFINEREG(PORT_HOTPLUG_STAT),
816
817 DEFINEREG2(DSPACNTR, i830_debug_dspcntr),
818 DEFINEREG2(DSPASTRIDE, i830_debug_dspstride),
819 DEFINEREG2(DSPAPOS, i830_debug_xy),
820 DEFINEREG2(DSPASIZE, i830_debug_xyminus1),
821 DEFINEREG(DSPABASE),
822 DEFINEREG(DSPASURF),
823 DEFINEREG(DSPATILEOFF),
824 DEFINEREG2(PIPEACONF, i830_debug_pipeconf),
825 DEFINEREG2(PIPEASRC, i830_debug_yxminus1),
826 DEFINEREG2(PIPEASTAT, i830_debug_pipestat),
827 DEFINEREG(PIPEA_GMCH_DATA_M),
828 DEFINEREG(PIPEA_GMCH_DATA_N),
829 DEFINEREG(PIPEA_DP_LINK_M),
830 DEFINEREG(PIPEA_DP_LINK_N),
831 DEFINEREG(CURSOR_A_BASE),
832 DEFINEREG(CURSOR_A_CONTROL),
833 DEFINEREG(CURSOR_A_POSITION),
834
835 DEFINEREG2(FPA0, i830_debug_fp),
836 DEFINEREG2(FPA1, i830_debug_fp),
837 DEFINEREG2(DPLL_A, i830_debug_dpll),
838 DEFINEREG(DPLL_A_MD),
839 DEFINEREG2(HTOTAL_A, i830_debug_hvtotal),
840 DEFINEREG2(HBLANK_A, i830_debug_hvsyncblank),
841 DEFINEREG2(HSYNC_A, i830_debug_hvsyncblank),
842 DEFINEREG2(VTOTAL_A, i830_debug_hvtotal),
843 DEFINEREG2(VBLANK_A, i830_debug_hvsyncblank),
844 DEFINEREG2(VSYNC_A, i830_debug_hvsyncblank),
845 DEFINEREG(BCLRPAT_A),
846 DEFINEREG(VSYNCSHIFT_A),
847
848 DEFINEREG2(DSPBCNTR, i830_debug_dspcntr),
849 DEFINEREG2(DSPBSTRIDE, i830_debug_dspstride),
850 DEFINEREG2(DSPBPOS, i830_debug_xy),
851 DEFINEREG2(DSPBSIZE, i830_debug_xyminus1),
852 DEFINEREG(DSPBBASE),
853 DEFINEREG(DSPBSURF),
854 DEFINEREG(DSPBTILEOFF),
855 DEFINEREG2(PIPEBCONF, i830_debug_pipeconf),
856 DEFINEREG2(PIPEBSRC, i830_debug_yxminus1),
857 DEFINEREG2(PIPEBSTAT, i830_debug_pipestat),
858 DEFINEREG(PIPEB_GMCH_DATA_M),
859 DEFINEREG(PIPEB_GMCH_DATA_N),
860 DEFINEREG(PIPEB_DP_LINK_M),
861 DEFINEREG(PIPEB_DP_LINK_N),
862 DEFINEREG(CURSOR_B_BASE),
863 DEFINEREG(CURSOR_B_CONTROL),
864 DEFINEREG(CURSOR_B_POSITION),
865
866 DEFINEREG2(FPB0, i830_debug_fp),
867 DEFINEREG2(FPB1, i830_debug_fp),
868 DEFINEREG2(DPLL_B, i830_debug_dpll),
869 DEFINEREG(DPLL_B_MD),
870 DEFINEREG2(HTOTAL_B, i830_debug_hvtotal),
871 DEFINEREG2(HBLANK_B, i830_debug_hvsyncblank),
872 DEFINEREG2(HSYNC_B, i830_debug_hvsyncblank),
873 DEFINEREG2(VTOTAL_B, i830_debug_hvtotal),
874 DEFINEREG2(VBLANK_B, i830_debug_hvsyncblank),
875 DEFINEREG2(VSYNC_B, i830_debug_hvsyncblank),
876 DEFINEREG(BCLRPAT_B),
877 DEFINEREG(VSYNCSHIFT_B),
878
879 DEFINEREG(VCLK_DIVISOR_VGA0),
880 DEFINEREG(VCLK_DIVISOR_VGA1),
881 DEFINEREG(VCLK_POST_DIV),
882 DEFINEREG2(VGACNTRL, i830_debug_vgacntrl),
883
884 DEFINEREG(TV_CTL),
885 DEFINEREG(TV_DAC),
886 DEFINEREG(TV_CSC_Y),
887 DEFINEREG(TV_CSC_Y2),
888 DEFINEREG(TV_CSC_U),
889 DEFINEREG(TV_CSC_U2),
890 DEFINEREG(TV_CSC_V),
891 DEFINEREG(TV_CSC_V2),
892 DEFINEREG(TV_CLR_KNOBS),
893 DEFINEREG(TV_CLR_LEVEL),
894 DEFINEREG(TV_H_CTL_1),
895 DEFINEREG(TV_H_CTL_2),
896 DEFINEREG(TV_H_CTL_3),
897 DEFINEREG(TV_V_CTL_1),
898 DEFINEREG(TV_V_CTL_2),
899 DEFINEREG(TV_V_CTL_3),
900 DEFINEREG(TV_V_CTL_4),
901 DEFINEREG(TV_V_CTL_5),
902 DEFINEREG(TV_V_CTL_6),
903 DEFINEREG(TV_V_CTL_7),
904 DEFINEREG(TV_SC_CTL_1),
905 DEFINEREG(TV_SC_CTL_2),
906 DEFINEREG(TV_SC_CTL_3),
907 DEFINEREG(TV_WIN_POS),
908 DEFINEREG(TV_WIN_SIZE),
909 DEFINEREG(TV_FILTER_CTL_1),
910 DEFINEREG(TV_FILTER_CTL_2),
911 DEFINEREG(TV_FILTER_CTL_3),
912 DEFINEREG(TV_CC_CONTROL),
913 DEFINEREG(TV_CC_DATA),
914 DEFINEREG(TV_H_LUMA_0),
915 DEFINEREG(TV_H_LUMA_59),
916 DEFINEREG(TV_H_CHROMA_0),
917 DEFINEREG(TV_H_CHROMA_59),
918
919 DEFINEREG(FBC_CFB_BASE),
920 DEFINEREG(FBC_LL_BASE),
921 DEFINEREG(FBC_CONTROL),
922 DEFINEREG(FBC_COMMAND),
923 DEFINEREG(FBC_STATUS),
924 DEFINEREG(FBC_CONTROL2),
925 DEFINEREG(FBC_FENCE_OFF),
926 DEFINEREG(FBC_MOD_NUM),
927
928 DEFINEREG(MI_MODE),
929 /* DEFINEREG(MI_DISPLAY_POWER_DOWN), CRL only */
930 DEFINEREG(MI_ARB_STATE),
931 DEFINEREG(MI_RDRET_STATE),
932 DEFINEREG(ECOSKPD),
933
934 DEFINEREG(DP_B),
935 DEFINEREG(DPB_AUX_CH_CTL),
936 DEFINEREG(DPB_AUX_CH_DATA1),
937 DEFINEREG(DPB_AUX_CH_DATA2),
938 DEFINEREG(DPB_AUX_CH_DATA3),
939 DEFINEREG(DPB_AUX_CH_DATA4),
940 DEFINEREG(DPB_AUX_CH_DATA5),
941
942 DEFINEREG(DP_C),
943 DEFINEREG(DPC_AUX_CH_CTL),
944 DEFINEREG(DPC_AUX_CH_DATA1),
945 DEFINEREG(DPC_AUX_CH_DATA2),
946 DEFINEREG(DPC_AUX_CH_DATA3),
947 DEFINEREG(DPC_AUX_CH_DATA4),
948 DEFINEREG(DPC_AUX_CH_DATA5),
949
950 DEFINEREG(DP_D),
951 DEFINEREG(DPD_AUX_CH_CTL),
952 DEFINEREG(DPD_AUX_CH_DATA1),
953 DEFINEREG(DPD_AUX_CH_DATA2),
954 DEFINEREG(DPD_AUX_CH_DATA3),
955 DEFINEREG(DPD_AUX_CH_DATA4),
956 DEFINEREG(DPD_AUX_CH_DATA5),
957
958 DEFINEREG(AUD_CONFIG),
959 DEFINEREG(AUD_HDMIW_STATUS),
960 DEFINEREG(AUD_CONV_CHCNT),
961 DEFINEREG(VIDEO_DIP_CTL),
962 DEFINEREG(AUD_PINW_CNTR),
963 DEFINEREG(AUD_CNTL_ST),
964 DEFINEREG(AUD_PIN_CAP),
965 DEFINEREG(AUD_PINW_CAP),
966 DEFINEREG(AUD_PINW_UNSOLRESP),
967 DEFINEREG(AUD_OUT_DIG_CNVT),
968 DEFINEREG(AUD_OUT_CWCAP),
969 DEFINEREG(AUD_GRP_CAP),
970
971#define DEFINEFENCE_915(i) \
972 { FENCE+i*4, "FENCE " #i, i810_debug_915_fence }
973#define DEFINEFENCE_945(i) \
974 { FENCE_NEW+(i - 8) * 4, "FENCE " #i, i810_debug_915_fence }
975
976 DEFINEFENCE_915(0),
977 DEFINEFENCE_915(1),
978 DEFINEFENCE_915(2),
979 DEFINEFENCE_915(3),
980 DEFINEFENCE_915(4),
981 DEFINEFENCE_915(5),
982 DEFINEFENCE_915(6),
983 DEFINEFENCE_915(7),
984 DEFINEFENCE_945(8),
985 DEFINEFENCE_945(9),
986 DEFINEFENCE_945(10),
987 DEFINEFENCE_945(11),
988 DEFINEFENCE_945(12),
989 DEFINEFENCE_945(13),
990 DEFINEFENCE_945(14),
991 DEFINEFENCE_945(15),
992
993#define DEFINEFENCE_965(i) \
994 { FENCE_NEW+i*8, "FENCE START " #i, i810_debug_965_fence_start }, \
995 { FENCE_NEW+i*8+4, "FENCE END " #i, i810_debug_965_fence_end }
996
997 DEFINEFENCE_965(0),
998 DEFINEFENCE_965(1),
999 DEFINEFENCE_965(2),
1000 DEFINEFENCE_965(3),
1001 DEFINEFENCE_965(4),
1002 DEFINEFENCE_965(5),
1003 DEFINEFENCE_965(6),
1004 DEFINEFENCE_965(7),
1005 DEFINEFENCE_965(8),
1006 DEFINEFENCE_965(9),
1007 DEFINEFENCE_965(10),
1008 DEFINEFENCE_965(11),
1009 DEFINEFENCE_965(12),
1010 DEFINEFENCE_965(13),
1011 DEFINEFENCE_965(14),
1012 DEFINEFENCE_965(15),
1013
1014 DEFINEREG(INST_PM),
1015};
1016
1017DEBUGSTRING(ironlake_debug_rr_hw_ctl)
1018{
1019 snprintf(result, len, "low %d, high %d", val & RR_HW_LOW_POWER_FRAMES_MASK,
1020 (val & RR_HW_HIGH_POWER_FRAMES_MASK) >> 8);
1021}
1022
1023DEBUGSTRING(ironlake_debug_m_tu)
1024{
1025 snprintf(result, len, "TU %d, val 0x%x %d", (val >> 25) + 1, val & 0xffffff,
1026 val & 0xffffff);
1027}
1028
1029DEBUGSTRING(ironlake_debug_n)
1030{
1031 snprintf(result, len, "val 0x%x %d", val & 0xffffff, val & 0xffffff);
1032}
1033
1034DEBUGSTRING(ironlake_debug_fdi_tx_ctl)
1035{
1036 const char *train = NULL, *voltage = NULL, *pre_emphasis = NULL, *portw =
1037 NULL;
1038
1039 switch (val & FDI_LINK_TRAIN_NONE) {
1040 case FDI_LINK_TRAIN_PATTERN_1:
1041 train = "pattern_1";
1042 break;
1043 case FDI_LINK_TRAIN_PATTERN_2:
1044 train = "pattern_2";
1045 break;
1046 case FDI_LINK_TRAIN_PATTERN_IDLE:
1047 train = "pattern_idle";
1048 break;
1049 case FDI_LINK_TRAIN_NONE:
1050 train = "not train";
1051 break;
1052 }
1053
1054 if (HAS_CPT) {
1055 /* SNB B0 */
1056 switch (val & (0x3f << 22)) {
1057 case FDI_LINK_TRAIN_400MV_0DB_SNB_B:
1058 voltage = "0.4V";
1059 pre_emphasis = "0dB";
1060 break;
1061 case FDI_LINK_TRAIN_400MV_6DB_SNB_B:
1062 voltage = "0.4V";
1063 pre_emphasis = "6dB";
1064 break;
1065 case FDI_LINK_TRAIN_600MV_3_5DB_SNB_B:
1066 voltage = "0.6V";
1067 pre_emphasis = "3.5dB";
1068 break;
1069 case FDI_LINK_TRAIN_800MV_0DB_SNB_B:
1070 voltage = "0.8V";
1071 pre_emphasis = "0dB";
1072 break;
1073 }
1074
1075 } else {
1076
1077 switch (val & (7 << 25)) {
1078 case FDI_LINK_TRAIN_VOLTAGE_0_4V:
1079 voltage = "0.4V";
1080 break;
1081 case FDI_LINK_TRAIN_VOLTAGE_0_6V:
1082 voltage = "0.6V";
1083 break;
1084 case FDI_LINK_TRAIN_VOLTAGE_0_8V:
1085 voltage = "0.8V";
1086 break;
1087 case FDI_LINK_TRAIN_VOLTAGE_1_2V:
1088 voltage = "1.2V";
1089 break;
1090 default:
1091 voltage = "reserved";
1092 }
1093
1094 switch (val & (7 << 22)) {
1095 case FDI_LINK_TRAIN_PRE_EMPHASIS_NONE:
1096 pre_emphasis = "none";
1097 break;
1098 case FDI_LINK_TRAIN_PRE_EMPHASIS_1_5X:
1099 pre_emphasis = "1.5x";
1100 break;
1101 case FDI_LINK_TRAIN_PRE_EMPHASIS_2X:
1102 pre_emphasis = "2x";
1103 break;
1104 case FDI_LINK_TRAIN_PRE_EMPHASIS_3X:
1105 pre_emphasis = "3x";
1106 break;
1107 default:
1108 pre_emphasis = "reserved";
1109 }
1110
1111 }
1112
1113 switch (val & (7 << 19)) {
1114 case FDI_DP_PORT_WIDTH_X1:
1115 portw = "X1";
1116 break;
1117 case FDI_DP_PORT_WIDTH_X2:
1118 portw = "X2";
1119 break;
1120 case FDI_DP_PORT_WIDTH_X3:
1121 portw = "X3";
1122 break;
1123 case FDI_DP_PORT_WIDTH_X4:
1124 portw = "X4";
1125 break;
1126 }
1127
1128 snprintf(result, len, "%s, train pattern %s, voltage swing %s,"
1129 "pre-emphasis %s, port width %s, enhanced framing %s, FDI PLL %s, scrambing %s, master mode %s",
1130 val & FDI_TX_ENABLE ? "enable" : "disable",
1131 train, voltage, pre_emphasis, portw,
1132 val & FDI_TX_ENHANCE_FRAME_ENABLE ? "enable" :
1133 "disable",
1134 val & FDI_TX_PLL_ENABLE ? "enable" : "disable",
1135 val & (1 << 7) ? "disable" : "enable",
1136 val & (1 << 0) ? "enable" : "disable");
1137}
1138
1139DEBUGSTRING(ironlake_debug_fdi_rx_ctl)
1140{
1141 const char *train = NULL, *portw = NULL, *bpc = NULL;
1142
1143 if (HAS_CPT) {
1144 switch (val & FDI_LINK_TRAIN_PATTERN_MASK_CPT) {
1145 case FDI_LINK_TRAIN_PATTERN_1_CPT:
1146 train = "pattern_1";
1147 break;
1148 case FDI_LINK_TRAIN_PATTERN_2_CPT:
1149 train = "pattern_2";
1150 break;
1151 case FDI_LINK_TRAIN_PATTERN_IDLE_CPT:
1152 train = "pattern_idle";
1153 break;
1154 case FDI_LINK_TRAIN_NORMAL_CPT:
1155 train = "not train";
1156 break;
1157 }
1158 } else {
1159 switch (val & FDI_LINK_TRAIN_NONE) {
1160 case FDI_LINK_TRAIN_PATTERN_1:
1161 train = "pattern_1";
1162 break;
1163 case FDI_LINK_TRAIN_PATTERN_2:
1164 train = "pattern_2";
1165 break;
1166 case FDI_LINK_TRAIN_PATTERN_IDLE:
1167 train = "pattern_idle";
1168 break;
1169 case FDI_LINK_TRAIN_NONE:
1170 train = "not train";
1171 break;
1172 }
1173 }
1174
1175 switch (val & (7 << 19)) {
1176 case FDI_DP_PORT_WIDTH_X1:
1177 portw = "X1";
1178 break;
1179 case FDI_DP_PORT_WIDTH_X2:
1180 portw = "X2";
1181 break;
1182 case FDI_DP_PORT_WIDTH_X3:
1183 portw = "X3";
1184 break;
1185 case FDI_DP_PORT_WIDTH_X4:
1186 portw = "X4";
1187 break;
1188 }
1189
1190 switch (val & (7 << 16)) {
1191 case FDI_8BPC:
1192 bpc = "8bpc";
1193 break;
1194 case FDI_10BPC:
1195 bpc = "10bpc";
1196 break;
1197 case FDI_6BPC:
1198 bpc = "6bpc";
1199 break;
1200 case FDI_12BPC:
1201 bpc = "12bpc";
1202 break;
1203 }
1204
1205 snprintf(result, len, "%s, train pattern %s, port width %s, %s,"
1206 "link_reverse_strap_overwrite %s, dmi_link_reverse %s, FDI PLL %s,"
1207 "FS ecc %s, FE ecc %s, FS err report %s, FE err report %s,"
1208 "scrambing %s, enhanced framing %s, %s",
1209 val & FDI_RX_ENABLE ? "enable" : "disable",
1210 train, portw, bpc,
1211 val & FDI_LINK_REVERSE_OVERWRITE ? "yes" : "no",
1212 val & FDI_DMI_LINK_REVERSE_MASK ? "yes" : "no",
1213 val & FDI_RX_PLL_ENABLE ? "enable" : "disable",
1214 val & FDI_FS_ERR_CORRECT_ENABLE ? "enable" : "disable",
1215 val & FDI_FE_ERR_CORRECT_ENABLE ? "enable" : "disable",
1216 val & FDI_FS_ERR_REPORT_ENABLE ? "enable" : "disable",
1217 val & FDI_FE_ERR_REPORT_ENABLE ? "enable" : "disable",
1218 val & (1 << 7) ? "disable" : "enable",
1219 val & FDI_RX_ENHANCE_FRAME_ENABLE ? "enable" :
1220 "disable", val & FDI_SEL_PCDCLK ? "PCDClk" : "RawClk");
1221}
1222
1223DEBUGSTRING(ironlake_debug_dspstride)
1224{
1225 snprintf(result, len, "%d", val >> 6);
1226}
1227
1228DEBUGSTRING(ironlake_debug_pch_dpll)
1229{
1230 const char *enable = val & DPLL_VCO_ENABLE ? "enable" : "disable";
1231 const char *highspeed = val & DPLL_DVO_HIGH_SPEED ? "yes" : "no";
1232 const char *mode = NULL;
1233 const char *p2 = NULL;
1234 int fpa0_p1, fpa1_p1;
1235 const char *refclk = NULL;
1236 int sdvo_mul;
1237
1238 if ((val & DPLLB_MODE_LVDS) == DPLLB_MODE_LVDS) {
1239 mode = "LVDS";
1240 if (val & DPLLB_LVDS_P2_CLOCK_DIV_7)
1241 p2 = "Div 7";
1242 else
1243 p2 = "Div 14";
1244 } else if ((val & DPLLB_MODE_LVDS) == DPLLB_MODE_DAC_SERIAL) {
1245 mode = "Non-LVDS";
1246 if (val & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5)
1247 p2 = "Div 5";
1248 else
1249 p2 = "Div 10";
1250 }
1251 fpa0_p1 = ffs((val & DPLL_FPA01_P1_POST_DIV_MASK) >> 16);
1252 fpa1_p1 = ffs((val & DPLL_FPA1_P1_POST_DIV_MASK));
1253
1254 switch (val & PLL_REF_INPUT_MASK) {
1255 case PLL_REF_INPUT_DREFCLK:
1256 refclk = "default 120Mhz";
1257 break;
1258 case PLL_REF_INPUT_SUPER_SSC:
1259 refclk = "SuperSSC 120Mhz";
1260 break;
1261 case PLL_REF_INPUT_TVCLKINBC:
1262 refclk = "SDVO TVClkIn";
1263 break;
1264 case PLLB_REF_INPUT_SPREADSPECTRUMIN:
1265 refclk = "SSC";
1266 break;
1267 case PLL_REF_INPUT_DMICLK:
1268 refclk = "DMI RefCLK";
1269 break;
1270 }
1271
1272 sdvo_mul = ((val & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK) >> 9) + 1;
1273
1274 snprintf(result, len, "%s, sdvo high speed %s, mode %s, p2 %s, "
1275 "FPA0 P1 %d, FPA1 P1 %d, refclk %s, sdvo/hdmi mul %d",
1276 enable, highspeed, mode, p2, fpa0_p1, fpa1_p1, refclk,
1277 sdvo_mul);
1278}
1279
1280DEBUGSTRING(ironlake_debug_dref_ctl)
1281{
1282 const char *cpu_source;
1283 const char *ssc_source = val & DREF_SSC_SOURCE_ENABLE ? "enable" : "disable";
1284 const char *nonspread_source =
1285 val & DREF_NONSPREAD_SOURCE_ENABLE ? "enable" : "disable";
1286 const char *superspread_source =
1287 val & DREF_SUPERSPREAD_SOURCE_ENABLE ? "enable" : "disable";
1288 const char *ssc4_mode =
1289 val & DREF_SSC4_CENTERSPREAD ? "centerspread" : "downspread";
1290 const char *ssc1 = val & DREF_SSC1_ENABLE ? "enable" : "disable";
1291 const char *ssc4 = val & DREF_SSC4_ENABLE ? "enable" : "disable";
1292
1293 switch (val & DREF_CPU_SOURCE_OUTPUT_NONSPREAD) {
1294 case DREF_CPU_SOURCE_OUTPUT_DISABLE:
1295 cpu_source = "disable";
1296 break;
1297 case DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD:
1298 cpu_source = "downspread";
1299 break;
1300 case DREF_CPU_SOURCE_OUTPUT_NONSPREAD:
1301 cpu_source = "nonspread";
1302 break;
1303 default:
1304 cpu_source = "reserved";
1305 }
1306 snprintf(result, len, "cpu source %s, ssc_source %s, nonspread_source %s, "
1307 "superspread_source %s, ssc4_mode %s, ssc1 %s, ssc4 %s",
1308 cpu_source, ssc_source, nonspread_source,
1309 superspread_source, ssc4_mode, ssc1, ssc4);
1310}
1311
1312DEBUGSTRING(ironlake_debug_rawclk_freq)
1313{
1314 const char *tp1 = NULL, *tp2 = NULL;
1315
1316 switch (val & FDL_TP1_TIMER_MASK) {
1317 case 0:
1318 tp1 = "0.5us";
1319 break;
1320 case (1 << 12):
1321 tp1 = "1.0us";
1322 break;
1323 case (2 << 12):
1324 tp1 = "2.0us";
1325 break;
1326 case (3 << 12):
1327 tp1 = "4.0us";
1328 break;
1329 }
1330 switch (val & FDL_TP2_TIMER_MASK) {
1331 case 0:
1332 tp2 = "1.5us";
1333 break;
1334 case (1 << 10):
1335 tp2 = "3.0us";
1336 break;
1337 case (2 << 10):
1338 tp2 = "6.0us";
1339 break;
1340 case (3 << 10):
1341 tp2 = "12.0us";
1342 break;
1343 }
1344 snprintf(result, len, "FDL_TP1 timer %s, FDL_TP2 timer %s, freq %d",
1345 tp1, tp2, val & RAWCLK_FREQ_MASK);
1346
1347}
1348
1349DEBUGSTRING(ironlake_debug_fdi_rx_misc)
1350{
1351 snprintf(result, len, "FDI Delay %d", val & ((1 << 13) - 1));
1352}
1353
1354DEBUGSTRING(ironlake_debug_transconf)
1355{
1356 const char *enable = val & TRANS_ENABLE ? "enable" : "disable";
1357 const char *state = val & TRANS_STATE_ENABLE ? "active" : "inactive";
1358 const char *interlace;
1359
1360 switch ((val >> 21) & 7) {
1361 case 0:
1362 interlace = "progressive";
1363 break;
1364 case 2:
1365 if (IS_GEN5(devid))
1366 interlace = "interlaced sdvo";
1367 else
1368 interlace = "rsvd";
1369 break;
1370 case 3:
1371 interlace = "interlaced";
1372 break;
1373 default:
1374 interlace = "rsvd";
1375 }
1376
1377 snprintf(result, len, "%s, %s, %s", enable, state, interlace);
1378}
1379
1380DEBUGSTRING(ironlake_debug_panel_fitting)
1381{
1382 const char *vadapt = NULL, *filter_sel = NULL;
1383
1384 switch (val & (3 << 25)) {
1385 case 0:
1386 vadapt = "least";
1387 break;
1388 case (1 << 25):
1389 vadapt = "moderate";
1390 break;
1391 case (2 << 25):
1392 vadapt = "reserved";
1393 break;
1394 case (3 << 25):
1395 vadapt = "most";
1396 break;
1397 }
1398
1399 switch (val & (3 << 23)) {
1400 case 0:
1401 filter_sel = "programmed";
1402 break;
1403 case (1 << 23):
1404 filter_sel = "hardcoded";
1405 break;
1406 case (2 << 23):
1407 filter_sel = "edge_enhance";
1408 break;
1409 case (3 << 23):
1410 filter_sel = "edge_soften";
1411 break;
1412 }
1413
1414 snprintf(result, len,
1415 "%s, auto_scale %s, auto_scale_cal %s, v_filter %s, vadapt %s, mode %s, filter_sel %s,"
1416 "chroma pre-filter %s, vert3tap %s, v_inter_invert %s",
1417 val & PF_ENABLE ? "enable" : "disable",
1418 val & (1 << 30) ? "no" : "yes",
1419 val & (1 << 29) ? "yes" : "no",
1420 val & (1 << 28) ? "bypass" : "enable",
1421 val & (1 << 27) ? "enable" : "disable",
1422 vadapt,
1423 filter_sel,
1424 val & (1 << 22) ? "enable" : "disable",
1425 val & (1 << 21) ? "force" : "auto",
1426 val & (1 << 20) ? "field 0" : "field 1");
1427}
1428
1429DEBUGSTRING(ironlake_debug_panel_fitting_2)
1430{
1431 snprintf(result, len,
1432 "vscale %f",
1433 val / (float) (1<<15));
1434}
1435
1436DEBUGSTRING(ironlake_debug_panel_fitting_3)
1437{
1438 snprintf(result, len,
1439 "vscale initial phase %f",
1440 val / (float) (1<<15));
1441}
1442
1443DEBUGSTRING(ironlake_debug_panel_fitting_4)
1444{
1445 snprintf(result, len,
1446 "hscale %f",
1447 val / (float) (1<<15));
1448}
1449
1450DEBUGSTRING(ironlake_debug_pf_win)
1451{
1452 int a, b;
1453
1454 a = (val >> 16) & 0x1fff;
1455 b = val & 0xfff;
1456
1457 snprintf(result, len, "%d, %d", a, b);
1458}
1459
1460DEBUGSTRING(ironlake_debug_hdmi)
1461{
1462 int disp_pipe;
1463 const char *enable, *bpc = NULL, *encoding;
1464 const char *mode, *audio, *vsync, *hsync, *detect;
1465
1466 if (val & PORT_ENABLE)
1467 enable = "enabled";
1468 else
1469 enable = "disabled";
1470
1471 if (HAS_CPT)
1472 disp_pipe = (val & (3<<29)) >> 29;
1473 else
1474 disp_pipe = (val & TRANSCODER_B) >> 29;
1475
1476 switch (val & (7 << 26)) {
1477 case COLOR_FORMAT_8bpc:
1478 bpc = "8bpc";
1479 break;
1480 case COLOR_FORMAT_12bpc:
1481 bpc = "12bpc";
1482 break;
1483 }
1484
1485 if ((val & (3 << 10)) == TMDS_ENCODING)
1486 encoding = "TMDS";
1487 else
1488 encoding = "SDVO";
1489
1490 if (val & (1 << 9))
1491 mode = "HDMI";
1492 else
1493 mode = "DVI";
1494
1495 if (val & AUDIO_ENABLE)
1496 audio = "enabled";
1497 else
1498 audio = "disabled";
1499
1500 if (val & VSYNC_ACTIVE_HIGH)
1501 vsync = "+vsync";
1502 else
1503 vsync = "-vsync";
1504
1505 if (val & HSYNC_ACTIVE_HIGH)
1506 hsync = "+hsync";
1507 else
1508 hsync = "-hsync";
1509
1510 if (val & PORT_DETECTED)
1511 detect = "detected";
1512 else
1513 detect = "non-detected";
1514
1515 snprintf(result, len, "%s pipe %c %s %s %s audio %s %s %s %s",
1516 enable, disp_pipe + 'A', bpc, encoding, mode, audio, vsync, hsync, detect);
1517}
1518
1519DEBUGSTRING(snb_debug_dpll_sel)
1520{
1521 const char *transa, *transb;
1522 const char *dplla = NULL, *dpllb = NULL;
1523
1524 if (!HAS_CPT)
1525 return;
1526
1527 if (val & TRANSA_DPLL_ENABLE) {
1528 transa = "enable";
1529 if (val & TRANSA_DPLLB_SEL)
1530 dplla = "B";
1531 else
1532 dplla = "A";
1533 } else
1534 transa = "disable";
1535
1536 if (val & TRANSB_DPLL_ENABLE) {
1537 transb = "enable";
1538 if (val & TRANSB_DPLLB_SEL)
1539 dpllb = "B";
1540 else
1541 dpllb = "A";
1542 } else
1543 transb = "disable";
1544
1545 snprintf(result, len, "TransA DPLL %s (DPLL %s), TransB DPLL %s (DPLL %s)",
1546 transa, dplla, transb, dpllb);
1547}
1548
1549DEBUGSTRING(snb_debug_trans_dp_ctl)
1550{
1551 const char *enable, *port = NULL, *bpc = NULL, *vsync, *hsync;
1552
1553 if (!HAS_CPT)
1554 return;
1555
1556 if (val & TRANS_DP_OUTPUT_ENABLE)
1557 enable = "enable";
1558 else
1559 enable = "disable";
1560
1561 switch (val & TRANS_DP_PORT_SEL_MASK) {
1562 case TRANS_DP_PORT_SEL_B:
1563 port = "B";
1564 break;
1565 case TRANS_DP_PORT_SEL_C:
1566 port = "C";
1567 break;
1568 case TRANS_DP_PORT_SEL_D:
1569 port = "D";
1570 break;
1571 default:
1572 port = "none";
1573 break;
1574 }
1575
1576 switch (val & (7<<9)) {
1577 case TRANS_DP_8BPC:
1578 bpc = "8bpc";
1579 break;
1580 case TRANS_DP_10BPC:
1581 bpc = "10bpc";
1582 break;
1583 case TRANS_DP_6BPC:
1584 bpc = "6bpc";
1585 break;
1586 case TRANS_DP_12BPC:
1587 bpc = "12bpc";
1588 break;
1589 }
1590
1591 if (val & TRANS_DP_VSYNC_ACTIVE_HIGH)
1592 vsync = "+vsync";
1593 else
1594 vsync = "-vsync";
1595
1596 if (val & TRANS_DP_HSYNC_ACTIVE_HIGH)
1597 hsync = "+hsync";
1598 else
1599 hsync = "-hsync";
1600
1601 snprintf(result, len, "%s port %s %s %s %s",
1602 enable, port, bpc, vsync, hsync);
1603}
1604
1605DEBUGSTRING(ilk_debug_pp_control)
1606{
1607 snprintf(result, len, "blacklight %s, %spower down on reset, panel %s",
1608 (val & (1 << 2)) ? "enabled" : "disabled",
1609 (val & (1 << 1)) ? "" : "do not ",
1610 (val & (1 << 0)) ? "on" : "off");
1611}
1612
1613DEBUGSTRING(hsw_debug_port_clk_sel)
1614{
1615 const char *clock = NULL;
1616
1617 switch ((val >> 29 ) & 7) {
1618 case 0:
1619 clock = "LCPLL 2700";
1620 break;
1621 case 1:
1622 clock = "LCPLL 1350";
1623 break;
1624 case 2:
1625 clock = "LCPLL 810";
1626 break;
1627 case 3:
1628 clock = "SPLL";
1629 break;
1630 case 4:
1631 clock = "WRPLL 1";
1632 break;
1633 case 5:
1634 clock = "WRPLL 2";
1635 break;
1636 case 6:
1637 clock = "Reserved";
1638 break;
1639 case 7:
1640 clock = "None";
1641 break;
1642 }
1643
1644 snprintf(result, len, "%s", clock);
1645}
1646
1647DEBUGSTRING(hsw_debug_pipe_clk_sel)
1648{
1649 const char *clock;
1650
1651 switch ((val >> 29) & 7) {
1652 case 0:
1653 clock = "None";
1654 break;
1655 case 2:
1656 clock = "DDIB";
1657 break;
1658 case 3:
1659 clock = "DDIC";
1660 break;
1661 case 4:
1662 clock = "DDID";
1663 break;
1664 case 5:
1665 clock = "DDIE";
1666 break;
1667 default:
1668 clock = "Reserved";
1669 break;
1670 }
1671
1672 snprintf(result, len, "%s", clock);
1673}
1674
1675DEBUGSTRING(hsw_debug_ddi_buf_ctl)
1676{
1677 const char *enable, *reversal, *width, *detected;
1678
1679 enable = (val & (1<<31)) ? "enabled" : "disabled";
1680 reversal = (val & (1<<16)) ? "reversed" : "not reversed";
1681
1682 switch ((val >> 1) & 7) {
1683 case 0:
1684 width = "x1";
1685 break;
1686 case 1:
1687 width = "x2";
1688 break;
1689 case 3:
1690 width = "x4";
1691 break;
1692 default:
1693 width = "reserved";
1694 break;
1695 }
1696
1697 detected = (val & 1) ? "detected" : "not detected";
1698
1699 snprintf(result, len, "%s %s %s %s", enable, reversal, width, detected);
1700}
1701
1702DEBUGSTRING(hsw_debug_sfuse_strap)
1703{
1704 const char *display, *crt, *lane_reversal, *portb, *portc, *portd;
1705
1706 display = (val & (1<<7)) ? "disabled" : "enabled";
1707 crt = (val & (1<<6)) ? "yes" : "no";
1708 lane_reversal = (val & (1<<4)) ? "yes" : "no";
1709 portb = (val & (1<<2)) ? "yes" : "no";
1710 portc = (val & (1<<1)) ? "yes" : "no";
1711 portd = (val & (1<<0)) ? "yes" : "no";
1712
1713 snprintf(result, len, "display %s, crt %s, lane reversal %s, "
1714 "port b %s, port c %s, port d %s", display, crt, lane_reversal,
1715 portb, portc, portd);
1716}
1717
1718DEBUGSTRING(hsw_debug_pipe_ddi_func_ctl)
1719{
1720 const char *enable, *port, *mode, *bpc, *vsync, *hsync, *edp_input;
1721 const char *width;
1722
1723 enable = (val & (1<<31)) ? "enabled" : "disabled";
1724
1725 switch ((val >> 28) & 7) {
1726 case 0:
1727 port = "no port";
1728 break;
1729 case 1:
1730 port = "DDIB";
1731 break;
1732 case 2:
1733 port = "DDIC";
1734 break;
1735 case 3:
1736 port = "DDID";
1737 break;
1738 case 4:
1739 port = "DDIE";
1740 break;
1741 default:
1742 port = "port reserved";
1743 break;
1744 }
1745
1746 switch ((val >> 24) & 7) {
1747 case 0:
1748 mode = "HDMI";
1749 break;
1750 case 1:
1751 mode = "DVI";
1752 break;
1753 case 2:
1754 mode = "DP SST";
1755 break;
1756 case 3:
1757 mode = "DP MST";
1758 break;
1759 case 4:
1760 mode = "FDI";
1761 break;
1762 case 5:
1763 default:
1764 mode = "mode reserved";
1765 break;
1766 }
1767
1768 switch ((val >> 20) & 7) {
1769 case 0:
1770 bpc = "8 bpc";
1771 break;
1772 case 1:
1773 bpc = "10 bpc";
1774 break;
1775 case 2:
1776 bpc = "6 bpc";
1777 break;
1778 case 3:
1779 bpc = "12 bpc";
1780 break;
1781 default:
1782 bpc = "bpc reserved";
1783 break;
1784 }
1785
1786 hsync = (val & (1<<16)) ? "+HSync" : "-HSync";
1787 vsync = (val & (1<<17)) ? "+VSync" : "-VSync";
1788
1789 switch ((val >> 12) & 7) {
1790 case 0:
1791 edp_input = "EDP A ON";
1792 break;
1793 case 4:
1794 edp_input = "EDP A ONOFF";
1795 break;
1796 case 5:
1797 edp_input = "EDP B ONOFF";
1798 break;
1799 case 6:
1800 edp_input = "EDP C ONOFF";
1801 break;
1802 default:
1803 edp_input = "EDP input reserved";
1804 break;
1805 }
1806
1807 switch ((val >> 1) & 7) {
1808 case 0:
1809 width = "x1";
1810 break;
1811 case 1:
1812 width = "x2";
1813 break;
1814 case 3:
1815 width = "x4";
1816 break;
1817 default:
1818 width = "reserved width";
1819 break;
1820 }
1821
1822 snprintf(result, len, "%s, %s, %s, %s, %s, %s, %s, %s", enable,
1823 port, mode, bpc, vsync, hsync, edp_input, width);
1824}
1825
1826DEBUGSTRING(hsw_debug_wm_pipe)
1827{
1828 uint32_t primary, sprite, cursor;
1829
1830 primary = (val >> 16) & 0x7F;
1831 sprite = (val >> 8) & 0x7F;
1832 cursor = val & 0x3F;
1833
1834 snprintf(result, len, "primary %d, sprite %d, pipe %d", primary,
1835 sprite, cursor);
1836}
1837
1838DEBUGSTRING(hsw_debug_lp_wm)
1839{
1840 const char *enable;
1841 uint32_t latency, fbc, pri, cur;
1842
1843 enable = ((val >> 31) & 1) ? "enabled" : "disabled";
1844 latency = (val >> 24) & 0x7F;
1845 fbc = (val >> 20) & 0xF;
1846 pri = (val >> 8) & 0x3FF;
1847 cur = val & 0xFF;
1848
1849 snprintf(result, len, "%s, latency %d, fbc %d, pri %d, cur %d",
1850 enable, latency, fbc, pri, cur);
1851}
1852
1853DEBUGSTRING(hsw_debug_sinterrupt)
1854{
1855 int portd, portc, portb, crt;
1856
1857 portd = (val >> 23) & 1;
1858 portc = (val >> 22) & 1;
1859 portb = (val >> 21) & 1;
1860 crt = (val >> 19) & 1;
1861
1862 snprintf(result, len, "port d:%d, port c:%d, port b:%d, crt:%d",
1863 portd, portc, portb, crt);
1864}
1865
1866DEBUGSTRING(ilk_debug_blc_pwm_cpu_ctl2)
1867{
1868 int enable, blinking, granularity;
1869 const char *pipe;
1870
1871 enable = (val >> 31) & 1;
1872
1873 if (IS_GEN5(devid) || IS_GEN6(devid)) {
1874 pipe = ((val >> 29) & 1) ? "B" : "A";
1875 } else {
1876 switch ((val >> 29) & 3) {
1877 case 0:
1878 pipe = "A";
1879 break;
1880 case 1:
1881 pipe = "B";
1882 break;
1883 case 2:
1884 pipe = "C";
1885 break;
1886 case 3:
1887 if (IS_IVYBRIDGE(devid))
1888 pipe = "reserved";
1889 else
1890 pipe = "EDP";
1891 break;
1892 }
1893 }
1894
1895 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_IVYBRIDGE(devid)) {
1896 snprintf(result, len, "enable %d, pipe %s", enable, pipe);
1897 } else {
1898 blinking = (val >> 28) & 1;
1899 granularity = ((val >> 27) & 1) ? 8 : 128;
1900
1901 snprintf(result, len, "enable %d, pipe %s, blinking %d, "
1902 "granularity %d", enable, pipe, blinking,
1903 granularity);
1904 }
1905}
1906
1907DEBUGSTRING(ilk_debug_blc_pwm_cpu_ctl)
1908{
1909 int cycle, freq;
1910
1911 cycle = (val & 0xFFFF);
1912
1913 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_IVYBRIDGE(devid)) {
1914 snprintf(result, len, "cycle %d", cycle);
1915 } else {
1916 freq = (val >> 16) & 0xFFFF;
1917
1918 snprintf(result, len, "cycle %d, freq %d", cycle, freq);
1919 }
1920}
1921
1922DEBUGSTRING(ibx_debug_blc_pwm_ctl1)
1923{
1924 int enable, override, inverted_polarity;
1925
1926 enable = (val >> 31) & 1;
1927 override = (val >> 30) & 1;
1928 inverted_polarity = (val >> 29) & 1;
1929
1930 snprintf(result, len, "enable %d, override %d, inverted polarity %d",
1931 enable, override, inverted_polarity);
1932}
1933
1934DEBUGSTRING(ibx_debug_blc_pwm_ctl2)
1935{
1936 int freq, cycle;
1937
1938 freq = (val >> 16) & 0xFFFF;
1939 cycle = val & 0xFFFF;
1940
1941 snprintf(result, len, "freq %d, cycle %d", freq, cycle);
1942}
1943
1944DEBUGSTRING(hsw_debug_blc_misc_ctl)
1945{
1946 const char *sel;
1947
1948 sel = (val & 1) ? "PWM1-CPU PWM2-PCH" : "PWM1-PCH PWM2-CPU";
1949
1950 snprintf(result, len, "%s", sel);
1951}
1952
1953DEBUGSTRING(hsw_debug_util_pin_ctl)
1954{
1955 int enable, data, inverted_polarity;
1956 const char *transcoder, *mode;
1957
1958 enable = (val >> 31) & 1;
1959
1960 switch ((val >> 29) & 3) {
1961 case 0:
1962 transcoder = "A";
1963 break;
1964 case 1:
1965 transcoder = "B";
1966 break;
1967 case 2:
1968 transcoder = "C";
1969 break;
1970 case 3:
1971 transcoder = "EDP";
1972 break;
1973 }
1974
1975 switch ((val >> 24) & 0xF) {
1976 case 0:
1977 mode = "data";
1978 break;
1979 case 1:
1980 mode = "PWM";
1981 break;
1982 case 4:
1983 mode = "Vblank";
1984 break;
1985 case 5:
1986 mode = "Vsync";
1987 break;
1988 default:
1989 mode = "reserved";
1990 break;
1991 }
1992
1993 data = (val >> 23) & 1;
1994 inverted_polarity = (val >> 22) & 1;
1995
1996 snprintf(result, len, "enable %d, transcoder %s, mode %s, data %d "
1997 "inverted polarity %d", enable, transcoder, mode, data,
1998 inverted_polarity);
1999}
2000
2001static const struct reg_debug gen6_fences[] = {
2002#define DEFINEFENCE_SNB(i) \
2003 { FENCE_REG_SANDYBRIDGE_0 + (i) * 8, "FENCE START "#i, NULL }, \
2004 { FENCE_REG_SANDYBRIDGE_0 + (i) * 8 + 4, "FENCE END "#i, NULL }
2005 DEFINEFENCE_SNB(0),
2006 DEFINEFENCE_SNB(1),
2007 DEFINEFENCE_SNB(2),
2008 DEFINEFENCE_SNB(3),
2009 DEFINEFENCE_SNB(4),
2010 DEFINEFENCE_SNB(5),
2011 DEFINEFENCE_SNB(6),
2012 DEFINEFENCE_SNB(7),
2013 DEFINEFENCE_SNB(8),
2014 DEFINEFENCE_SNB(9),
2015 DEFINEFENCE_SNB(10),
2016 DEFINEFENCE_SNB(11),
2017 DEFINEFENCE_SNB(12),
2018 DEFINEFENCE_SNB(13),
2019 DEFINEFENCE_SNB(14),
2020 DEFINEFENCE_SNB(15),
2021 DEFINEFENCE_SNB(16),
2022 DEFINEFENCE_SNB(17),
2023 DEFINEFENCE_SNB(18),
2024 DEFINEFENCE_SNB(19),
2025 DEFINEFENCE_SNB(20),
2026 DEFINEFENCE_SNB(20),
2027 DEFINEFENCE_SNB(21),
2028 DEFINEFENCE_SNB(22),
2029 DEFINEFENCE_SNB(23),
2030 DEFINEFENCE_SNB(24),
2031 DEFINEFENCE_SNB(25),
2032 DEFINEFENCE_SNB(26),
2033 DEFINEFENCE_SNB(27),
2034 DEFINEFENCE_SNB(28),
2035 DEFINEFENCE_SNB(29),
2036 DEFINEFENCE_SNB(30),
2037 DEFINEFENCE_SNB(31),
2038};
2039
2040static const struct reg_debug ironlake_debug_regs[] = {
2041 DEFINEREG(PGETBL_CTL),
2042 DEFINEREG(INSTDONE_I965),
2043 DEFINEREG(INSTDONE_1),
2044 DEFINEREG2(CPU_VGACNTRL, i830_debug_vgacntrl),
2045 DEFINEREG(DIGITAL_PORT_HOTPLUG_CNTRL),
2046
2047 DEFINEREG2(RR_HW_CTL, ironlake_debug_rr_hw_ctl),
2048
2049 DEFINEREG(FDI_PLL_BIOS_0),
2050 DEFINEREG(FDI_PLL_BIOS_1),
2051 DEFINEREG(FDI_PLL_BIOS_2),
2052
2053 DEFINEREG(DISPLAY_PORT_PLL_BIOS_0),
2054 DEFINEREG(DISPLAY_PORT_PLL_BIOS_1),
2055 DEFINEREG(DISPLAY_PORT_PLL_BIOS_2),
2056
2057 DEFINEREG(FDI_PLL_FREQ_CTL),
2058
2059 /* pipe B */
2060
2061 DEFINEREG2(PIPEACONF, i830_debug_pipeconf),
2062
2063 DEFINEREG2(HTOTAL_A, i830_debug_hvtotal),
2064 DEFINEREG2(HBLANK_A, i830_debug_hvsyncblank),
2065 DEFINEREG2(HSYNC_A, i830_debug_hvsyncblank),
2066 DEFINEREG2(VTOTAL_A, i830_debug_hvtotal),
2067 DEFINEREG2(VBLANK_A, i830_debug_hvsyncblank),
2068 DEFINEREG2(VSYNC_A, i830_debug_hvsyncblank),
2069 DEFINEREG(VSYNCSHIFT_A),
2070 DEFINEREG2(PIPEASRC, i830_debug_yxminus1),
2071
2072 DEFINEREG2(PIPEA_DATA_M1, ironlake_debug_m_tu),
2073 DEFINEREG2(PIPEA_DATA_N1, ironlake_debug_n),
2074 DEFINEREG2(PIPEA_DATA_M2, ironlake_debug_m_tu),
2075 DEFINEREG2(PIPEA_DATA_N2, ironlake_debug_n),
2076
2077 DEFINEREG2(PIPEA_LINK_M1, ironlake_debug_n),
2078 DEFINEREG2(PIPEA_LINK_N1, ironlake_debug_n),
2079 DEFINEREG2(PIPEA_LINK_M2, ironlake_debug_n),
2080 DEFINEREG2(PIPEA_LINK_N2, ironlake_debug_n),
2081
2082 DEFINEREG2(DSPACNTR, i830_debug_dspcntr),
2083 DEFINEREG(DSPABASE),
2084 DEFINEREG2(DSPASTRIDE, ironlake_debug_dspstride),
2085 DEFINEREG(DSPASURF),
2086 DEFINEREG2(DSPATILEOFF, i830_debug_xy),
2087
2088 /* pipe B */
2089
2090 DEFINEREG2(PIPEBCONF, i830_debug_pipeconf),
2091
2092 DEFINEREG2(HTOTAL_B, i830_debug_hvtotal),
2093 DEFINEREG2(HBLANK_B, i830_debug_hvsyncblank),
2094 DEFINEREG2(HSYNC_B, i830_debug_hvsyncblank),
2095 DEFINEREG2(VTOTAL_B, i830_debug_hvtotal),
2096 DEFINEREG2(VBLANK_B, i830_debug_hvsyncblank),
2097 DEFINEREG2(VSYNC_B, i830_debug_hvsyncblank),
2098 DEFINEREG(VSYNCSHIFT_B),
2099 DEFINEREG2(PIPEBSRC, i830_debug_yxminus1),
2100
2101 DEFINEREG2(PIPEB_DATA_M1, ironlake_debug_m_tu),
2102 DEFINEREG2(PIPEB_DATA_N1, ironlake_debug_n),
2103 DEFINEREG2(PIPEB_DATA_M2, ironlake_debug_m_tu),
2104 DEFINEREG2(PIPEB_DATA_N2, ironlake_debug_n),
2105
2106 DEFINEREG2(PIPEB_LINK_M1, ironlake_debug_n),
2107 DEFINEREG2(PIPEB_LINK_N1, ironlake_debug_n),
2108 DEFINEREG2(PIPEB_LINK_M2, ironlake_debug_n),
2109 DEFINEREG2(PIPEB_LINK_N2, ironlake_debug_n),
2110
2111 DEFINEREG2(DSPBCNTR, i830_debug_dspcntr),
2112 DEFINEREG(DSPBBASE),
2113 DEFINEREG2(DSPBSTRIDE, ironlake_debug_dspstride),
2114 DEFINEREG(DSPBSURF),
2115 DEFINEREG2(DSPBTILEOFF, i830_debug_xy),
2116
2117 /* pipe C */
2118
2119 DEFINEREG2(PIPECCONF, i830_debug_pipeconf),
2120
2121 DEFINEREG2(HTOTAL_C, i830_debug_hvtotal),
2122 DEFINEREG2(HBLANK_C, i830_debug_hvsyncblank),
2123 DEFINEREG2(HSYNC_C, i830_debug_hvsyncblank),
2124 DEFINEREG2(VTOTAL_C, i830_debug_hvtotal),
2125 DEFINEREG2(VBLANK_C, i830_debug_hvsyncblank),
2126 DEFINEREG2(VSYNC_C, i830_debug_hvsyncblank),
2127 DEFINEREG(VSYNCSHIFT_C),
2128 DEFINEREG2(PIPECSRC, i830_debug_yxminus1),
2129
2130 DEFINEREG2(PIPEC_DATA_M1, ironlake_debug_m_tu),
2131 DEFINEREG2(PIPEC_DATA_N1, ironlake_debug_n),
2132 DEFINEREG2(PIPEC_DATA_M2, ironlake_debug_m_tu),
2133 DEFINEREG2(PIPEC_DATA_N2, ironlake_debug_n),
2134
2135 DEFINEREG2(PIPEC_LINK_M1, ironlake_debug_n),
2136 DEFINEREG2(PIPEC_LINK_N1, ironlake_debug_n),
2137 DEFINEREG2(PIPEC_LINK_M2, ironlake_debug_n),
2138 DEFINEREG2(PIPEC_LINK_N2, ironlake_debug_n),
2139
2140 DEFINEREG2(DSPCCNTR, i830_debug_dspcntr),
2141 DEFINEREG(DSPCBASE),
2142 DEFINEREG2(DSPCSTRIDE, ironlake_debug_dspstride),
2143 DEFINEREG(DSPCSURF),
2144 DEFINEREG2(DSPCTILEOFF, i830_debug_xy),
2145
2146 /* Panel fitter */
2147
2148 DEFINEREG2(PFA_CTL_1, ironlake_debug_panel_fitting),
2149 DEFINEREG2(PFA_CTL_2, ironlake_debug_panel_fitting_2),
2150 DEFINEREG2(PFA_CTL_3, ironlake_debug_panel_fitting_3),
2151 DEFINEREG2(PFA_CTL_4, ironlake_debug_panel_fitting_4),
2152 DEFINEREG2(PFA_WIN_POS, ironlake_debug_pf_win),
2153 DEFINEREG2(PFA_WIN_SIZE, ironlake_debug_pf_win),
2154 DEFINEREG2(PFB_CTL_1, ironlake_debug_panel_fitting),
2155 DEFINEREG2(PFB_CTL_2, ironlake_debug_panel_fitting_2),
2156 DEFINEREG2(PFB_CTL_3, ironlake_debug_panel_fitting_3),
2157 DEFINEREG2(PFB_CTL_4, ironlake_debug_panel_fitting_4),
2158 DEFINEREG2(PFB_WIN_POS, ironlake_debug_pf_win),
2159 DEFINEREG2(PFB_WIN_SIZE, ironlake_debug_pf_win),
2160 DEFINEREG2(PFC_CTL_1, ironlake_debug_panel_fitting),
2161 DEFINEREG2(PFC_CTL_2, ironlake_debug_panel_fitting_2),
2162 DEFINEREG2(PFC_CTL_3, ironlake_debug_panel_fitting_3),
2163 DEFINEREG2(PFC_CTL_4, ironlake_debug_panel_fitting_4),
2164 DEFINEREG2(PFC_WIN_POS, ironlake_debug_pf_win),
2165 DEFINEREG2(PFC_WIN_SIZE, ironlake_debug_pf_win),
2166
2167 /* PCH */
2168
2169 DEFINEREG2(PCH_DREF_CONTROL, ironlake_debug_dref_ctl),
2170 DEFINEREG2(PCH_RAWCLK_FREQ, ironlake_debug_rawclk_freq),
2171 DEFINEREG(PCH_DPLL_TMR_CFG),
2172 DEFINEREG(PCH_SSC4_PARMS),
2173 DEFINEREG(PCH_SSC4_AUX_PARMS),
2174 DEFINEREG2(PCH_DPLL_SEL, snb_debug_dpll_sel),
2175 DEFINEREG(PCH_DPLL_ANALOG_CTL),
2176
2177 DEFINEREG2(PCH_DPLL_A, ironlake_debug_pch_dpll),
2178 DEFINEREG2(PCH_DPLL_B, ironlake_debug_pch_dpll),
2179 DEFINEREG2(PCH_FPA0, i830_debug_fp),
2180 DEFINEREG2(PCH_FPA1, i830_debug_fp),
2181 DEFINEREG2(PCH_FPB0, i830_debug_fp),
2182 DEFINEREG2(PCH_FPB1, i830_debug_fp),
2183
2184 DEFINEREG2(TRANS_HTOTAL_A, i830_debug_hvtotal),
2185 DEFINEREG2(TRANS_HBLANK_A, i830_debug_hvsyncblank),
2186 DEFINEREG2(TRANS_HSYNC_A, i830_debug_hvsyncblank),
2187 DEFINEREG2(TRANS_VTOTAL_A, i830_debug_hvtotal),
2188 DEFINEREG2(TRANS_VBLANK_A, i830_debug_hvsyncblank),
2189 DEFINEREG2(TRANS_VSYNC_A, i830_debug_hvsyncblank),
2190 DEFINEREG(TRANS_VSYNCSHIFT_A),
2191
2192 DEFINEREG2(TRANSA_DATA_M1, ironlake_debug_m_tu),
2193 DEFINEREG2(TRANSA_DATA_N1, ironlake_debug_n),
2194 DEFINEREG2(TRANSA_DATA_M2, ironlake_debug_m_tu),
2195 DEFINEREG2(TRANSA_DATA_N2, ironlake_debug_n),
2196 DEFINEREG2(TRANSA_DP_LINK_M1, ironlake_debug_n),
2197 DEFINEREG2(TRANSA_DP_LINK_N1, ironlake_debug_n),
2198 DEFINEREG2(TRANSA_DP_LINK_M2, ironlake_debug_n),
2199 DEFINEREG2(TRANSA_DP_LINK_N2, ironlake_debug_n),
2200
2201 DEFINEREG2(TRANS_HTOTAL_B, i830_debug_hvtotal),
2202 DEFINEREG2(TRANS_HBLANK_B, i830_debug_hvsyncblank),
2203 DEFINEREG2(TRANS_HSYNC_B, i830_debug_hvsyncblank),
2204 DEFINEREG2(TRANS_VTOTAL_B, i830_debug_hvtotal),
2205 DEFINEREG2(TRANS_VBLANK_B, i830_debug_hvsyncblank),
2206 DEFINEREG2(TRANS_VSYNC_B, i830_debug_hvsyncblank),
2207 DEFINEREG(TRANS_VSYNCSHIFT_B),
2208
2209 DEFINEREG2(TRANSB_DATA_M1, ironlake_debug_m_tu),
2210 DEFINEREG2(TRANSB_DATA_N1, ironlake_debug_n),
2211 DEFINEREG2(TRANSB_DATA_M2, ironlake_debug_m_tu),
2212 DEFINEREG2(TRANSB_DATA_N2, ironlake_debug_n),
2213 DEFINEREG2(TRANSB_DP_LINK_M1, ironlake_debug_n),
2214 DEFINEREG2(TRANSB_DP_LINK_N1, ironlake_debug_n),
2215 DEFINEREG2(TRANSB_DP_LINK_M2, ironlake_debug_n),
2216 DEFINEREG2(TRANSB_DP_LINK_N2, ironlake_debug_n),
2217
2218 DEFINEREG2(TRANS_HTOTAL_C, i830_debug_hvtotal),
2219 DEFINEREG2(TRANS_HBLANK_C, i830_debug_hvsyncblank),
2220 DEFINEREG2(TRANS_HSYNC_C, i830_debug_hvsyncblank),
2221 DEFINEREG2(TRANS_VTOTAL_C, i830_debug_hvtotal),
2222 DEFINEREG2(TRANS_VBLANK_C, i830_debug_hvsyncblank),
2223 DEFINEREG2(TRANS_VSYNC_C, i830_debug_hvsyncblank),
2224 DEFINEREG(TRANS_VSYNCSHIFT_C),
2225
2226 DEFINEREG2(TRANSC_DATA_M1, ironlake_debug_m_tu),
2227 DEFINEREG2(TRANSC_DATA_N1, ironlake_debug_n),
2228 DEFINEREG2(TRANSC_DATA_M2, ironlake_debug_m_tu),
2229 DEFINEREG2(TRANSC_DATA_N2, ironlake_debug_n),
2230 DEFINEREG2(TRANSC_DP_LINK_M1, ironlake_debug_n),
2231 DEFINEREG2(TRANSC_DP_LINK_N1, ironlake_debug_n),
2232 DEFINEREG2(TRANSC_DP_LINK_M2, ironlake_debug_n),
2233 DEFINEREG2(TRANSC_DP_LINK_N2, ironlake_debug_n),
2234
2235 DEFINEREG2(TRANSACONF, ironlake_debug_transconf),
2236 DEFINEREG2(TRANSBCONF, ironlake_debug_transconf),
2237 DEFINEREG2(TRANSCCONF, ironlake_debug_transconf),
2238
2239 DEFINEREG2(FDI_TXA_CTL, ironlake_debug_fdi_tx_ctl),
2240 DEFINEREG2(FDI_TXB_CTL, ironlake_debug_fdi_tx_ctl),
2241 DEFINEREG2(FDI_TXC_CTL, ironlake_debug_fdi_tx_ctl),
2242 DEFINEREG2(FDI_RXA_CTL, ironlake_debug_fdi_rx_ctl),
2243 DEFINEREG2(FDI_RXB_CTL, ironlake_debug_fdi_rx_ctl),
2244 DEFINEREG2(FDI_RXC_CTL, ironlake_debug_fdi_rx_ctl),
2245
2246 DEFINEREG(DPAFE_BMFUNC),
2247 DEFINEREG(DPAFE_DL_IREFCAL0),
2248 DEFINEREG(DPAFE_DL_IREFCAL1),
2249 DEFINEREG(DPAFE_DP_IREFCAL),
2250
2251 DEFINEREG(PCH_DSPCLK_GATE_D),
2252 DEFINEREG(PCH_DSP_CHICKEN1),
2253 DEFINEREG(PCH_DSP_CHICKEN2),
2254 DEFINEREG(PCH_DSP_CHICKEN3),
2255
2256 DEFINEREG2(FDI_RXA_MISC, ironlake_debug_fdi_rx_misc),
2257 DEFINEREG2(FDI_RXB_MISC, ironlake_debug_fdi_rx_misc),
2258 DEFINEREG2(FDI_RXC_MISC, ironlake_debug_fdi_rx_misc),
2259 DEFINEREG(FDI_RXA_TUSIZE1),
2260 DEFINEREG(FDI_RXA_TUSIZE2),
2261 DEFINEREG(FDI_RXB_TUSIZE1),
2262 DEFINEREG(FDI_RXB_TUSIZE2),
2263 DEFINEREG(FDI_RXC_TUSIZE1),
2264 DEFINEREG(FDI_RXC_TUSIZE2),
2265
2266 DEFINEREG(FDI_PLL_CTL_1),
2267 DEFINEREG(FDI_PLL_CTL_2),
2268
2269 DEFINEREG(FDI_RXA_IIR),
2270 DEFINEREG(FDI_RXA_IMR),
2271 DEFINEREG(FDI_RXB_IIR),
2272 DEFINEREG(FDI_RXB_IMR),
2273
2274 DEFINEREG2(PCH_ADPA, i830_debug_adpa),
2275 DEFINEREG2(HDMIB, ironlake_debug_hdmi),
2276 DEFINEREG2(HDMIC, ironlake_debug_hdmi),
2277 DEFINEREG2(HDMID, ironlake_debug_hdmi),
2278 DEFINEREG2(PCH_LVDS, i830_debug_lvds),
2279 DEFINEREG(CPU_eDP_A),
2280 DEFINEREG(PCH_DP_B),
2281 DEFINEREG(PCH_DP_C),
2282 DEFINEREG(PCH_DP_D),
2283 DEFINEREG2(TRANS_DP_CTL_A, snb_debug_trans_dp_ctl),
2284 DEFINEREG2(TRANS_DP_CTL_B, snb_debug_trans_dp_ctl),
2285 DEFINEREG2(TRANS_DP_CTL_C, snb_debug_trans_dp_ctl),
2286
2287 DEFINEREG2(BLC_PWM_CPU_CTL2, ilk_debug_blc_pwm_cpu_ctl2),
2288 DEFINEREG2(BLC_PWM_CPU_CTL, ilk_debug_blc_pwm_cpu_ctl),
2289 DEFINEREG2(BLC_PWM_PCH_CTL1, ibx_debug_blc_pwm_ctl1),
2290 DEFINEREG2(BLC_PWM_PCH_CTL2, ibx_debug_blc_pwm_ctl2),
2291
2292 DEFINEREG2(PCH_PP_STATUS, i830_debug_pp_status),
2293 DEFINEREG2(PCH_PP_CONTROL, ilk_debug_pp_control),
2294 DEFINEREG(PCH_PP_ON_DELAYS),
2295 DEFINEREG(PCH_PP_OFF_DELAYS),
2296 DEFINEREG(PCH_PP_DIVISOR),
2297
2298 DEFINEREG2(PORT_DBG, ivb_debug_port),
2299
2300 DEFINEREG(RC6_RESIDENCY_TIME),
2301 DEFINEREG(RC6p_RESIDENCY_TIME),
2302 DEFINEREG(RC6pp_RESIDENCY_TIME),
2303};
2304
2305static const struct reg_debug haswell_debug_regs[] = {
2306 /* Power wells */
2307 DEFINEREG(HSW_PWR_WELL_CTL1),
2308 DEFINEREG(HSW_PWR_WELL_CTL2),
2309 DEFINEREG(HSW_PWR_WELL_CTL3),
2310 DEFINEREG(HSW_PWR_WELL_CTL4),
2311 DEFINEREG(HSW_PWR_WELL_CTL5),
2312 DEFINEREG(HSW_PWR_WELL_CTL6),
2313
2314 /* DDI pipe function */
2315 DEFINEREG2(PIPE_DDI_FUNC_CTL_A, hsw_debug_pipe_ddi_func_ctl),
2316 DEFINEREG2(PIPE_DDI_FUNC_CTL_B, hsw_debug_pipe_ddi_func_ctl),
2317 DEFINEREG2(PIPE_DDI_FUNC_CTL_C, hsw_debug_pipe_ddi_func_ctl),
2318 DEFINEREG2(PIPE_DDI_FUNC_CTL_EDP, hsw_debug_pipe_ddi_func_ctl),
2319
2320 /* DP transport control */
2321 DEFINEREG(DP_TP_CTL_A),
2322 DEFINEREG(DP_TP_CTL_B),
2323 DEFINEREG(DP_TP_CTL_C),
2324 DEFINEREG(DP_TP_CTL_D),
2325 DEFINEREG(DP_TP_CTL_E),
2326
2327 /* DP status */
2328 DEFINEREG(DP_TP_STATUS_B),
2329 DEFINEREG(DP_TP_STATUS_C),
2330 DEFINEREG(DP_TP_STATUS_D),
2331 DEFINEREG(DP_TP_STATUS_E),
2332
2333 /* DDI buffer control */
2334 DEFINEREG2(DDI_BUF_CTL_A, hsw_debug_ddi_buf_ctl),
2335 DEFINEREG2(DDI_BUF_CTL_B, hsw_debug_ddi_buf_ctl),
2336 DEFINEREG2(DDI_BUF_CTL_C, hsw_debug_ddi_buf_ctl),
2337 DEFINEREG2(DDI_BUF_CTL_D, hsw_debug_ddi_buf_ctl),
2338 DEFINEREG2(DDI_BUF_CTL_E, hsw_debug_ddi_buf_ctl),
2339
2340 /* Clocks */
2341 DEFINEREG(SPLL_CTL),
2342 DEFINEREG(LCPLL_CTL),
2343 DEFINEREG(WRPLL_CTL1),
2344 DEFINEREG(WRPLL_CTL2),
2345
2346 /* DDI port clock control */
2347 DEFINEREG2(PORT_CLK_SEL_A, hsw_debug_port_clk_sel),
2348 DEFINEREG2(PORT_CLK_SEL_B, hsw_debug_port_clk_sel),
2349 DEFINEREG2(PORT_CLK_SEL_C, hsw_debug_port_clk_sel),
2350 DEFINEREG2(PORT_CLK_SEL_D, hsw_debug_port_clk_sel),
2351 DEFINEREG2(PORT_CLK_SEL_E, hsw_debug_port_clk_sel),
2352
2353 /* Pipe clock control */
2354 DEFINEREG2(PIPE_CLK_SEL_A, hsw_debug_pipe_clk_sel),
2355 DEFINEREG2(PIPE_CLK_SEL_B, hsw_debug_pipe_clk_sel),
2356 DEFINEREG2(PIPE_CLK_SEL_C, hsw_debug_pipe_clk_sel),
2357
2358 /* Watermarks */
2359 DEFINEREG2(WM_PIPE_A, hsw_debug_wm_pipe),
2360 DEFINEREG2(WM_PIPE_B, hsw_debug_wm_pipe),
2361 DEFINEREG2(WM_PIPE_C, hsw_debug_wm_pipe),
2362 DEFINEREG2(WM_LP1, hsw_debug_lp_wm),
2363 DEFINEREG2(WM_LP2, hsw_debug_lp_wm),
2364 DEFINEREG2(WM_LP3, hsw_debug_lp_wm),
2365 DEFINEREG(WM_LP1_SPR),
2366 DEFINEREG(WM_LP2_SPR),
2367 DEFINEREG(WM_LP3_SPR),
2368 DEFINEREG(WM_MISC),
2369 DEFINEREG(WM_SR_CNT),
2370 DEFINEREG(PIPE_WM_LINETIME_A),
2371 DEFINEREG(PIPE_WM_LINETIME_B),
2372 DEFINEREG(PIPE_WM_LINETIME_C),
2373 DEFINEREG(WM_DBG),
2374
2375 /* Fuses */
2376 DEFINEREG2(SFUSE_STRAP, hsw_debug_sfuse_strap),
2377
2378 /* Pipe A */
2379 DEFINEREG2(PIPEASRC, i830_debug_yxminus1),
2380 DEFINEREG2(DSPACNTR, i830_debug_dspcntr),
2381 DEFINEREG2(DSPASTRIDE, ironlake_debug_dspstride),
2382 DEFINEREG(DSPASURF),
2383 DEFINEREG2(DSPATILEOFF, i830_debug_xy),
2384
2385 /* Pipe B */
2386 DEFINEREG2(PIPEBSRC, i830_debug_yxminus1),
2387 DEFINEREG2(DSPBCNTR, i830_debug_dspcntr),
2388 DEFINEREG2(DSPBSTRIDE, ironlake_debug_dspstride),
2389 DEFINEREG(DSPBSURF),
2390 DEFINEREG2(DSPBTILEOFF, i830_debug_xy),
2391
2392 /* Pipe C */
2393 DEFINEREG2(PIPECSRC, i830_debug_yxminus1),
2394 DEFINEREG2(DSPCCNTR, i830_debug_dspcntr),
2395 DEFINEREG2(DSPCSTRIDE, ironlake_debug_dspstride),
2396 DEFINEREG(DSPCSURF),
2397 DEFINEREG2(DSPCTILEOFF, i830_debug_xy),
2398
2399 /* Transcoder A */
2400 DEFINEREG2(PIPEACONF, i830_debug_pipeconf),
2401 DEFINEREG2(HTOTAL_A, i830_debug_hvtotal),
2402 DEFINEREG2(HBLANK_A, i830_debug_hvsyncblank),
2403 DEFINEREG2(HSYNC_A, i830_debug_hvsyncblank),
2404 DEFINEREG2(VTOTAL_A, i830_debug_hvtotal),
2405 DEFINEREG2(VBLANK_A, i830_debug_hvsyncblank),
2406 DEFINEREG2(VSYNC_A, i830_debug_hvsyncblank),
2407 DEFINEREG(VSYNCSHIFT_A),
2408 DEFINEREG2(PIPEA_DATA_M1, ironlake_debug_m_tu),
2409 DEFINEREG2(PIPEA_DATA_N1, ironlake_debug_n),
2410 DEFINEREG2(PIPEA_LINK_M1, ironlake_debug_n),
2411 DEFINEREG2(PIPEA_LINK_N1, ironlake_debug_n),
2412
2413 /* Transcoder B */
2414 DEFINEREG2(PIPEBCONF, i830_debug_pipeconf),
2415 DEFINEREG2(HTOTAL_B, i830_debug_hvtotal),
2416 DEFINEREG2(HBLANK_B, i830_debug_hvsyncblank),
2417 DEFINEREG2(HSYNC_B, i830_debug_hvsyncblank),
2418 DEFINEREG2(VTOTAL_B, i830_debug_hvtotal),
2419 DEFINEREG2(VBLANK_B, i830_debug_hvsyncblank),
2420 DEFINEREG2(VSYNC_B, i830_debug_hvsyncblank),
2421 DEFINEREG(VSYNCSHIFT_B),
2422 DEFINEREG2(PIPEB_DATA_M1, ironlake_debug_m_tu),
2423 DEFINEREG2(PIPEB_DATA_N1, ironlake_debug_n),
2424 DEFINEREG2(PIPEB_LINK_M1, ironlake_debug_n),
2425 DEFINEREG2(PIPEB_LINK_N1, ironlake_debug_n),
2426
2427 /* Transcoder C */
2428 DEFINEREG2(PIPECCONF, i830_debug_pipeconf),
2429 DEFINEREG2(HTOTAL_C, i830_debug_hvtotal),
2430 DEFINEREG2(HBLANK_C, i830_debug_hvsyncblank),
2431 DEFINEREG2(HSYNC_C, i830_debug_hvsyncblank),
2432 DEFINEREG2(VTOTAL_C, i830_debug_hvtotal),
2433 DEFINEREG2(VBLANK_C, i830_debug_hvsyncblank),
2434 DEFINEREG2(VSYNC_C, i830_debug_hvsyncblank),
2435 DEFINEREG(VSYNCSHIFT_C),
2436 DEFINEREG2(PIPEC_DATA_M1, ironlake_debug_m_tu),
2437 DEFINEREG2(PIPEC_DATA_N1, ironlake_debug_n),
2438 DEFINEREG2(PIPEC_LINK_M1, ironlake_debug_n),
2439 DEFINEREG2(PIPEC_LINK_N1, ironlake_debug_n),
2440
2441 /* Transcoder EDP */
2442 DEFINEREG2(PIPEEDPCONF, i830_debug_pipeconf),
2443 DEFINEREG2(HTOTAL_EDP, i830_debug_hvtotal),
2444 DEFINEREG2(HBLANK_EDP, i830_debug_hvsyncblank),
2445 DEFINEREG2(HSYNC_EDP, i830_debug_hvsyncblank),
2446 DEFINEREG2(VTOTAL_EDP, i830_debug_hvtotal),
2447 DEFINEREG2(VBLANK_EDP, i830_debug_hvsyncblank),
2448 DEFINEREG2(VSYNC_EDP, i830_debug_hvsyncblank),
2449 DEFINEREG(VSYNCSHIFT_EDP),
2450 DEFINEREG2(PIPEEDP_DATA_M1, ironlake_debug_m_tu),
2451 DEFINEREG2(PIPEEDP_DATA_N1, ironlake_debug_n),
2452 DEFINEREG2(PIPEEDP_LINK_M1, ironlake_debug_n),
2453 DEFINEREG2(PIPEEDP_LINK_N1, ironlake_debug_n),
2454
2455 /* Panel fitter */
2456 DEFINEREG2(PFA_CTL_1, ironlake_debug_panel_fitting),
2457 DEFINEREG2(PFA_WIN_POS, ironlake_debug_pf_win),
2458 DEFINEREG2(PFA_WIN_SIZE, ironlake_debug_pf_win),
2459
2460 DEFINEREG2(PFB_CTL_1, ironlake_debug_panel_fitting),
2461 DEFINEREG2(PFB_WIN_POS, ironlake_debug_pf_win),
2462 DEFINEREG2(PFB_WIN_SIZE, ironlake_debug_pf_win),
2463
2464 DEFINEREG2(PFC_CTL_1, ironlake_debug_panel_fitting),
2465 DEFINEREG2(PFC_WIN_POS, ironlake_debug_pf_win),
2466 DEFINEREG2(PFC_WIN_SIZE, ironlake_debug_pf_win),
2467
2468 /* LPT */
2469
2470 DEFINEREG2(TRANS_HTOTAL_A, i830_debug_hvtotal),
2471 DEFINEREG2(TRANS_HBLANK_A, i830_debug_hvsyncblank),
2472 DEFINEREG2(TRANS_HSYNC_A, i830_debug_hvsyncblank),
2473 DEFINEREG2(TRANS_VTOTAL_A, i830_debug_hvtotal),
2474 DEFINEREG2(TRANS_VBLANK_A, i830_debug_hvsyncblank),
2475 DEFINEREG2(TRANS_VSYNC_A, i830_debug_hvsyncblank),
2476 DEFINEREG(TRANS_VSYNCSHIFT_A),
2477
2478 DEFINEREG2(TRANSACONF, ironlake_debug_transconf),
2479
2480 DEFINEREG2(FDI_RXA_MISC, ironlake_debug_fdi_rx_misc),
2481 DEFINEREG(FDI_RXA_TUSIZE1),
2482 DEFINEREG(FDI_RXA_IIR),
2483 DEFINEREG(FDI_RXA_IMR),
2484
2485 DEFINEREG2(BLC_PWM_CPU_CTL2, ilk_debug_blc_pwm_cpu_ctl2),
2486 DEFINEREG2(BLC_PWM_CPU_CTL, ilk_debug_blc_pwm_cpu_ctl),
2487 DEFINEREG2(BLC_PWM2_CPU_CTL2, ilk_debug_blc_pwm_cpu_ctl2),
2488 DEFINEREG2(BLC_PWM2_CPU_CTL, ilk_debug_blc_pwm_cpu_ctl),
2489 DEFINEREG2(BLC_MISC_CTL, hsw_debug_blc_misc_ctl),
2490 DEFINEREG2(BLC_PWM_PCH_CTL1, ibx_debug_blc_pwm_ctl1),
2491 DEFINEREG2(BLC_PWM_PCH_CTL2, ibx_debug_blc_pwm_ctl2),
2492
2493 DEFINEREG2(UTIL_PIN_CTL, hsw_debug_util_pin_ctl),
2494
2495 DEFINEREG2(PCH_PP_STATUS, i830_debug_pp_status),
2496 DEFINEREG2(PCH_PP_CONTROL, ilk_debug_pp_control),
2497 DEFINEREG(PCH_PP_ON_DELAYS),
2498 DEFINEREG(PCH_PP_OFF_DELAYS),
2499 DEFINEREG(PCH_PP_DIVISOR),
2500
2501 DEFINEREG(PIXCLK_GATE),
2502
2503 DEFINEREG2(SDEISR, hsw_debug_sinterrupt),
2504
2505 DEFINEREG(RC6_RESIDENCY_TIME),
2506};
2507
2508static const struct reg_debug i945gm_mi_regs[] = {
2509 DEFINEREG(PGETBL_CTL),
2510 DEFINEREG(PGTBL_ER),
2511 DEFINEREG(EXCC),
2512 DEFINEREG(HWS_PGA),
2513 DEFINEREG(IPEIR),
2514 DEFINEREG(IPEHR),
2515 DEFINEREG(INSTDONE),
2516 DEFINEREG(NOP_ID),
2517 DEFINEREG(HWSTAM),
2518 DEFINEREG(SCPD0),
2519 DEFINEREG(IER),
2520 DEFINEREG(IIR),
2521 DEFINEREG(IMR),
2522 DEFINEREG(ISR),
2523 DEFINEREG(EIR),
2524 DEFINEREG(EMR),
2525 DEFINEREG(ESR),
2526 DEFINEREG(INST_PM),
2527 DEFINEREG(ECOSKPD),
2528};
2529
2530DEBUGSTRING(gen6_rp_control)
2531{
2532 snprintf(result, len, "%s",
2533 (val & (1 << 7)) ? "enabled" : "disabled");
2534}
2535
2536static const struct reg_debug gen6_rp_debug_regs[] = {
2537 DEFINEREG2(GEN6_RP_CONTROL, gen6_rp_control),
2538 DEFINEREG(GEN6_RPNSWREQ),
2539 DEFINEREG(GEN6_RP_DOWN_TIMEOUT),
2540 DEFINEREG(GEN6_RP_INTERRUPT_LIMITS),
2541 DEFINEREG(GEN6_RP_UP_THRESHOLD),
2542 DEFINEREG(GEN6_RP_UP_EI),
2543 DEFINEREG(GEN6_RP_DOWN_EI),
2544 DEFINEREG(GEN6_RP_IDLE_HYSTERSIS),
2545 DEFINEREG(GEN6_RC_STATE),
2546 DEFINEREG(GEN6_RC_CONTROL),
2547 DEFINEREG(GEN6_RC1_WAKE_RATE_LIMIT),
2548 DEFINEREG(GEN6_RC6_WAKE_RATE_LIMIT),
2549 DEFINEREG(GEN6_RC_EVALUATION_INTERVAL),
2550 DEFINEREG(GEN6_RC_IDLE_HYSTERSIS),
2551 DEFINEREG(GEN6_RC_SLEEP),
2552 DEFINEREG(GEN6_RC1e_THRESHOLD),
2553 DEFINEREG(GEN6_RC6_THRESHOLD),
2554 DEFINEREG(GEN6_RC_VIDEO_FREQ),
2555 DEFINEREG(GEN6_PMIER),
2556 DEFINEREG(GEN6_PMIMR),
2557 DEFINEREG(GEN6_PMINTRMSK),
2558};
2559
2560static bool is_hsw_plus(uint32_t devid, uint32_t pch)
2561{
2562 return IS_HASWELL(devid) || intel_gen(devid) >= 8;
2563}
2564
2565static bool is_gen6_plus(uint32_t devid, uint32_t pch)
2566{
2567 return intel_gen(devid) >= 6;
2568}
2569
2570static bool is_gen56ivb(uint32_t devid, uint32_t pch)
2571{
2572 return IS_GEN5(devid) || IS_GEN6(devid) || IS_IVYBRIDGE(devid);
2573}
2574
2575static bool is_945gm(uint32_t devid, uint32_t pch)
2576{
2577 return IS_945GM(devid);
2578}
2579
2580static bool is_gen234(uint32_t devid, uint32_t pch)
2581{
2582 return IS_GEN2(devid) || IS_GEN3(devid) || IS_GEN3(devid);
2583}
2584
2585#define DECLARE_REGS(d,r,m) \
2586 { .description = d, .regs = r, .count = ARRAY_SIZE(r), .match = m }
2587static struct {
2588 const char *description;
2589 const struct reg_debug *regs;
2590 bool (*match)(uint32_t devid, uint32_t pch);
2591 int count;
2592} known_registers[] = {
2593 DECLARE_REGS("Gen2", intel_debug_regs, is_gen234),
2594 DECLARE_REGS("i945GM", i945gm_mi_regs, is_945gm),
2595 DECLARE_REGS("Gen5", ironlake_debug_regs, is_gen56ivb),
2596 DECLARE_REGS("Gen6", gen6_rp_debug_regs, is_gen6_plus),
2597 DECLARE_REGS("Gen6+", gen6_fences, is_gen6_plus),
2598 DECLARE_REGS("Gen7.5", haswell_debug_regs, is_hsw_plus),
2599};
2600#undef DECLARE_REGS
2601
2602/*
2603 * Decode register value into buffer for devid.
2604 *
2605 * If devid is 0, decode for all known platforms, with newline after each
2606 * decode.
2607 */
2608int intel_reg_spec_decode(char *buf, size_t bufsize, const struct reg *reg,
2609 uint32_t val, uint32_t devid)
2610{
2611 char tmp[1024];
2612 int i, j;
2613
2614 if (!bufsize)
2615 return -1;
2616
2617 *buf = 0;
2618
2619 for (i = 0; i < ARRAY_SIZE(known_registers); i++) {
2620 const struct reg_debug *regs = known_registers[i].regs;
2621
2622 if (devid) {
2623 if (known_registers[i].match &&
2624 !known_registers[i].match(devid, 0))
2625 continue;
2626 }
2627
2628 for (j = 0; j < known_registers[i].count; j++) {
2629 const struct reg_debug *r = &regs[j];
2630 if (reg->addr != r->reg)
2631 continue;
2632
2633 if (r->debug_output)
2634 r->debug_output(tmp, sizeof(tmp), r->reg,
2635 val, devid);
2636 else if (devid)
2637 return 0;
2638 else
2639 continue;
2640
2641 if (devid) {
2642 strncpy(buf, tmp, bufsize);
2643 return 0;
2644 }
2645
2646 strncat(buf, known_registers[i].description, bufsize);
2647 strncat(buf, "\t", bufsize);
2648 strncat(buf, tmp, bufsize);
2649 strncat(buf, "\n", bufsize);
2650 }
2651 }
2652
2653 return 0;
2654}
2655
2656static ssize_t get_regs(struct reg **regs, size_t *nregs, ssize_t index,
2657 uint32_t devid)
2658{
2659 ssize_t ret = -1;
2660 int i, j;
2661
2662 if (!devid)
2663 return 0;
2664
2665 for (i = 0; i < ARRAY_SIZE(known_registers); i++) {
2666 if (known_registers[i].match &&
2667 !known_registers[i].match(devid, 0))
2668 continue;
2669
2670 for (j = 0; j < known_registers[i].count; j++) {
2671 const struct reg_debug *reg_in =
2672 &known_registers[i].regs[j];
2673 struct reg reg;
2674
2675 /* XXX: Could be optimized. */
2676 parse_port_desc(&reg, NULL);
2677
2678 reg.name = strdup(reg_in->name);
2679 reg.addr = reg_in->reg;
2680
2681 if (!*regs || index >= *nregs) {
2682 if (!*regs)
2683 *nregs = 64;
2684 else
2685 *nregs *= 2;
2686
2687 *regs = recalloc(*regs, *nregs, sizeof(**regs));
2688 if (!*regs) {
2689 fprintf(stderr, "Error: %s\n", strerror(ENOMEM));
2690 goto out;
2691 }
2692 }
2693
2694 (*regs)[index++] = reg;
2695 }
2696 }
2697
2698 ret = index;
2699
2700out:
2701 return ret;
2702}
2703
2704/*
2705 * Get builtin register definitions for devid.
2706 */
2707ssize_t intel_reg_spec_builtin(struct reg **regs, uint32_t devid)
2708{
2709 size_t nregs = 0;
2710 *regs = NULL;
2711
2712 return get_regs(regs, &nregs, 0, devid);
2713}