tools/intel_reg_dumper: add some cpt/ppt debug regs
[platform/upstream/intel-gpu-tools.git] / lib / intel_reg.h
1 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h,v 1.13 2003/02/06 04:18:04 dawes Exp $ */
2 /**************************************************************************
3
4 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
5 All Rights Reserved.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sub license, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice (including the
16 next paragraph) shall be included in all copies or substantial portions
17 of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
23 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 **************************************************************************/
28
29 /** @file
30  * Register names and fields for Intel graphics.
31  */
32
33 /*
34  * Authors:
35  *   Keith Whitwell <keith@tungstengraphics.com>
36  *   Eric Anholt <eric@anholt.net>
37  *
38  *   based on the i740 driver by
39  *        Kevin E. Martin <kevin@precisioninsight.com> 
40  *   
41  *
42  */
43
44 #ifndef _I810_REG_H
45 #define _I810_REG_H
46
47 /* I/O register offsets
48  */
49 #define SRX 0x3C4               /* p208 */
50 #define GRX 0x3CE               /* p213 */
51 #define ARX 0x3C0               /* p224 */
52
53 /* VGA Color Palette Registers */
54 #define DACMASK  0x3C6          /* p232 */
55 #define DACSTATE 0x3C7          /* p232 */
56 #define DACRX    0x3C7          /* p233 */
57 #define DACWX    0x3C8          /* p233 */
58 #define DACDATA  0x3C9          /* p233 */
59
60 /* CRT Controller Registers (CRX) */
61 #define START_ADDR_HI        0x0C /* p246 */
62 #define START_ADDR_LO        0x0D /* p247 */
63 #define VERT_SYNC_END        0x11 /* p249 */
64 #define EXT_VERT_TOTAL       0x30 /* p257 */
65 #define EXT_VERT_DISPLAY     0x31 /* p258 */
66 #define EXT_VERT_SYNC_START  0x32 /* p259 */
67 #define EXT_VERT_BLANK_START 0x33 /* p260 */
68 #define EXT_HORIZ_TOTAL      0x35 /* p261 */
69 #define EXT_HORIZ_BLANK      0x39 /* p261 */
70 #define EXT_START_ADDR       0x40 /* p262 */
71 #define EXT_START_ADDR_ENABLE    0x80 
72 #define EXT_OFFSET           0x41 /* p263 */
73 #define EXT_START_ADDR_HI    0x42 /* p263 */
74 #define INTERLACE_CNTL       0x70 /* p264 */
75 #define INTERLACE_ENABLE         0x80 
76 #define INTERLACE_DISABLE        0x00 
77
78 /* Miscellaneous Output Register 
79  */
80 #define MSR_R          0x3CC    /* p207 */
81 #define MSR_W          0x3C2    /* p207 */
82 #define IO_ADDR_SELECT     0x01
83
84 #define MDA_BASE       0x3B0    /* p207 */
85 #define CGA_BASE       0x3D0    /* p207 */
86
87 /* CR80 - IO Control, p264
88  */
89 #define IO_CTNL            0x80
90 #define EXTENDED_ATTR_CNTL     0x02
91 #define EXTENDED_CRTC_CNTL     0x01
92
93 /* GR10 - Address mapping, p221
94  */
95 #define ADDRESS_MAPPING    0x10
96 #define PAGE_TO_LOCAL_MEM_ENABLE 0x10
97 #define GTT_MEM_MAP_ENABLE     0x08
98 #define PACKED_MODE_ENABLE     0x04
99 #define LINEAR_MODE_ENABLE     0x02
100 #define PAGE_MAPPING_ENABLE    0x01
101
102 #define HOTKEY_VBIOS_SWITCH_BLOCK       0x80
103 #define HOTKEY_SWITCH                   0x20
104 #define HOTKEY_TOGGLE                   0x10
105
106 /* Blitter control, p378
107  */
108 #define BITBLT_CNTL        0x7000c
109 #define COLEXP_MODE            0x30
110 #define COLEXP_8BPP            0x00
111 #define COLEXP_16BPP           0x10
112 #define COLEXP_24BPP           0x20
113 #define COLEXP_RESERVED        0x30
114 #define BITBLT_STATUS          0x01
115
116 #define CHDECMISC       0x10111
117 #define DCC                     0x10200
118 #define C0DRB0                  0x10200
119 #define C0DRB1                  0x10202
120 #define C0DRB2                  0x10204
121 #define C0DRB3                  0x10206
122 #define C0DRA01                 0x10208
123 #define C0DRA23                 0x1020a
124 #define C1DRB0                  0x10600
125 #define C1DRB1                  0x10602
126 #define C1DRB2                  0x10604
127 #define C1DRB3                  0x10606
128 #define C1DRA01                 0x10608
129 #define C1DRA23                 0x1060a
130
131 /* p375. 
132  */
133 #define DISPLAY_CNTL       0x70008
134 #define VGA_WRAP_MODE          0x02
135 #define VGA_WRAP_AT_256KB      0x00
136 #define VGA_NO_WRAP            0x02
137 #define GUI_MODE               0x01
138 #define STANDARD_VGA_MODE      0x00
139 #define HIRES_MODE             0x01
140
141 /* p375
142  */
143 #define PIXPIPE_CONFIG_0   0x70009
144 #define DAC_8_BIT              0x80
145 #define DAC_6_BIT              0x00
146 #define HW_CURSOR_ENABLE       0x10
147 #define EXTENDED_PALETTE       0x01
148
149 /* p375
150  */
151 #define PIXPIPE_CONFIG_1   0x7000a
152 #define DISPLAY_COLOR_MODE     0x0F
153 #define DISPLAY_VGA_MODE       0x00
154 #define DISPLAY_8BPP_MODE      0x02
155 #define DISPLAY_15BPP_MODE     0x04
156 #define DISPLAY_16BPP_MODE     0x05
157 #define DISPLAY_24BPP_MODE     0x06
158 #define DISPLAY_32BPP_MODE     0x07
159
160 /* p375
161  */
162 #define PIXPIPE_CONFIG_2   0x7000b
163 #define DISPLAY_GAMMA_ENABLE   0x08
164 #define DISPLAY_GAMMA_DISABLE  0x00
165 #define OVERLAY_GAMMA_ENABLE   0x04
166 #define OVERLAY_GAMMA_DISABLE  0x00
167
168
169 /* p380
170  */
171 #define DISPLAY_BASE       0x70020
172 #define DISPLAY_BASE_MASK  0x03fffffc
173
174
175 /* Cursor control registers, pp383-384
176  */
177 /* Desktop (845G, 865G) */
178 #define CURSOR_CONTROL     0x70080
179 #define CURSOR_ENABLE          0x80000000
180 #define CURSOR_GAMMA_ENABLE    0x40000000
181 #define CURSOR_STRIDE_MASK     0x30000000
182 #define CURSOR_FORMAT_SHIFT    24
183 #define CURSOR_FORMAT_MASK     (0x07 << CURSOR_FORMAT_SHIFT)
184 #define CURSOR_FORMAT_2C       (0x00 << CURSOR_FORMAT_SHIFT)
185 #define CURSOR_FORMAT_3C       (0x01 << CURSOR_FORMAT_SHIFT)
186 #define CURSOR_FORMAT_4C       (0x02 << CURSOR_FORMAT_SHIFT)
187 #define CURSOR_FORMAT_ARGB     (0x04 << CURSOR_FORMAT_SHIFT)
188 #define CURSOR_FORMAT_XRGB     (0x05 << CURSOR_FORMAT_SHIFT)
189
190 /* Mobile and i810 */
191 #define CURSOR_A_CONTROL   CURSOR_CONTROL
192 #define CURSOR_ORIGIN_SCREEN   0x00     /* i810 only */
193 #define CURSOR_ORIGIN_DISPLAY  0x1      /* i810 only */
194 #define CURSOR_MODE            0x27
195 #define CURSOR_MODE_DISABLE    0x00
196 #define CURSOR_MODE_32_4C_AX   0x01     /* i810 only */
197 #define CURSOR_MODE_64_3C      0x04
198 #define CURSOR_MODE_64_4C_AX   0x05
199 #define CURSOR_MODE_64_4C      0x06
200 #define CURSOR_MODE_64_32B_AX  0x07
201 #define CURSOR_MODE_64_ARGB_AX (0x20 | CURSOR_MODE_64_32B_AX)
202 #define MCURSOR_PIPE_SELECT    (1 << 28)
203 #define MCURSOR_PIPE_A         0x00
204 #define MCURSOR_PIPE_B         (1 << 28)
205 #define MCURSOR_GAMMA_ENABLE   (1 << 26)
206 #define MCURSOR_MEM_TYPE_LOCAL (1 << 25)
207
208
209 #define CURSOR_BASEADDR    0x70084
210 #define CURSOR_A_BASE      CURSOR_BASEADDR
211 #define CURSOR_BASEADDR_MASK 0x1FFFFF00
212 #define CURSOR_A_POSITION  0x70088
213 #define CURSOR_POS_SIGN        0x8000
214 #define CURSOR_POS_MASK        0x007FF
215 #define CURSOR_X_SHIFT         0
216 #define CURSOR_Y_SHIFT         16
217 #define CURSOR_X_LO        0x70088
218 #define CURSOR_X_HI        0x70089
219 #define CURSOR_X_POS           0x00
220 #define CURSOR_X_NEG           0x80
221 #define CURSOR_Y_LO        0x7008A
222 #define CURSOR_Y_HI        0x7008B
223 #define CURSOR_Y_POS           0x00
224 #define CURSOR_Y_NEG           0x80
225
226 #define CURSOR_A_PALETTE0  0x70090
227 #define CURSOR_A_PALETTE1  0x70094
228 #define CURSOR_A_PALETTE2  0x70098
229 #define CURSOR_A_PALETTE3  0x7009C
230
231 #define CURSOR_SIZE        0x700A0
232 #define CURSOR_SIZE_MASK       0x3FF
233 #define CURSOR_SIZE_HSHIFT     0
234 #define CURSOR_SIZE_VSHIFT     12
235
236 #define CURSOR_B_CONTROL   0x700C0
237 #define CURSOR_B_BASE      0x700C4
238 #define CURSOR_B_POSITION  0x700C8
239 #define CURSOR_B_PALETTE0  0x700D0
240 #define CURSOR_B_PALETTE1  0x700D4
241 #define CURSOR_B_PALETTE2  0x700D8
242 #define CURSOR_B_PALETTE3  0x700DC
243
244
245 /* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm
246  * not sure they refer to local (graphics) memory.
247  *
248  * These details are for the local memory control registers,
249  * (pp301-310).  The test machines are not equiped with local memory,
250  * so nothing is tested.  Only a single row seems to be supported.
251  */
252 #define DRAM_ROW_TYPE      0x3000
253 #define DRAM_ROW_0             0x01
254 #define DRAM_ROW_0_SDRAM       0x01
255 #define DRAM_ROW_0_EMPTY       0x00
256 #define DRAM_ROW_CNTL_LO   0x3001
257 #define DRAM_PAGE_MODE_CTRL    0x10
258 #define DRAM_RAS_TO_CAS_OVRIDE 0x08
259 #define DRAM_CAS_LATENCY       0x04
260 #define DRAM_RAS_TIMING        0x02
261 #define DRAM_RAS_PRECHARGE     0x01
262 #define DRAM_ROW_CNTL_HI   0x3002
263 #define DRAM_REFRESH_RATE      0x18
264 #define DRAM_REFRESH_DISABLE   0x00
265 #define DRAM_REFRESH_60HZ      0x08
266 #define DRAM_REFRESH_FAST_TEST 0x10
267 #define DRAM_REFRESH_RESERVED  0x18
268 #define DRAM_SMS               0x07
269 #define DRAM_SMS_NORMAL        0x00
270 #define DRAM_SMS_NOP_ENABLE    0x01
271 #define DRAM_SMS_ABPCE         0x02
272 #define DRAM_SMS_MRCE          0x03
273 #define DRAM_SMS_CBRCE         0x04
274
275 /* p307
276  */
277 #define DPMS_SYNC_SELECT   0x5002
278 #define VSYNC_CNTL             0x08
279 #define VSYNC_ON               0x00
280 #define VSYNC_OFF              0x08
281 #define HSYNC_CNTL             0x02
282 #define HSYNC_ON               0x00
283 #define HSYNC_OFF              0x02
284
285 #define GPIOA                   0x5010
286 #define GPIOB                   0x5014
287 #define GPIOC                   0x5018
288 #define GPIOD                   0x501c
289 #define GPIOE                   0x5020
290 #define GPIOF                   0x5024
291 #define GPIOG                   0x5028
292 #define GPIOH                   0x502c
293 # define GPIO_CLOCK_DIR_MASK            (1 << 0)
294 # define GPIO_CLOCK_DIR_IN              (0 << 1)
295 # define GPIO_CLOCK_DIR_OUT             (1 << 1)
296 # define GPIO_CLOCK_VAL_MASK            (1 << 2)
297 # define GPIO_CLOCK_VAL_OUT             (1 << 3)
298 # define GPIO_CLOCK_VAL_IN              (1 << 4)
299 # define GPIO_CLOCK_PULLUP_DISABLE      (1 << 5)
300 # define GPIO_DATA_DIR_MASK             (1 << 8)
301 # define GPIO_DATA_DIR_IN               (0 << 9)
302 # define GPIO_DATA_DIR_OUT              (1 << 9)
303 # define GPIO_DATA_VAL_MASK             (1 << 10)
304 # define GPIO_DATA_VAL_OUT              (1 << 11)
305 # define GPIO_DATA_VAL_IN               (1 << 12)
306 # define GPIO_DATA_PULLUP_DISABLE       (1 << 13)
307
308 /* GMBus registers for hardware-assisted (non-bitbanging) I2C access */
309 #define GMBUS0                  0x5100
310 #define GMBUS1                  0x5104
311 #define GMBUS2                  0x5108
312 #define GMBUS3                  0x510c
313 #define GMBUS4                  0x5110
314 #define GMBUS5                  0x5120
315
316 /* p317, 319
317  */
318 #define VCLK2_VCO_M        0x6008 /* treat as 16 bit? (includes msbs) */
319 #define VCLK2_VCO_N        0x600a
320 #define VCLK2_VCO_DIV_SEL  0x6012
321
322 #define VCLK_DIVISOR_VGA0   0x6000
323 #define VCLK_DIVISOR_VGA1   0x6004
324 #define VCLK_POST_DIV       0x6010
325 /** Selects a post divisor of 4 instead of 2. */
326 # define VGA1_PD_P2_DIV_4       (1 << 15)
327 /** Overrides the p2 post divisor field */
328 # define VGA1_PD_P1_DIV_2       (1 << 13)
329 # define VGA1_PD_P1_SHIFT       8
330 /** P1 value is 2 greater than this field */
331 # define VGA1_PD_P1_MASK        (0x1f << 8)
332 /** Selects a post divisor of 4 instead of 2. */
333 # define VGA0_PD_P2_DIV_4       (1 << 7)
334 /** Overrides the p2 post divisor field */
335 # define VGA0_PD_P1_DIV_2       (1 << 5)
336 # define VGA0_PD_P1_SHIFT       0
337 /** P1 value is 2 greater than this field */
338 # define VGA0_PD_P1_MASK        (0x1f << 0)
339
340 #define POST_DIV_SELECT        0x70
341 #define POST_DIV_1             0x00
342 #define POST_DIV_2             0x10
343 #define POST_DIV_4             0x20
344 #define POST_DIV_8             0x30
345 #define POST_DIV_16            0x40
346 #define POST_DIV_32            0x50
347 #define VCO_LOOP_DIV_BY_4M     0x00
348 #define VCO_LOOP_DIV_BY_16M    0x04
349
350
351 /* Instruction Parser Mode Register 
352  *    - p281
353  *    - 2 new bits.
354  */
355 #define INST_PM                  0x20c0 
356 #define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */
357 #define SYNC_PACKET_FLUSH_ENABLE     0x10
358 #define TWO_D_INST_DISABLE           0x08
359 #define THREE_D_INST_DISABLE         0x04
360 #define STATE_VAR_UPDATE_DISABLE     0x02
361 #define PAL_STIP_DISABLE             0x01
362 #define GEN6_GLOBAL_DEBUG_ENABLE     0x10
363
364
365 #define MEMMODE                  0x20dc
366
367
368 /* Instruction parser error register.  p279
369  */
370 #define IPEIR                  0x2088
371 #define IPEHR                  0x208C
372
373 #define INST_DONE                0x2090
374 # define IDCT_DONE                      (1 << 30)
375 # define IQ_DONE                        (1 << 29)
376 # define PR_DONE                        (1 << 28)
377 # define VLD_DONE                       (1 << 27)
378 # define IP_DONE                        (1 << 26)
379 # define FBC_DONE                       (1 << 25)
380 # define BINNER_DONE                    (1 << 24)
381 # define SF_DONE                        (1 << 23)
382 # define SE_DONE                        (1 << 22)
383 # define WM_DONE                        (1 << 21)
384 # define IZ_DONE                        (1 << 20)
385 # define PERSPECTIVE_INTERP_DONE        (1 << 19)
386 # define DISPATCHER_DONE                (1 << 18)
387 # define PROJECTION_DONE                (1 << 17)
388 # define DEPENDENT_ADDRESS_DONE         (1 << 16)
389 # define QUAD_CACHE_DONE                (1 << 15)
390 # define TEXTURE_FETCH_DONE             (1 << 14)
391 # define TEXTURE_DECOMPRESS_DONE        (1 << 13)
392 # define SAMPLER_CACHE_DONE             (1 << 12)
393 # define FILTER_DONE                    (1 << 11)
394 # define BYPASS_FIFO_DONE               (1 << 10)
395 # define PS_DONE                        (1 << 9)
396 # define CC_DONE                        (1 << 8)
397 # define MAP_FILTER_DONE                (1 << 7)
398 # define MAP_L2_IDLE                    (1 << 6)
399 # define RING_2_ENABLE                  (1 << 2)
400 # define RING_1_ENABLE                  (1 << 1)
401 # define RING_0_ENABLE                  (1 << 0)
402
403 # define I830_GMBUS_DONE                (1 << 26)
404 # define I830_FBC_DONE                  (1 << 25)
405 # define I830_BINNER_DONE               (1 << 24)
406 # define I830_MPEG_DONE                 (1 << 23)
407 # define I830_MECO_DONE                 (1 << 22)
408 # define I830_MCD_DONE                  (1 << 21)
409 # define I830_MCSTP_DONE                (1 << 20)
410 # define I830_CC_DONE                   (1 << 19)
411 # define I830_DG_DONE                   (1 << 18)
412 # define I830_DCMP_DONE                 (1 << 17)
413 # define I830_FTCH_DONE                 (1 << 16)
414 # define I830_IT_DONE                   (1 << 15)
415 # define I830_MG_DONE                   (1 << 14)
416 # define I830_MEC_DONE                  (1 << 13)
417 # define I830_PC_DONE                   (1 << 12)
418 # define I830_QCC_DONE                  (1 << 11)
419 # define I830_TB_DONE                   (1 << 10)
420 # define I830_WM_DONE                   (1 << 9)
421 # define I830_EF_DONE                   (1 << 8)
422 # define I830_BLITTER_DONE              (1 << 7)
423 # define I830_MAP_L2_DONE               (1 << 6)
424 # define I830_SECONDARY_RING_3_DONE     (1 << 5)
425 # define I830_SECONDARY_RING_2_DONE     (1 << 4)
426 # define I830_SECONDARY_RING_1_DONE     (1 << 3)
427 # define I830_SECONDARY_RING_0_DONE     (1 << 2)
428 # define I830_PRIMARY_RING_1_DONE       (1 << 1)
429 # define I830_PRIMARY_RING_0_DONE       (1 << 0)
430
431 #define NOP_ID                   0x2094
432
433 #define SCPD0                    0x209c /* debug */
434 #define INST_PS                  0x20c4
435 #define IPEIR_I965                  0x2064 /* i965 */
436 #define IPEHR_I965                  0x2068 /* i965 */
437 #define INST_DONE_I965              0x206c
438 # define I965_ROW_0_EU_0_DONE           (1 << 31)
439 # define I965_ROW_0_EU_1_DONE           (1 << 30)
440 # define I965_ROW_0_EU_2_DONE           (1 << 29)
441 # define I965_ROW_0_EU_3_DONE           (1 << 28)
442 # define I965_ROW_1_EU_0_DONE           (1 << 27)
443 # define I965_ROW_1_EU_1_DONE           (1 << 26)
444 # define I965_ROW_1_EU_2_DONE           (1 << 25)
445 # define I965_ROW_1_EU_3_DONE           (1 << 24)
446 # define I965_SF_DONE                   (1 << 23)
447 # define I965_SE_DONE                   (1 << 22)
448 # define I965_WM_DONE                   (1 << 21)
449 # define I965_DISPATCHER_DONE           (1 << 18)
450 # define I965_PROJECTION_DONE           (1 << 17)
451 # define I965_DG_DONE                   (1 << 16)
452 # define I965_QUAD_CACHE_DONE           (1 << 15)
453 # define I965_TEXTURE_FETCH_DONE        (1 << 14)
454 # define I965_TEXTURE_DECOMPRESS_DONE   (1 << 13)
455 # define I965_SAMPLER_CACHE_DONE        (1 << 12)
456 # define I965_FILTER_DONE               (1 << 11)
457 # define I965_BYPASS_DONE               (1 << 10)
458 # define I965_PS_DONE                   (1 << 9)
459 # define I965_CC_DONE                   (1 << 8)
460 # define I965_MAP_FILTER_DONE           (1 << 7)
461 # define I965_MAP_L2_IDLE               (1 << 6)
462 # define I965_MA_ROW_0_DONE             (1 << 5)
463 # define I965_MA_ROW_1_DONE             (1 << 4)
464 # define I965_IC_ROW_0_DONE             (1 << 3)
465 # define I965_IC_ROW_1_DONE             (1 << 2)
466 # define I965_CP_DONE                   (1 << 1)
467 # define I965_RING_0_ENABLE             (1 << 0)
468
469 # define ILK_ROW_0_EU_0_DONE            (1 << 31)
470 # define ILK_ROW_0_EU_1_DONE            (1 << 30)
471 # define ILK_ROW_0_EU_2_DONE            (1 << 29)
472 # define ILK_ROW_0_EU_3_DONE            (1 << 28)
473 # define ILK_ROW_1_EU_0_DONE            (1 << 27)
474 # define ILK_ROW_1_EU_1_DONE            (1 << 26)
475 # define ILK_ROW_1_EU_2_DONE            (1 << 25)
476 # define ILK_ROW_1_EU_3_DONE            (1 << 24)
477 # define ILK_ROW_2_EU_0_DONE            (1 << 23)
478 # define ILK_ROW_2_EU_1_DONE            (1 << 22)
479 # define ILK_ROW_2_EU_2_DONE            (1 << 21)
480 # define ILK_ROW_2_EU_3_DONE            (1 << 20)
481 # define ILK_VCP_DONE                   (1 << 19)
482 # define ILK_ROW_0_MATH_DONE            (1 << 18)
483 # define ILK_ROW_1_MATH_DONE            (1 << 17)
484 # define ILK_ROW_2_MATH_DONE            (1 << 16)
485 # define ILK_VC1_DONE                   (1 << 15)
486 # define ILK_ROW_0_MA_DONE              (1 << 14)
487 # define ILK_ROW_1_MA_DONE              (1 << 13)
488 # define ILK_ROW_2_MA_DONE              (1 << 12)
489 # define ILK_ROW_0_ISC_DONE             (1 << 11)
490 # define ILK_ROW_1_ISC_DONE             (1 << 10)
491 # define ILK_ROW_2_ISC_DONE             (1 << 9)
492 # define ILK_VFE_DONE                   (1 << 8)
493 # define ILK_TD_DONE                    (1 << 7)
494 # define ILK_SVTS_DONE                  (1 << 6)
495 # define ILK_TS_DONE                    (1 << 5)
496 # define ILK_GW_DONE                    (1 << 4)
497 # define ILK_AI_DONE                    (1 << 3)
498 # define ILK_AC_DONE                    (1 << 2)
499 # define ILK_AM_DONE                    (1 << 1)
500
501 #define GEN6_INSTDONE_1         0x206c
502 # define GEN6_MA_3_DONE                 (1 << 31)
503 # define GEN6_EU_32_DONE                (1 << 30)
504 # define GEN6_EU_31_DONE                (1 << 29)
505 # define GEN6_EU_30_DONE                (1 << 28)
506 # define GEN6_MA_2_DONE                 (1 << 27)
507 # define GEN6_EU_22_DONE                (1 << 26)
508 # define GEN6_EU_21_DONE                (1 << 25)
509 # define GEN6_EU_20_DONE                (1 << 24)
510 # define GEN6_MA_1_DONE                 (1 << 23)
511 # define GEN6_EU_12_DONE                (1 << 22)
512 # define GEN6_EU_11_DONE                (1 << 21)
513 # define GEN6_EU_10_DONE                (1 << 20)
514 # define GEN6_MA_0_DONE                 (1 << 19)
515 # define GEN6_EU_02_DONE                (1 << 18)
516 # define GEN6_EU_01_DONE                (1 << 17)
517 # define GEN6_EU_00_DONE                (1 << 16)
518 # define GEN6_IC_3_DONE                 (1 << 15)
519 # define GEN6_IC_2_DONE                 (1 << 14)
520 # define GEN6_IC_1_DONE                 (1 << 13)
521 # define GEN6_IC_0_DONE                 (1 << 12)
522 # define GEN6_ISC_10_DONE               (1 << 11)
523 # define GEN6_ISC_32_DONE               (1 << 10)
524 # define GEN6_VSC_DONE                  (1 << 9)
525 # define GEN6_IEF_DONE                  (1 << 8)
526 # define GEN6_VFE_DONE                  (1 << 7)
527 # define GEN6_TD_DONE                   (1 << 6)
528 # define GEN6_TS_DONE                   (1 << 4)
529 # define GEN6_GW_DONE                   (1 << 3)
530 # define GEN6_HIZ_DONE                  (1 << 2)
531 # define GEN6_AVS_DONE                  (1 << 1)
532
533 #define INST_PS_I965                0x2070
534
535 /* Current active ring head address: 
536  */
537 #define ACTHD_I965                 0x2074
538 #define ACTHD                      0x20C8
539
540 /* Current primary/secondary DMA fetch addresses:
541  */
542 #define DMA_FADD_P             0x2078
543 #define DMA_FADD_S               0x20d4
544 #define INST_DONE_1              0x207c
545 # define I965_GW_CS_DONE_CR             (1 << 19)
546 # define I965_SVSM_CS_DONE_CR           (1 << 18)
547 # define I965_SVDW_CS_DONE_CR           (1 << 17)
548 # define I965_SVDR_CS_DONE_CR           (1 << 16)
549 # define I965_SVRW_CS_DONE_CR           (1 << 15)
550 # define I965_SVRR_CS_DONE_CR           (1 << 14)
551 # define I965_SVTW_CS_DONE_CR           (1 << 13)
552 # define I965_MASM_CS_DONE_CR           (1 << 12)
553 # define I965_MASF_CS_DONE_CR           (1 << 11)
554 # define I965_MAW_CS_DONE_CR            (1 << 10)
555 # define I965_EM1_CS_DONE_CR            (1 << 9)
556 # define I965_EM0_CS_DONE_CR            (1 << 8)
557 # define I965_UC1_CS_DONE               (1 << 7)
558 # define I965_UC0_CS_DONE               (1 << 6)
559 # define I965_URB_CS_DONE               (1 << 5)
560 # define I965_ISC_CS_DONE               (1 << 4)
561 # define I965_CL_CS_DONE                (1 << 3)
562 # define I965_GS_CS_DONE                (1 << 2)
563 # define I965_VS0_CS_DONE               (1 << 1)
564 # define I965_VF_CS_DONE                (1 << 0)
565
566 # define G4X_BCS_DONE                   (1 << 31)
567 # define G4X_CS_DONE                    (1 << 30)
568 # define G4X_MASF_DONE                  (1 << 29)
569 # define G4X_SVDW_DONE                  (1 << 28)
570 # define G4X_SVDR_DONE                  (1 << 27)
571 # define G4X_SVRW_DONE                  (1 << 26)
572 # define G4X_SVRR_DONE                  (1 << 25)
573 # define G4X_ISC_DONE                   (1 << 24)
574 # define G4X_MT_DONE                    (1 << 23)
575 # define G4X_RC_DONE                    (1 << 22)
576 # define G4X_DAP_DONE                   (1 << 21)
577 # define G4X_MAWB_DONE                  (1 << 20)
578 # define G4X_MT_IDLE                    (1 << 19)
579 # define G4X_GBLT_BUSY                  (1 << 18)
580 # define G4X_SVSM_DONE                  (1 << 17)
581 # define G4X_MASM_DONE                  (1 << 16)
582 # define G4X_QC_DONE                    (1 << 15)
583 # define G4X_FL_DONE                    (1 << 14)
584 # define G4X_SC_DONE                    (1 << 13)
585 # define G4X_DM_DONE                    (1 << 12)
586 # define G4X_FT_DONE                    (1 << 11)
587 # define G4X_DG_DONE                    (1 << 10)
588 # define G4X_SI_DONE                    (1 << 9)
589 # define G4X_SO_DONE                    (1 << 8)
590 # define G4X_PL_DONE                    (1 << 7)
591 # define G4X_WIZ_DONE                   (1 << 6)
592 # define G4X_URB_DONE                   (1 << 5)
593 # define G4X_SF_DONE                    (1 << 4)
594 # define G4X_CL_DONE                    (1 << 3)
595 # define G4X_GS_DONE                    (1 << 2)
596 # define G4X_VS0_DONE                   (1 << 1)
597 # define G4X_VF_DONE                    (1 << 0)
598
599 #define GEN6_INSTDONE_2         0x207c
600 # define GEN6_GAM_DONE                  (1 << 31)
601 # define GEN6_CS_DONE                   (1 << 30)
602 # define GEN6_WMBE_DONE                 (1 << 29)
603 # define GEN6_SVRW_DONE                 (1 << 28)
604 # define GEN6_RCC_DONE                  (1 << 27)
605 # define GEN6_SVG_DONE                  (1 << 26)
606 # define GEN6_ISC_DONE                  (1 << 25)
607 # define GEN6_MT_DONE                   (1 << 24)
608 # define GEN6_RCPFE_DONE                (1 << 23)
609 # define GEN6_RCPBE_DONE                (1 << 22)
610 # define GEN6_VDI_DONE                  (1 << 21)
611 # define GEN6_RCZ_DONE                  (1 << 20)
612 # define GEN6_DAP_DONE                  (1 << 19)
613 # define GEN6_PSD_DONE                  (1 << 18)
614 # define GEN6_IZ_DONE                   (1 << 17)
615 # define GEN6_WMFE_DONE                 (1 << 16)
616 # define GEN6_SVSM_DONE                 (1 << 15)
617 # define GEN6_QC_DONE                   (1 << 14)
618 # define GEN6_FL_DONE                   (1 << 13)
619 # define GEN6_SC_DONE                   (1 << 12)
620 # define GEN6_DM_DONE                   (1 << 11)
621 # define GEN6_FT_DONE                   (1 << 10)
622 # define GEN6_DG_DONE                   (1 << 9)
623 # define GEN6_SI_DONE                   (1 << 8)
624 # define GEN6_SO_DONE                   (1 << 7)
625 # define GEN6_PL_DONE                   (1 << 6)
626 # define GEN6_VME_DONE                  (1 << 5)
627 # define GEN6_SF_DONE                   (1 << 4)
628 # define GEN6_CL_DONE                   (1 << 3)
629 # define GEN6_GS_DONE                   (1 << 2)
630 # define GEN6_VS0_DONE                  (1 << 1)
631 # define GEN6_VF_DONE                   (1 << 0)
632
633 #define CACHE_MODE_0           0x2120
634 #define CACHE_MODE_1           0x2124
635 #define MI_MODE                0x209c
636 #define MI_DISPLAY_POWER_DOWN  0x20e0
637 #define MI_ARB_STATE           0x20e4
638 #define MI_RDRET_STATE         0x20fc
639
640 /* Start addresses for each of the primary rings:
641  */
642 #define PR0_STR                  0x20f0
643 #define PR1_STR                  0x20f4
644 #define PR2_STR                  0x20f8
645
646 #define WIZ_CTL                0x7c00
647 #define WIZ_CTL_SINGLE_SUBSPAN  (1<<6)
648 #define WIZ_CTL_IGNORE_STALLS  (1<<5)
649
650 #define SVG_WORK_CTL           0x7408
651
652 #define TS_CTL                 0x7e00
653 #define TS_MUX_ERR_CODE        (0<<8)
654 #define TS_MUX_URB_0           (1<<8)
655 #define TS_MUX_DISPATCH_ID_0   (10<<8)
656 #define TS_MUX_ERR_CODE_VALID  (15<<8)
657 #define TS_MUX_TID_0           (16<<8)
658 #define TS_MUX_EUID_0          (18<<8)
659 #define TS_MUX_FFID_0          (22<<8)
660 #define TS_MUX_EOT             (26<<8)
661 #define TS_MUX_SIDEBAND_0      (27<<8)
662 #define TS_SNAP_ALL_CHILD      (1<<2)
663 #define TS_SNAP_ALL_ROOT       (1<<1)
664 #define TS_SNAP_ENABLE         (1<<0)
665
666 #define TS_DEBUG_DATA          0x7e0c
667
668 #define TD_CTL                 0x8000
669 #define TD_CTL2                0x8004
670
671
672 #define ECOSKPD 0x21d0
673 #define EXCC    0x2028
674
675 /* I965 debug regs:
676  */
677 #define IA_VERTICES_COUNT_QW   0x2310
678 #define IA_PRIMITIVES_COUNT_QW 0x2318
679 #define VS_INVOCATION_COUNT_QW 0x2320
680 #define GS_INVOCATION_COUNT_QW 0x2328
681 #define GS_PRIMITIVES_COUNT_QW 0x2330
682 #define CL_INVOCATION_COUNT_QW 0x2338
683 #define CL_PRIMITIVES_COUNT_QW 0x2340
684 #define PS_INVOCATION_COUNT_QW 0x2348
685 #define PS_DEPTH_COUNT_QW      0x2350
686 #define TIMESTAMP_QW           0x2358
687 #define CLKCMP_QW              0x2360
688
689
690
691
692
693
694 /* General error reporting regs, p296
695  */
696 #define EIR               0x20B0
697 #define EMR               0x20B4
698 #define ESR               0x20B8
699 # define ERR_VERTEX_MAX                         (1 << 5) /* lpt/cst */
700 # define ERR_PGTBL_ERROR                        (1 << 4)
701 # define ERR_DISPLAY_OVERLAY_UNDERRUN           (1 << 3)
702 # define ERR_MAIN_MEMORY_REFRESH                (1 << 1)
703 # define ERR_INSTRUCTION_ERROR                  (1 << 0)
704
705
706 /* Interrupt Control Registers 
707  *   - new bits for i810
708  *   - new register hwstam (mask)
709  */
710 #define HWS_PGA              0x2080
711 #define PWRCTXA              0x2088 /* 965GM+ only */
712 #define   PWRCTX_EN          (1<<0)
713 #define HWSTAM               0x2098 /* p290 */
714 #define IER                  0x20a0 /* p291 */
715 #define IIR                  0x20a4 /* p292 */
716 #define IMR                  0x20a8 /* p293 */
717 #define ISR                  0x20ac /* p294 */
718 #define HW_ERROR                 0x8000
719 #define SYNC_STATUS_TOGGLE       0x1000
720 #define DPY_0_FLIP_PENDING       0x0800
721 #define DPY_1_FLIP_PENDING       0x0400 /* not implemented on i810 */
722 #define OVL_0_FLIP_PENDING       0x0200
723 #define OVL_1_FLIP_PENDING       0x0100 /* not implemented on i810 */
724 #define DPY_0_VBLANK             0x0080
725 #define DPY_0_EVENT              0x0040
726 #define DPY_1_VBLANK             0x0020 /* not implemented on i810 */
727 #define DPY_1_EVENT              0x0010 /* not implemented on i810 */
728 #define HOST_PORT_EVENT          0x0008 /*  */
729 #define CAPTURE_EVENT            0x0004 /*  */
730 #define USER_DEFINED             0x0002
731 #define BREAKPOINT               0x0001
732
733
734 #define INTR_RESERVED            (0x6000 |              \
735                                   DPY_1_FLIP_PENDING |  \
736                                   OVL_1_FLIP_PENDING |  \
737                                   DPY_1_VBLANK |        \
738                                   DPY_1_EVENT |         \
739                                   HOST_PORT_EVENT |     \
740                                   CAPTURE_EVENT )
741
742 /* FIFO Watermark and Burst Length Control Register 
743  *
744  * - different offset and contents on i810 (p299) (fewer bits per field)
745  * - some overlay fields added
746  * - what does it all mean?
747  */
748 #define FWATER_BLC       0x20d8
749 #define FWATER_BLC2      0x20dc
750 #define MM_BURST_LENGTH     0x00700000
751 #define MM_FIFO_WATERMARK   0x0001F000
752 #define LM_BURST_LENGTH     0x00000700
753 #define LM_FIFO_WATERMARK   0x0000001F
754
755
756 /* Fence/Tiling ranges [0..7]
757  */
758 #define FENCE            0x2000
759 #define FENCE_NR         8
760
761 #define FENCE_NEW        0x3000
762 #define FENCE_NEW_NR     16
763
764 #define FENCE_LINEAR     0
765 #define FENCE_XMAJOR     1
766 #define FENCE_YMAJOR     2
767
768 #define I915G_FENCE_START_MASK  0x0ff00000
769
770 #define I830_FENCE_START_MASK   0x07f80000
771
772 #define FENCE_START_MASK    0x03F80000
773 #define FENCE_X_MAJOR       0x00000000
774 #define FENCE_Y_MAJOR       0x00001000
775 #define FENCE_SIZE_MASK     0x00000700
776 #define FENCE_SIZE_512K     0x00000000
777 #define FENCE_SIZE_1M       0x00000100
778 #define FENCE_SIZE_2M       0x00000200
779 #define FENCE_SIZE_4M       0x00000300
780 #define FENCE_SIZE_8M       0x00000400
781 #define FENCE_SIZE_16M      0x00000500
782 #define FENCE_SIZE_32M      0x00000600
783 #define FENCE_SIZE_64M      0x00000700
784 #define I915G_FENCE_SIZE_1M       0x00000000
785 #define I915G_FENCE_SIZE_2M       0x00000100
786 #define I915G_FENCE_SIZE_4M       0x00000200
787 #define I915G_FENCE_SIZE_8M       0x00000300
788 #define I915G_FENCE_SIZE_16M      0x00000400
789 #define I915G_FENCE_SIZE_32M      0x00000500
790 #define I915G_FENCE_SIZE_64M    0x00000600
791 #define I915G_FENCE_SIZE_128M   0x00000700
792 #define I965_FENCE_X_MAJOR      0x00000000
793 #define I965_FENCE_Y_MAJOR      0x00000002
794 #define FENCE_PITCH_1       0x00000000
795 #define FENCE_PITCH_2       0x00000010
796 #define FENCE_PITCH_4       0x00000020
797 #define FENCE_PITCH_8       0x00000030
798 #define FENCE_PITCH_16      0x00000040
799 #define FENCE_PITCH_32      0x00000050
800 #define FENCE_PITCH_64      0x00000060
801 #define FENCE_VALID         0x00000001
802
803
804 /* Registers to control page table, p274
805  */
806 #define PGETBL_CTL       0x2020
807 #define PGETBL_ADDR_MASK    0xFFFFF000
808 #define PGETBL_ENABLE_MASK  0x00000001
809 #define PGETBL_ENABLED      0x00000001
810 /** Added in 965G, this field has the actual size of the global GTT */
811 #define PGETBL_SIZE_MASK    0x0000000e
812 #define PGETBL_SIZE_512KB   (0 << 1)
813 #define PGETBL_SIZE_256KB   (1 << 1)
814 #define PGETBL_SIZE_128KB   (2 << 1)
815 #define PGETBL_SIZE_1MB     (3 << 1)
816 #define PGETBL_SIZE_2MB     (4 << 1)
817 #define PGETBL_SIZE_1_5MB   (5 << 1)
818 #define G33_PGETBL_SIZE_MASK            (3 << 8)
819 #define G33_PGETBL_SIZE_1M              (1 << 8)
820 #define G33_PGETBL_SIZE_2M              (2 << 8)
821
822 #define I830_PTE_BASE                   0x10000
823 #define PTE_ADDRESS_MASK                0xfffff000
824 #define PTE_ADDRESS_MASK_HIGH           0x000000f0 /* i915+ */
825 #define PTE_MAPPING_TYPE_UNCACHED       (0 << 1)
826 #define PTE_MAPPING_TYPE_DCACHE         (1 << 1) /* i830 only */
827 #define PTE_MAPPING_TYPE_CACHED         (3 << 1)
828 #define PTE_MAPPING_TYPE_MASK           (3 << 1)
829 #define PTE_VALID                       (1 << 0)
830
831 /** @defgroup PGE_ERR
832  * @{
833  */
834 /** Page table debug register for i845 */
835 #define PGE_ERR          0x2024
836 #define PGE_ERR_ADDR_MASK   0xFFFFF000
837 #define PGE_ERR_ID_MASK     0x00000038
838 #define PGE_ERR_CAPTURE     0x00000000
839 #define PGE_ERR_OVERLAY     0x00000008
840 #define PGE_ERR_DISPLAY     0x00000010
841 #define PGE_ERR_HOST        0x00000018
842 #define PGE_ERR_RENDER      0x00000020
843 #define PGE_ERR_BLITTER     0x00000028
844 #define PGE_ERR_MAPPING     0x00000030
845 #define PGE_ERR_CMD_PARSER  0x00000038
846 #define PGE_ERR_TYPE_MASK   0x00000007
847 #define PGE_ERR_INV_TABLE   0x00000000
848 #define PGE_ERR_INV_PTE     0x00000001
849 #define PGE_ERR_MIXED_TYPES 0x00000002
850 #define PGE_ERR_PAGE_MISS   0x00000003
851 #define PGE_ERR_ILLEGAL_TRX 0x00000004
852 #define PGE_ERR_LOCAL_MEM   0x00000005
853 #define PGE_ERR_TILED       0x00000006
854 /** @} */
855
856 /** @defgroup PGTBL_ER
857  * @{
858  */
859 /** Page table debug register for i945 */
860 # define PGTBL_ER       0x2024
861 # define PGTBL_ERR_MT_TILING                    (1 << 27)
862 # define PGTBL_ERR_MT_GTT_PTE                   (1 << 26)
863 # define PGTBL_ERR_LC_TILING                    (1 << 25)
864 # define PGTBL_ERR_LC_GTT_PTE                   (1 << 24)
865 # define PGTBL_ERR_BIN_VERTEXDATA_GTT_PTE       (1 << 23)
866 # define PGTBL_ERR_BIN_INSTRUCTION_GTT_PTE      (1 << 22)
867 # define PGTBL_ERR_CS_VERTEXDATA_GTT_PTE        (1 << 21)
868 # define PGTBL_ERR_CS_INSTRUCTION_GTT_PTE       (1 << 20)
869 # define PGTBL_ERR_CS_GTT               (1 << 19)
870 # define PGTBL_ERR_OVERLAY_TILING               (1 << 18)
871 # define PGTBL_ERR_OVERLAY_GTT_PTE              (1 << 16)
872 # define PGTBL_ERR_DISPC_TILING                 (1 << 14)
873 # define PGTBL_ERR_DISPC_GTT_PTE                (1 << 12)
874 # define PGTBL_ERR_DISPB_TILING                 (1 << 10)
875 # define PGTBL_ERR_DISPB_GTT_PTE                (1 << 8)
876 # define PGTBL_ERR_DISPA_TILING                 (1 << 6)
877 # define PGTBL_ERR_DISPA_GTT_PTE                (1 << 4)
878 # define PGTBL_ERR_HOST_PTE_DATA                (1 << 1)
879 # define PGTBL_ERR_HOST_GTT_PTE                 (1 << 0)
880 /** @} */
881
882 /* Ring buffer registers, p277, overview p19
883  */
884 #define LP_RING     0x2030
885 #define HP_RING     0x2040
886
887 #define RING_TAIL      0x00
888 #define TAIL_ADDR           0x000FFFF8
889 #define I830_TAIL_MASK      0x001FFFF8
890
891 #define RING_HEAD      0x04
892 #define HEAD_WRAP_COUNT     0xFFE00000
893 #define HEAD_WRAP_ONE       0x00200000
894 #define HEAD_ADDR           0x001FFFFC
895 #define I830_HEAD_MASK      0x001FFFFC
896
897 #define RING_START     0x08
898 #define START_ADDR          0x03FFFFF8
899 #define I830_RING_START_MASK    0xFFFFF000
900
901 #define RING_LEN       0x0C
902 #define RING_NR_PAGES       0x001FF000 
903 #define I830_RING_NR_PAGES      0x001FF000
904 #define RING_REPORT_MASK    0x00000006
905 #define RING_REPORT_64K     0x00000002
906 #define RING_REPORT_128K    0x00000004
907 #define RING_NO_REPORT      0x00000000
908 #define RING_VALID_MASK     0x00000001
909 #define RING_VALID          0x00000001
910 #define RING_INVALID        0x00000000
911
912
913
914 /* BitBlt Instructions
915  *
916  * There are many more masks & ranges yet to add.
917  */
918 #define BR00_BITBLT_CLIENT   0x40000000
919 #define BR00_OP_COLOR_BLT    0x10000000
920 #define BR00_OP_SRC_COPY_BLT 0x10C00000
921 #define BR00_OP_FULL_BLT     0x11400000
922 #define BR00_OP_MONO_SRC_BLT 0x11800000
923 #define BR00_OP_MONO_SRC_COPY_BLT 0x11000000
924 #define BR00_OP_MONO_PAT_BLT 0x11C00000
925 #define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22)
926 #define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000
927
928
929 #define BR00_TPCY_DISABLE    0x00000000
930 #define BR00_TPCY_ENABLE     0x00000010
931
932 #define BR00_TPCY_ROP        0x00000000
933 #define BR00_TPCY_NO_ROP     0x00000020
934 #define BR00_TPCY_EQ         0x00000000
935 #define BR00_TPCY_NOT_EQ     0x00000040
936
937 #define BR00_PAT_MSB_FIRST   0x00000000 /* ? */
938
939 #define BR00_PAT_VERT_ALIGN  0x000000e0
940
941 #define BR00_LENGTH          0x0000000F
942
943 #define BR09_DEST_ADDR       0x03FFFFFF
944
945 #define BR11_SOURCE_PITCH    0x00003FFF
946
947 #define BR12_SOURCE_ADDR     0x03FFFFFF
948
949 #define BR13_SOLID_PATTERN   0x80000000
950 #define BR13_RIGHT_TO_LEFT   0x40000000
951 #define BR13_LEFT_TO_RIGHT   0x00000000
952 #define BR13_MONO_TRANSPCY   0x20000000
953 #define BR13_MONO_PATN_TRANS 0x10000000
954 #define BR13_USE_DYN_DEPTH   0x04000000
955 #define BR13_DYN_8BPP        0x00000000
956 #define BR13_DYN_16BPP       0x01000000
957 #define BR13_DYN_24BPP       0x02000000
958 #define BR13_ROP_MASK        0x00FF0000
959 #define BR13_DEST_PITCH      0x0000FFFF
960 #define BR13_PITCH_SIGN_BIT  0x00008000
961
962 #define BR14_DEST_HEIGHT     0xFFFF0000
963 #define BR14_DEST_WIDTH      0x0000FFFF
964
965 #define BR15_PATTERN_ADDR    0x03FFFFFF
966
967 #define BR16_SOLID_PAT_COLOR 0x00FFFFFF
968 #define BR16_BACKGND_PAT_CLR 0x00FFFFFF
969
970 #define BR17_FGND_PAT_CLR    0x00FFFFFF
971
972 #define BR18_SRC_BGND_CLR    0x00FFFFFF
973 #define BR19_SRC_FGND_CLR    0x00FFFFFF
974
975
976 /* Instruction parser instructions
977  */
978
979 #define INST_PARSER_CLIENT   0x00000000
980 #define INST_OP_FLUSH        0x02000000
981 #define INST_FLUSH_MAP_CACHE 0x00000001
982
983
984 #define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
985
986
987 /* Registers in the i810 host-pci bridge pci config space which affect
988  * the i810 graphics operations.  
989  */
990 #define SMRAM_MISCC         0x70
991 #define GMS                    0x000000c0
992 #define GMS_DISABLE            0x00000000
993 #define GMS_ENABLE_BARE        0x00000040
994 #define GMS_ENABLE_512K        0x00000080
995 #define GMS_ENABLE_1M          0x000000c0
996 #define USMM                   0x00000030 
997 #define USMM_DISABLE           0x00000000
998 #define USMM_TSEG_ZERO         0x00000010
999 #define USMM_TSEG_512K         0x00000020
1000 #define USMM_TSEG_1M           0x00000030  
1001 #define GFX_MEM_WIN_SIZE       0x00010000
1002 #define GFX_MEM_WIN_32M        0x00010000
1003 #define GFX_MEM_WIN_64M        0x00000000
1004
1005 /* Overkill?  I don't know.  Need to figure out top of mem to make the
1006  * SMRAM calculations come out.  Linux seems to have problems
1007  * detecting it all on its own, so this seems a reasonable double
1008  * check to any user supplied 'mem=...' boot param.
1009  *
1010  * ... unfortunately this reg doesn't work according to spec on the
1011  * test hardware.
1012  */
1013 #define WHTCFG_PAMR_DRP      0x50
1014 #define SYS_DRAM_ROW_0_SHIFT    16
1015 #define SYS_DRAM_ROW_1_SHIFT    20
1016 #define DRAM_MASK           0x0f
1017 #define DRAM_VALUE_0        0
1018 #define DRAM_VALUE_1        8
1019 /* No 2 value defined */
1020 #define DRAM_VALUE_3        16
1021 #define DRAM_VALUE_4        16
1022 #define DRAM_VALUE_5        24
1023 #define DRAM_VALUE_6        32
1024 #define DRAM_VALUE_7        32
1025 #define DRAM_VALUE_8        48
1026 #define DRAM_VALUE_9        64
1027 #define DRAM_VALUE_A        64
1028 #define DRAM_VALUE_B        96
1029 #define DRAM_VALUE_C        128
1030 #define DRAM_VALUE_D        128
1031 #define DRAM_VALUE_E        192
1032 #define DRAM_VALUE_F        256 /* nice one, geezer */
1033 #define LM_FREQ_MASK        0x10
1034 #define LM_FREQ_133         0x10
1035 #define LM_FREQ_100         0x00
1036
1037
1038
1039
1040 /* These are 3d state registers, but the state is invarient, so we let
1041  * the X server handle it:
1042  */
1043
1044
1045
1046 /* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
1047  */
1048 #define GFX_OP_COLOR_CHROMA_KEY  ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
1049 #define CC1_UPDATE_KILL_WRITE    (1<<28)
1050 #define CC1_ENABLE_KILL_WRITE    (1<<27)
1051 #define CC1_DISABLE_KILL_WRITE    0
1052 #define CC1_UPDATE_COLOR_IDX     (1<<26)
1053 #define CC1_UPDATE_CHROMA_LOW    (1<<25)
1054 #define CC1_UPDATE_CHROMA_HI     (1<<24)
1055 #define CC1_CHROMA_LOW_MASK      ((1<<24)-1)
1056 #define CC2_COLOR_IDX_SHIFT      24
1057 #define CC2_COLOR_IDX_MASK       (0xff<<24)
1058 #define CC2_CHROMA_HI_MASK       ((1<<24)-1)
1059
1060
1061 #define GFX_CMD_CONTEXT_SEL      ((0<<29)|(0x5<<23))
1062 #define CS_UPDATE_LOAD           (1<<17)
1063 #define CS_UPDATE_USE            (1<<16)
1064 #define CS_UPDATE_LOAD           (1<<17)
1065 #define CS_LOAD_CTX0             0
1066 #define CS_LOAD_CTX1             (1<<8)
1067 #define CS_USE_CTX0              0
1068 #define CS_USE_CTX1              (1<<0)
1069
1070 /* I810 LCD/TV registers */
1071 #define LCD_TV_HTOTAL   0x60000
1072 #define LCD_TV_C        0x60018
1073 #define LCD_TV_OVRACT   0x6001C
1074
1075 #define LCD_TV_ENABLE (1 << 31)
1076 #define LCD_TV_VGAMOD (1 << 28)
1077
1078 /* I830 CRTC registers */
1079 #define HTOTAL_A        0x60000
1080 #define HBLANK_A        0x60004
1081 #define HSYNC_A         0x60008
1082 #define VTOTAL_A        0x6000c
1083 #define VBLANK_A        0x60010
1084 #define VSYNC_A         0x60014
1085 #define PIPEASRC        0x6001c
1086 #define BCLRPAT_A       0x60020
1087 #define VSYNCSHIFT_A    0x60028
1088
1089 #define HTOTAL_B        0x61000
1090 #define HBLANK_B        0x61004
1091 #define HSYNC_B         0x61008
1092 #define VTOTAL_B        0x6100c
1093 #define VBLANK_B        0x61010
1094 #define VSYNC_B         0x61014
1095 #define PIPEBSRC        0x6101c
1096 #define BCLRPAT_B       0x61020
1097 #define VSYNCSHIFT_B    0x61028
1098
1099 #define HTOTAL_C        0x62000
1100 #define HBLANK_C        0x62004
1101 #define HSYNC_C         0x62008
1102 #define VTOTAL_C        0x6200c
1103 #define VBLANK_C        0x62010
1104 #define VSYNC_C         0x62014
1105 #define PIPECSRC        0x6201c
1106 #define BCLRPAT_C       0x62020
1107 #define VSYNCSHIFT_C    0x62028
1108
1109 #define PP_STATUS       0x61200
1110 # define PP_ON                                  (1 << 31)
1111 /**
1112  * Indicates that all dependencies of the panel are on:
1113  *
1114  * - PLL enabled
1115  * - pipe enabled
1116  * - LVDS/DVOB/DVOC on
1117  */
1118 # define PP_READY                               (1 << 30)
1119 # define PP_SEQUENCE_NONE                       (0 << 28)
1120 # define PP_SEQUENCE_ON                         (1 << 28)
1121 # define PP_SEQUENCE_OFF                        (2 << 28)
1122 # define PP_SEQUENCE_MASK                       0x30000000
1123
1124 #define PP_CONTROL      0x61204
1125 # define POWER_DOWN_ON_RESET                    (1 << 1)
1126 # define POWER_TARGET_ON                        (1 << 0)
1127
1128 #define PP_ON_DELAYS    0x61208
1129 #define PP_OFF_DELAYS   0x6120c
1130 #define PP_DIVISOR      0x61210
1131
1132 #define PFIT_CONTROL    0x61230
1133 # define PFIT_ENABLE                            (1 << 31)
1134 /* Pre-965 */
1135 # define VERT_INTERP_DISABLE                    (0 << 10)
1136 # define VERT_INTERP_BILINEAR                   (1 << 10)
1137 # define VERT_INTERP_MASK                       (3 << 10)
1138 # define VERT_AUTO_SCALE                        (1 << 9)
1139 # define HORIZ_INTERP_DISABLE                   (0 << 6)
1140 # define HORIZ_INTERP_BILINEAR                  (1 << 6)
1141 # define HORIZ_INTERP_MASK                      (3 << 6)
1142 # define HORIZ_AUTO_SCALE                       (1 << 5)
1143 # define PANEL_8TO6_DITHER_ENABLE               (1 << 3)
1144 /* 965+ */
1145 # define PFIT_PIPE_MASK                         (3 << 29)
1146 # define PFIT_PIPE_SHIFT                        29
1147 # define PFIT_SCALING_MODE_MASK                 (7 << 26)
1148 #  define PFIT_SCALING_AUTO                     (0 << 26)
1149 #  define PFIT_SCALING_PROGRAMMED               (1 << 26)
1150 #  define PFIT_SCALING_PILLAR                   (2 << 26)
1151 #  define PFIT_SCALING_LETTER                   (3 << 26)
1152 # define PFIT_FILTER_SELECT_MASK                (3 << 24)
1153 #  define PFIT_FILTER_FUZZY                     (0 << 24)
1154 #  define PFIT_FILTER_CRISP                     (1 << 24)
1155 #  define PFIT_FILTER_MEDIAN                    (2 << 24)
1156
1157 #define PFIT_PGM_RATIOS 0x61234
1158 /* Pre-965 */
1159 # define PFIT_VERT_SCALE_SHIFT                  20
1160 # define PFIT_VERT_SCALE_MASK                   0xfff00000
1161 # define PFIT_HORIZ_SCALE_SHIFT                 4
1162 # define PFIT_HORIZ_SCALE_MASK                  0x0000fff0
1163 /* 965+ */
1164 # define PFIT_VERT_SCALE_SHIFT_965              16
1165 # define PFIT_VERT_SCALE_MASK_965               0x1fff0000
1166 # define PFIT_HORIZ_SCALE_SHIFT_965             0
1167 # define PFIT_HORIZ_SCALE_MASK_965              0x00001fff
1168
1169 #define DPLL_A          0x06014
1170 #define DPLL_B          0x06018
1171 # define DPLL_VCO_ENABLE                        (1 << 31)
1172 # define DPLL_DVO_HIGH_SPEED                    (1 << 30)
1173 # define DPLL_SYNCLOCK_ENABLE                   (1 << 29)
1174 # define DPLL_VGA_MODE_DIS                      (1 << 28)
1175 # define DPLLB_MODE_DAC_SERIAL                  (1 << 26) /* i915 */
1176 # define DPLLB_MODE_LVDS                        (2 << 26) /* i915 */
1177 # define DPLL_MODE_MASK                         (3 << 26)
1178 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10        (0 << 24) /* i915 */
1179 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5         (1 << 24) /* i915 */
1180 # define DPLLB_LVDS_P2_CLOCK_DIV_14             (0 << 24) /* i915 */
1181 # define DPLLB_LVDS_P2_CLOCK_DIV_7              (1 << 24) /* i915 */
1182 # define DPLL_P2_CLOCK_DIV_MASK                 0x03000000 /* i915 */
1183 # define DPLL_FPA01_P1_POST_DIV_MASK            0x00ff0000 /* i915 */
1184 # define DPLL_FPA01_P1_POST_DIV_MASK_IGD        0x00ff8000 /* IGD */
1185 /**
1186  *  The i830 generation, in DAC/serial mode, defines p1 as two plus this
1187  * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
1188  */
1189 # define DPLL_FPA01_P1_POST_DIV_MASK_I830       0x001f0000
1190 /**
1191  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
1192  * this field (only one bit may be set).
1193  */
1194 # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS  0x003f0000
1195 # define DPLL_FPA01_P1_POST_DIV_SHIFT           16
1196 # define DPLL_FPA01_P1_POST_DIV_SHIFT_IGD       15
1197 # define PLL_P2_DIVIDE_BY_4                     (1 << 23) /* i830, required in DVO non-gang */
1198 # define PLL_P1_DIVIDE_BY_TWO                   (1 << 21) /* i830 */
1199 # define PLL_REF_INPUT_DREFCLK                  (0 << 13)
1200 # define PLL_REF_INPUT_TVCLKINA                 (1 << 13) /* i830 */
1201 # define PLL_REF_INPUT_SUPER_SSC                (1 << 13) /* Ironlake: 120M SSC */
1202 # define PLL_REF_INPUT_TVCLKINBC                (2 << 13) /* SDVO TVCLKIN */
1203 # define PLLB_REF_INPUT_SPREADSPECTRUMIN        (3 << 13)
1204 # define PLL_REF_INPUT_MASK                     (3 << 13)
1205 # define PLL_REF_INPUT_DMICLK                   (5 << 13) /* Ironlake: DMI refclk */
1206 # define PLL_LOAD_PULSE_PHASE_SHIFT             9
1207 /*
1208  * Parallel to Serial Load Pulse phase selection.
1209  * Selects the phase for the 10X DPLL clock for the PCIe
1210  * digital display port. The range is 4 to 13; 10 or more
1211  * is just a flip delay. The default is 6
1212  */
1213 # define PLL_LOAD_PULSE_PHASE_MASK              (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
1214 # define DISPLAY_RATE_SELECT_FPA1               (1 << 8)
1215 /* Ironlake */
1216 # define PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT     9
1217 # define PLL_REF_SDVO_HDMI_MULTIPLIER_MASK      (7 << 9)
1218 # define PLL_REF_SDVO_HDMI_MULTIPLIER(x)        (((x)-1)<< PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT)
1219 # define DPLL_FPA1_P1_POST_DIV_SHIFT            0
1220 # define DPLL_FPA1_P1_POST_DIV_MASK             0xff
1221
1222 /**
1223  * SDVO multiplier for 945G/GM. Not used on 965.
1224  *
1225  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1226  */
1227 # define SDVO_MULTIPLIER_MASK                   0x000000ff
1228 # define SDVO_MULTIPLIER_SHIFT_HIRES            4
1229 # define SDVO_MULTIPLIER_SHIFT_VGA              0
1230
1231 /** @defgroup DPLL_MD
1232  * @{
1233  */
1234 /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
1235 #define DPLL_A_MD               0x0601c
1236 /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
1237 #define DPLL_B_MD               0x06020
1238 /**
1239  * UDI pixel divider, controlling how many pixels are stuffed into a packet.
1240  *
1241  * Value is pixels minus 1.  Must be set to 1 pixel for SDVO.
1242  */
1243 # define DPLL_MD_UDI_DIVIDER_MASK               0x3f000000
1244 # define DPLL_MD_UDI_DIVIDER_SHIFT              24
1245 /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
1246 # define DPLL_MD_VGA_UDI_DIVIDER_MASK           0x003f0000
1247 # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT          16
1248 /**
1249  * SDVO/UDI pixel multiplier.
1250  *
1251  * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
1252  * clock rate is 10 times the DPLL clock.  At low resolution/refresh rate
1253  * modes, the bus rate would be below the limits, so SDVO allows for stuffing
1254  * dummy bytes in the datastream at an increased clock rate, with both sides of
1255  * the link knowing how many bytes are fill.
1256  *
1257  * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
1258  * rate to 130Mhz to get a bus rate of 1.30Ghz.  The DPLL clock rate would be
1259  * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
1260  * through an SDVO command.
1261  *
1262  * This register field has values of multiplication factor minus 1, with
1263  * a maximum multiplier of 5 for SDVO.
1264  */
1265 # define DPLL_MD_UDI_MULTIPLIER_MASK            0x00003f00
1266 # define DPLL_MD_UDI_MULTIPLIER_SHIFT           8
1267 /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK. 
1268  * This best be set to the default value (3) or the CRT won't work. No,
1269  * I don't entirely understand what this does...
1270  */
1271 # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK        0x0000003f
1272 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT       0
1273 /** @} */
1274
1275 #define DPLL_TEST               0x606c
1276 # define DPLLB_TEST_SDVO_DIV_1                  (0 << 22)
1277 # define DPLLB_TEST_SDVO_DIV_2                  (1 << 22)
1278 # define DPLLB_TEST_SDVO_DIV_4                  (2 << 22)
1279 # define DPLLB_TEST_SDVO_DIV_MASK               (3 << 22)
1280 # define DPLLB_TEST_N_BYPASS                    (1 << 19)
1281 # define DPLLB_TEST_M_BYPASS                    (1 << 18)
1282 # define DPLLB_INPUT_BUFFER_ENABLE              (1 << 16)
1283 # define DPLLA_TEST_N_BYPASS                    (1 << 3)
1284 # define DPLLA_TEST_M_BYPASS                    (1 << 2)
1285 # define DPLLA_INPUT_BUFFER_ENABLE              (1 << 0)
1286
1287 #define D_STATE                 0x6104
1288 #define DSPCLK_GATE_D           0x6200
1289 # define DPUNIT_B_CLOCK_GATE_DISABLE            (1 << 30) /* 965 */
1290 # define VSUNIT_CLOCK_GATE_DISABLE              (1 << 29) /* 965 */
1291 # define VRHUNIT_CLOCK_GATE_DISABLE             (1 << 28) /* 965 */
1292 # define VRDUNIT_CLOCK_GATE_DISABLE             (1 << 27) /* 965 */
1293 # define AUDUNIT_CLOCK_GATE_DISABLE             (1 << 26) /* 965 */
1294 # define DPUNIT_A_CLOCK_GATE_DISABLE            (1 << 25) /* 965 */
1295 # define DPCUNIT_CLOCK_GATE_DISABLE             (1 << 24) /* 965 */
1296 # define TVRUNIT_CLOCK_GATE_DISABLE             (1 << 23) /* 915-945 */
1297 # define TVCUNIT_CLOCK_GATE_DISABLE             (1 << 22) /* 915-945 */
1298 # define TVFUNIT_CLOCK_GATE_DISABLE             (1 << 21) /* 915-945 */
1299 # define TVEUNIT_CLOCK_GATE_DISABLE             (1 << 20) /* 915-945 */
1300 # define DVSUNIT_CLOCK_GATE_DISABLE             (1 << 19) /* 915-945 */
1301 # define DSSUNIT_CLOCK_GATE_DISABLE             (1 << 18) /* 915-945 */
1302 # define DDBUNIT_CLOCK_GATE_DISABLE             (1 << 17) /* 915-945 */
1303 # define DPRUNIT_CLOCK_GATE_DISABLE             (1 << 16) /* 915-945 */
1304 # define DPFUNIT_CLOCK_GATE_DISABLE             (1 << 15) /* 915-945 */
1305 # define DPBMUNIT_CLOCK_GATE_DISABLE            (1 << 14) /* 915-945 */
1306 # define DPLSUNIT_CLOCK_GATE_DISABLE            (1 << 13) /* 915-945 */
1307 # define DPLUNIT_CLOCK_GATE_DISABLE             (1 << 12) /* 915-945 */
1308 # define DPOUNIT_CLOCK_GATE_DISABLE             (1 << 11)
1309 # define DPBUNIT_CLOCK_GATE_DISABLE             (1 << 10)
1310 # define DCUNIT_CLOCK_GATE_DISABLE              (1 << 9)
1311 # define DPUNIT_CLOCK_GATE_DISABLE              (1 << 8)
1312 # define VRUNIT_CLOCK_GATE_DISABLE              (1 << 7) /* 915+: reserved */
1313 # define OVHUNIT_CLOCK_GATE_DISABLE             (1 << 6) /* 830-865 */
1314 # define DPIOUNIT_CLOCK_GATE_DISABLE            (1 << 6) /* 915-945 */
1315 # define OVFUNIT_CLOCK_GATE_DISABLE             (1 << 5)
1316 # define OVBUNIT_CLOCK_GATE_DISABLE             (1 << 4)
1317 /**
1318  * This bit must be set on the 830 to prevent hangs when turning off the
1319  * overlay scaler.
1320  */
1321 # define OVRUNIT_CLOCK_GATE_DISABLE             (1 << 3)
1322 # define OVCUNIT_CLOCK_GATE_DISABLE             (1 << 2)
1323 # define OVUUNIT_CLOCK_GATE_DISABLE             (1 << 1)
1324 # define ZVUNIT_CLOCK_GATE_DISABLE              (1 << 0) /* 830 */
1325 # define OVLUNIT_CLOCK_GATE_DISABLE             (1 << 0) /* 845,865 */
1326
1327 #define RENCLK_GATE_D1          0x6204
1328 # define BLITTER_CLOCK_GATE_DISABLE             (1 << 13) /* 945GM only */
1329 # define MPEG_CLOCK_GATE_DISABLE                (1 << 12) /* 945GM only */
1330 # define PC_FE_CLOCK_GATE_DISABLE               (1 << 11)
1331 # define PC_BE_CLOCK_GATE_DISABLE               (1 << 10)
1332 # define WINDOWER_CLOCK_GATE_DISABLE            (1 << 9)
1333 # define INTERPOLATOR_CLOCK_GATE_DISABLE        (1 << 8)
1334 # define COLOR_CALCULATOR_CLOCK_GATE_DISABLE    (1 << 7)
1335 # define MOTION_COMP_CLOCK_GATE_DISABLE         (1 << 6)
1336 # define MAG_CLOCK_GATE_DISABLE                 (1 << 5)
1337 /** This bit must be unset on 855,865 */
1338 # define MECI_CLOCK_GATE_DISABLE                (1 << 4)
1339 # define DCMP_CLOCK_GATE_DISABLE                (1 << 3)
1340 # define MEC_CLOCK_GATE_DISABLE                 (1 << 2)
1341 # define MECO_CLOCK_GATE_DISABLE                (1 << 1)
1342 /** This bit must be set on 855,865. */
1343 # define SV_CLOCK_GATE_DISABLE                  (1 << 0)
1344 # define I915_MPEG_CLOCK_GATE_DISABLE           (1 << 16)
1345 # define I915_VLD_IP_PR_CLOCK_GATE_DISABLE      (1 << 15)
1346 # define I915_MOTION_COMP_CLOCK_GATE_DISABLE    (1 << 14)
1347 # define I915_BD_BF_CLOCK_GATE_DISABLE          (1 << 13)
1348 # define I915_SF_SE_CLOCK_GATE_DISABLE          (1 << 12)
1349 # define I915_WM_CLOCK_GATE_DISABLE             (1 << 11)
1350 # define I915_IZ_CLOCK_GATE_DISABLE             (1 << 10)
1351 # define I915_PI_CLOCK_GATE_DISABLE             (1 << 9)
1352 # define I915_DI_CLOCK_GATE_DISABLE             (1 << 8)
1353 # define I915_SH_SV_CLOCK_GATE_DISABLE          (1 << 7)
1354 # define I915_PL_DG_QC_FT_CLOCK_GATE_DISABLE    (1 << 6)
1355 # define I915_SC_CLOCK_GATE_DISABLE             (1 << 5)
1356 # define I915_FL_CLOCK_GATE_DISABLE             (1 << 4)
1357 # define I915_DM_CLOCK_GATE_DISABLE             (1 << 3)
1358 # define I915_PS_CLOCK_GATE_DISABLE             (1 << 2)
1359 # define I915_CC_CLOCK_GATE_DISABLE             (1 << 1)
1360 # define I915_BY_CLOCK_GATE_DISABLE             (1 << 0)
1361
1362 # define I965_RCZ_CLOCK_GATE_DISABLE            (1 << 30)
1363 /** This bit must always be set on 965G/965GM */
1364 # define I965_RCC_CLOCK_GATE_DISABLE            (1 << 29)
1365 # define I965_RCPB_CLOCK_GATE_DISABLE           (1 << 28)
1366 # define I965_DAP_CLOCK_GATE_DISABLE            (1 << 27)
1367 # define I965_ROC_CLOCK_GATE_DISABLE            (1 << 26)
1368 # define I965_GW_CLOCK_GATE_DISABLE             (1 << 25)
1369 # define I965_TD_CLOCK_GATE_DISABLE             (1 << 24)
1370 /** This bit must always be set on 965G */
1371 # define I965_ISC_CLOCK_GATE_DISABLE            (1 << 23)
1372 # define I965_IC_CLOCK_GATE_DISABLE             (1 << 22)
1373 # define I965_EU_CLOCK_GATE_DISABLE             (1 << 21)
1374 # define I965_IF_CLOCK_GATE_DISABLE             (1 << 20)
1375 # define I965_TC_CLOCK_GATE_DISABLE             (1 << 19)
1376 # define I965_SO_CLOCK_GATE_DISABLE             (1 << 17)
1377 # define I965_FBC_CLOCK_GATE_DISABLE            (1 << 16)
1378 # define I965_MARI_CLOCK_GATE_DISABLE           (1 << 15)
1379 # define I965_MASF_CLOCK_GATE_DISABLE           (1 << 14)
1380 # define I965_MAWB_CLOCK_GATE_DISABLE           (1 << 13)
1381 # define I965_EM_CLOCK_GATE_DISABLE             (1 << 12)
1382 # define I965_UC_CLOCK_GATE_DISABLE             (1 << 11)
1383 # define I965_SI_CLOCK_GATE_DISABLE             (1 << 6)
1384 # define I965_MT_CLOCK_GATE_DISABLE             (1 << 5)
1385 # define I965_PL_CLOCK_GATE_DISABLE             (1 << 4)
1386 # define I965_DG_CLOCK_GATE_DISABLE             (1 << 3)
1387 # define I965_QC_CLOCK_GATE_DISABLE             (1 << 2)
1388 # define I965_FT_CLOCK_GATE_DISABLE             (1 << 1)
1389 # define I965_DM_CLOCK_GATE_DISABLE             (1 << 0)
1390
1391 #define RENCLK_GATE_D2          0x6208
1392 #define VF_UNIT_CLOCK_GATE_DISABLE              (1 << 9)
1393 #define GS_UNIT_CLOCK_GATE_DISABLE              (1 << 7)
1394 #define CL_UNIT_CLOCK_GATE_DISABLE              (1 << 6)
1395 #define RAMCLK_GATE_D           0x6210          /* CRL only */
1396 #define DEUC                    0x6214          /* CRL only */
1397
1398 /*
1399  * This is a PCI config space register to manipulate backlight brightness
1400  * It is used when the BLM_LEGACY_MODE is turned on. When enabled, the first
1401  * byte of this config register sets brightness within the range from
1402  * 0 to 0xff
1403  */
1404 #define LEGACY_BACKLIGHT_BRIGHTNESS 0xf4
1405
1406 #define BLC_PWM_CTL             0x61254
1407 #define BACKLIGHT_MODULATION_FREQ_SHIFT         (17)
1408 #define BACKLIGHT_MODULATION_FREQ_SHIFT2        (16)
1409 /**
1410  * This is the most significant 15 bits of the number of backlight cycles in a
1411  * complete cycle of the modulated backlight control.
1412  *
1413  * The actual value is this field multiplied by two.
1414  */
1415 #define BACKLIGHT_MODULATION_FREQ_MASK          (0x7fff << 17)
1416 #define BACKLIGHT_MODULATION_FREQ_MASK2         (0xffff << 16)
1417 #define BLM_LEGACY_MODE                         (1 << 16)
1418
1419 /**
1420  * This is the number of cycles out of the backlight modulation cycle for which
1421  * the backlight is on.
1422  *
1423  * This field must be no greater than the number of cycles in the complete
1424  * backlight modulation cycle.
1425  */
1426 #define BACKLIGHT_DUTY_CYCLE_SHIFT              (0)
1427 #define BACKLIGHT_DUTY_CYCLE_MASK               (0xffff)
1428
1429 /* On 965+ backlight control is in another register */
1430 #define BLC_PWM_CTL2                    0x61250
1431 #define         BLM_LEGACY_MODE2        (1 << 30)
1432
1433 #define BLM_CTL                 0x61260
1434 #define BLM_THRESHOLD_0         0x61270
1435 #define BLM_THRESHOLD_1         0x61274
1436 #define BLM_THRESHOLD_2         0x61278
1437 #define BLM_THRESHOLD_3         0x6127c
1438 #define BLM_THRESHOLD_4         0x61280
1439 #define BLM_THRESHOLD_5         0x61284
1440
1441 #define BLM_ACCUMULATOR_0       0x61290
1442 #define BLM_ACCUMULATOR_1       0x61294
1443 #define BLM_ACCUMULATOR_2       0x61298
1444 #define BLM_ACCUMULATOR_3       0x6129c
1445 #define BLM_ACCUMULATOR_4       0x612a0
1446 #define BLM_ACCUMULATOR_5       0x612a4
1447
1448 #define FPA0            0x06040
1449 #define FPA1            0x06044
1450 #define FPB0            0x06048
1451 #define FPB1            0x0604c
1452 # define FP_N_DIV_MASK                          0x003f0000
1453 # define FP_N_IGD_DIV_MASK                      0x00ff0000
1454 # define FP_N_DIV_SHIFT                         16
1455 # define FP_M1_DIV_MASK                         0x00003f00
1456 # define FP_M1_DIV_SHIFT                        8
1457 # define FP_M2_DIV_MASK                         0x0000003f
1458 # define FP_M2_IGD_DIV_MASK                     0x000000ff
1459 # define FP_M2_DIV_SHIFT                        0
1460
1461 #define PORT_HOTPLUG_EN         0x61110
1462 # define HDMIB_HOTPLUG_INT_EN                   (1 << 29)
1463 # define HDMIC_HOTPLUG_INT_EN                   (1 << 28)
1464 # define HDMID_HOTPLUG_INT_EN                   (1 << 27)
1465 # define SDVOB_HOTPLUG_INT_EN                   (1 << 26)
1466 # define SDVOC_HOTPLUG_INT_EN                   (1 << 25)
1467 # define TV_HOTPLUG_INT_EN                      (1 << 18)
1468 # define CRT_HOTPLUG_INT_EN                     (1 << 9)
1469 # define CRT_HOTPLUG_ACTIVATION_PERIOD_32       (0 << 8)
1470 /* must use period 64 on GM45 according to docs */
1471 # define CRT_HOTPLUG_ACTIVATION_PERIOD_64       (1 << 8)
1472 # define CRT_HOTPLUG_DAC_ON_TIME_2M             (0 << 7)
1473 # define CRT_HOTPLUG_DAC_ON_TIME_4M             (1 << 7)
1474 # define CRT_HOTPLUG_VOLTAGE_COMPARE_40         (0 << 5)
1475 # define CRT_HOTPLUG_VOLTAGE_COMPARE_50         (1 << 5)
1476 # define CRT_HOTPLUG_VOLTAGE_COMPARE_60         (2 << 5)
1477 # define CRT_HOTPLUG_VOLTAGE_COMPARE_70         (3 << 5)
1478 # define CRT_HOTPLUG_VOLTAGE_COMPARE_MASK       (3 << 5)
1479 # define CRT_HOTPLUG_DETECT_DELAY_1G            (0 << 4)
1480 # define CRT_HOTPLUG_DETECT_DELAY_2G            (1 << 4)
1481 # define CRT_HOTPLUG_FORCE_DETECT               (1 << 3)
1482 # define CRT_HOTPLUG_DETECT_VOLTAGE_325MV       (0 << 2)
1483 # define CRT_HOTPLUG_DETECT_VOLTAGE_475MV       (1 << 2)
1484 # define CRT_HOTPLUG_MASK                       (0x3fc) /* Bits 9-2 */
1485
1486 #define PORT_HOTPLUG_STAT       0x61114
1487 # define HDMIB_HOTPLUG_INT_STATUS               (1 << 29)
1488 # define HDMIC_HOTPLUG_INT_STATUS               (1 << 28)
1489 # define HDMID_HOTPLUG_INT_STATUS               (1 << 27)
1490 # define CRT_HOTPLUG_INT_STATUS                 (1 << 11)
1491 # define TV_HOTPLUG_INT_STATUS                  (1 << 10)
1492 # define CRT_HOTPLUG_MONITOR_MASK               (3 << 8)
1493 # define CRT_HOTPLUG_MONITOR_COLOR              (3 << 8)
1494 # define CRT_HOTPLUG_MONITOR_MONO               (2 << 8)
1495 # define CRT_HOTPLUG_MONITOR_NONE               (0 << 8)
1496 # define SDVOC_HOTPLUG_INT_STATUS               (1 << 7)
1497 # define SDVOB_HOTPLUG_INT_STATUS               (1 << 6)
1498
1499 #define SDVOB                   0x61140
1500 #define SDVOC                   0x61160
1501 #define SDVO_ENABLE                             (1 << 31)
1502 #define SDVO_PIPE_B_SELECT                      (1 << 30)
1503 #define SDVO_STALL_SELECT                       (1 << 29)
1504 #define SDVO_INTERRUPT_ENABLE                   (1 << 26)
1505 /**
1506  * 915G/GM SDVO pixel multiplier.
1507  *
1508  * Programmed value is multiplier - 1, up to 5x.
1509  *
1510  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
1511  */
1512 #define SDVO_PORT_MULTIPLY_MASK                 (7 << 23)
1513 #define SDVO_PORT_MULTIPLY_SHIFT                23
1514 #define SDVO_PHASE_SELECT_MASK                  (15 << 19)
1515 #define SDVO_PHASE_SELECT_DEFAULT               (6 << 19)
1516 #define SDVO_CLOCK_OUTPUT_INVERT                (1 << 18)
1517 #define SDVOC_GANG_MODE                         (1 << 16)
1518 #define SDVO_ENCODING_SDVO                      (0x0 << 10)
1519 #define SDVO_ENCODING_HDMI                      (0x2 << 10)
1520 /** Requird for HDMI operation */
1521 #define SDVO_NULL_PACKETS_DURING_VSYNC          (1 << 9)
1522 #define SDVO_BORDER_ENABLE                      (1 << 7)
1523 #define SDVO_AUDIO_ENABLE                       (1 << 6)
1524 /** New with 965, default is to be set */
1525 #define SDVO_VSYNC_ACTIVE_HIGH                  (1 << 4)
1526 /** New with 965, default is to be set */
1527 #define SDVO_HSYNC_ACTIVE_HIGH                  (1 << 3)
1528 /** 915/945 only, read-only bit */
1529 #define SDVOB_PCIE_CONCURRENCY                  (1 << 3)
1530 #define SDVO_DETECTED                           (1 << 2)
1531 /* Bits to be preserved when writing */
1532 #define SDVOB_PRESERVE_MASK                     ((1 << 17) | (1 << 16) | (1 << 14))
1533 #define SDVOC_PRESERVE_MASK                     (1 << 17)
1534
1535 #define UDIB_SVB_SHB_CODES              0x61144
1536 #define UDIB_SHA_BLANK_CODES            0x61148
1537 #define UDIB_START_END_FILL_CODES       0x6114c
1538
1539
1540 #define SDVOUDI                         0x61150
1541
1542 #define I830_HTOTAL_MASK        0xfff0000
1543 #define I830_HACTIVE_MASK       0x7ff
1544
1545 #define I830_HBLANKEND_MASK     0xfff0000
1546 #define I830_HBLANKSTART_MASK    0xfff
1547
1548 #define I830_HSYNCEND_MASK      0xfff0000
1549 #define I830_HSYNCSTART_MASK    0xfff
1550
1551 #define I830_VTOTAL_MASK        0xfff0000
1552 #define I830_VACTIVE_MASK       0x7ff
1553
1554 #define I830_VBLANKEND_MASK     0xfff0000
1555 #define I830_VBLANKSTART_MASK    0xfff
1556
1557 #define I830_VSYNCEND_MASK      0xfff0000
1558 #define I830_VSYNCSTART_MASK    0xfff
1559
1560 #define I830_PIPEA_HORZ_MASK    0x7ff0000
1561 #define I830_PIPEA_VERT_MASK    0x7ff
1562
1563 #define ADPA                    0x61100
1564 #define ADPA_DAC_ENABLE         (1<<31)
1565 #define ADPA_DAC_DISABLE        0
1566 #define ADPA_PIPE_SELECT_MASK   (1<<30)
1567 #define ADPA_PIPE_A_SELECT      0
1568 #define ADPA_PIPE_B_SELECT      (1<<30)
1569 #define ADPA_USE_VGA_HVPOLARITY (1<<15)
1570 #define ADPA_SETS_HVPOLARITY    0
1571 #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
1572 #define ADPA_VSYNC_CNTL_ENABLE  0
1573 #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
1574 #define ADPA_HSYNC_CNTL_ENABLE  0
1575 #define ADPA_VSYNC_ACTIVE_HIGH  (1<<4)
1576 #define ADPA_VSYNC_ACTIVE_LOW   0
1577 #define ADPA_HSYNC_ACTIVE_HIGH  (1<<3)
1578 #define ADPA_HSYNC_ACTIVE_LOW   0
1579
1580 #define PCH_DSP_CHICKEN1        0x42000
1581 #define PCH_DSP_CHICKEN2        0x42004
1582 #define PCH_DSP_CHICKEN3        0x4200c
1583 #define PCH_DSPCLK_GATE_D       0x42020
1584 #define PCH_DSPRAMCLK_GATE_D    0x42024
1585 #define PCH_3DCGDIS0            0x46020
1586 #define PCH_3DCGDIS1            0x46024
1587 #define PCH_3DRAMCGDIS0         0x46028
1588 #define SOUTH_DSPCLK_GATE_D     0xc2020
1589
1590 #define CPU_eDP_A               0x64000
1591 #define PCH_DP_B                0xe4100
1592 #define PCH_DP_C                0xe4200
1593 #define PCH_DP_D                0xe4300
1594
1595 #define DVOA                    0x61120
1596 #define DVOB                    0x61140
1597 #define DVOC                    0x61160
1598 #define DVO_ENABLE                      (1 << 31)
1599 #define DVO_PIPE_B_SELECT               (1 << 30)
1600 #define DVO_PIPE_STALL_UNUSED           (0 << 28)
1601 #define DVO_PIPE_STALL                  (1 << 28)
1602 #define DVO_PIPE_STALL_TV               (2 << 28)
1603 #define DVO_PIPE_STALL_MASK             (3 << 28)
1604 #define DVO_USE_VGA_SYNC                (1 << 15)
1605 #define DVO_DATA_ORDER_I740             (0 << 14)
1606 #define DVO_DATA_ORDER_FP               (1 << 14)
1607 #define DVO_VSYNC_DISABLE               (1 << 11)
1608 #define DVO_HSYNC_DISABLE               (1 << 10)
1609 #define DVO_VSYNC_TRISTATE              (1 << 9)
1610 #define DVO_HSYNC_TRISTATE              (1 << 8)
1611 #define DVO_BORDER_ENABLE               (1 << 7)
1612 #define DVO_DATA_ORDER_GBRG             (1 << 6)
1613 #define DVO_DATA_ORDER_RGGB             (0 << 6)
1614 #define DVO_DATA_ORDER_GBRG_ERRATA      (0 << 6)
1615 #define DVO_DATA_ORDER_RGGB_ERRATA      (1 << 6)
1616 #define DVO_VSYNC_ACTIVE_HIGH           (1 << 4)
1617 #define DVO_HSYNC_ACTIVE_HIGH           (1 << 3)
1618 #define DVO_BLANK_ACTIVE_HIGH           (1 << 2)
1619 #define DVO_OUTPUT_CSTATE_PIXELS        (1 << 1)        /* SDG only */
1620 #define DVO_OUTPUT_SOURCE_SIZE_PIXELS   (1 << 0)        /* SDG only */
1621 #define DVO_PRESERVE_MASK       (0x7<<24)
1622
1623 #define DVOA_SRCDIM             0x61124
1624 #define DVOB_SRCDIM             0x61144
1625 #define DVOC_SRCDIM             0x61164
1626 #define DVO_SRCDIM_HORIZONTAL_SHIFT     12
1627 #define DVO_SRCDIM_VERTICAL_SHIFT       0
1628
1629 /** @defgroup LVDS
1630  * @{
1631  */
1632 /**
1633  * This register controls the LVDS output enable, pipe selection, and data
1634  * format selection.
1635  *
1636  * All of the clock/data pairs are force powered down by power sequencing.
1637  */
1638 #define LVDS                    0x61180
1639 /**
1640  * Enables the LVDS port.  This bit must be set before DPLLs are enabled, as
1641  * the DPLL semantics change when the LVDS is assigned to that pipe.
1642  */
1643 # define LVDS_PORT_EN                   (1 << 31)
1644 /** Selects pipe B for LVDS data.  Must be set on pre-965. */
1645 # define LVDS_PIPEB_SELECT              (1 << 30)
1646
1647 /* on 965, dithering is enabled in this register, not PFIT_CONTROL */
1648 # define LVDS_DITHER_ENABLE             (1 << 25)
1649
1650 /*
1651  * Selects between .0 and .1 formats:
1652  *
1653  * 0 = 1x18.0, 2x18.0, 1x24.0 or 2x24.0
1654  * 1 = 1x24.1 or 2x24.1
1655  */
1656 # define LVDS_DATA_FORMAT_DOT_ONE       (1 << 24)
1657
1658 /* Using LE instead of HS on second channel control signal */
1659 # define LVDS_LE_CONTROL_ENABLE         (1 << 23)
1660
1661 /* Using LF instead of VS on second channel control signal */
1662 # define LVDS_LF_CONTROL_ENABLE         (1 << 22)
1663
1664 /* invert vsync signal polarity */
1665 # define LVDS_VSYNC_POLARITY_INVERT     (1 << 21)
1666
1667 /* invert hsync signal polarity */
1668 # define LVDS_HSYNC_POLARITY_INVERT     (1 << 20)
1669
1670 /* invert display enable signal polarity */
1671 # define LVDS_DE_POLARITY_INVERT        (1 << 19)
1672
1673 /*
1674  * Control signals for second channel, ignored in single channel modes
1675  */
1676
1677 /* send DE, HS, VS on second channel */
1678 # define LVDS_SECOND_CHANNEL_DE_HS_VS   (0 << 17)
1679
1680 # define LVDS_SECOND_CHANNEL_RESERVED   (1 << 17)
1681
1682 /* Send zeros instead of DE, HS, VS on second channel */
1683 # define LVDS_SECOND_CHANNEL_ZEROS      (2 << 17)
1684
1685 /* Set DE=0, HS=LE, VS=LF on second channel */
1686 # define LVDS_SECOND_CHANNEL_HS_VS      (3 << 17)
1687
1688 /*
1689  * Send duplicate data for channel reserved bits, otherwise send zeros
1690  */
1691 # define LVDS_CHANNEL_DUP_RESERVED      (1 << 16)
1692
1693 /*
1694  * Enable border for unscaled (or aspect-scaled) display
1695  */
1696 # define LVDS_BORDER_ENABLE             (1 << 15)
1697
1698 /*
1699  * Tri-state the LVDS buffers when powered down, otherwise
1700  * they are set to 0V
1701  */
1702 # define LVDS_POWER_DOWN_TRI_STATE      (1 << 10)
1703
1704 /**
1705  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
1706  * pixel.
1707  */
1708 # define LVDS_A0A2_CLKA_POWER_MASK      (3 << 8)
1709 # define LVDS_A0A2_CLKA_POWER_DOWN      (0 << 8)
1710 # define LVDS_A0A2_CLKA_POWER_UP        (3 << 8)
1711 /**
1712  * Controls the A3 data pair, which contains the additional LSBs for 24 bit
1713  * mode.  Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
1714  * on.
1715  */
1716 # define LVDS_A3_POWER_MASK             (3 << 6)
1717 # define LVDS_A3_POWER_DOWN             (0 << 6)
1718 # define LVDS_A3_POWER_UP               (3 << 6)
1719 /**
1720  * Controls the CLKB pair.  This should only be set when LVDS_B0B3_POWER_UP
1721  * is set.
1722  */
1723 # define LVDS_CLKB_POWER_MASK           (3 << 4)
1724 # define LVDS_CLKB_POWER_DOWN           (0 << 4)
1725 # define LVDS_CLKB_POWER_UP             (3 << 4)
1726
1727 /**
1728  * Controls the B0-B3 data pairs.  This must be set to match the DPLL p2
1729  * setting for whether we are in dual-channel mode.  The B3 pair will
1730  * additionally only be powered up when LVDS_A3_POWER_UP is set.
1731  */
1732 # define LVDS_B0B3_POWER_MASK           (3 << 2)
1733 # define LVDS_B0B3_POWER_DOWN           (0 << 2)
1734 # define LVDS_B0B3_POWER_UP             (3 << 2)
1735
1736 /** @} */
1737
1738 #define DP_B                    0x64100
1739 #define DPB_AUX_CH_CTL          0x64110
1740 #define DPB_AUX_CH_DATA1        0x64114
1741 #define DPB_AUX_CH_DATA2        0x64118
1742 #define DPB_AUX_CH_DATA3        0x6411c
1743 #define DPB_AUX_CH_DATA4        0x64120
1744 #define DPB_AUX_CH_DATA5        0x64124
1745
1746 #define DP_C                    0x64200
1747 #define DPC_AUX_CH_CTL          0x64210
1748 #define DPC_AUX_CH_DATA1        0x64214
1749 #define DPC_AUX_CH_DATA2        0x64218
1750 #define DPC_AUX_CH_DATA3        0x6421c
1751 #define DPC_AUX_CH_DATA4        0x64220
1752 #define DPC_AUX_CH_DATA5        0x64224
1753
1754 #define DP_D                    0x64300
1755 #define DPD_AUX_CH_CTL          0x64310
1756 #define DPD_AUX_CH_DATA1        0x64314
1757 #define DPD_AUX_CH_DATA2        0x64318
1758 #define DPD_AUX_CH_DATA3        0x6431c
1759 #define DPD_AUX_CH_DATA4        0x64320
1760 #define DPD_AUX_CH_DATA5        0x64324
1761
1762 /*
1763  * Two channel clock control. Turn this on if you need clkb for two channel mode
1764  * Overridden by global LVDS power sequencing
1765  */
1766
1767 /* clkb off */
1768 # define LVDS_CLKB_POWER_DOWN           (0 << 4)
1769
1770 /* powered up, but clkb forced to 0 */
1771 # define LVDS_CLKB_POWER_PARTIAL        (1 << 4)
1772
1773 /* clock B running */
1774 # define LVDS_CLKB_POWER_UP             (3 << 4)
1775
1776 /*
1777  * Two channel mode B0-B2 control. Sets state when power is on.
1778  * Set to POWER_DOWN in single channel mode, other settings enable
1779  * two channel mode. The CLKB power control controls whether that clock
1780  * is enabled during two channel mode.
1781  *
1782  */
1783 /* Everything is off, including B3 and CLKB */
1784 # define LVDS_B_POWER_DOWN              (0 << 2)
1785
1786 /* B0, B1, B2 and data lines forced to 0. timing is active */
1787 # define LVDS_B_POWER_PARTIAL           (1 << 2)
1788
1789 /* data lines active (both timing and colour) */
1790 # define LVDS_B_POWER_UP                (3 << 2)
1791
1792 /** @defgroup TV_CTL
1793  * @{
1794  */
1795 #define TV_CTL                  0x68000
1796 /** Enables the TV encoder */
1797 # define TV_ENC_ENABLE                  (1 << 31)
1798 /** Sources the TV encoder input from pipe B instead of A. */
1799 # define TV_ENC_PIPEB_SELECT            (1 << 30)
1800 /** Outputs composite video (DAC A only) */
1801 # define TV_ENC_OUTPUT_COMPOSITE        (0 << 28)
1802 /** Outputs SVideo video (DAC B/C) */
1803 # define TV_ENC_OUTPUT_SVIDEO           (1 << 28)
1804 /** Outputs Component video (DAC A/B/C) */
1805 # define TV_ENC_OUTPUT_COMPONENT        (2 << 28)
1806 /** Outputs Composite and SVideo (DAC A/B/C) */
1807 # define TV_ENC_OUTPUT_SVIDEO_COMPOSITE (3 << 28)
1808 # define TV_TRILEVEL_SYNC               (1 << 21)
1809 /** Enables slow sync generation (945GM only) */
1810 # define TV_SLOW_SYNC                   (1 << 20)
1811 /** Selects 4x oversampling for 480i and 576p */
1812 # define TV_OVERSAMPLE_4X               (0 << 18)
1813 /** Selects 2x oversampling for 720p and 1080i */
1814 # define TV_OVERSAMPLE_2X               (1 << 18)
1815 /** Selects no oversampling for 1080p */
1816 # define TV_OVERSAMPLE_NONE             (2 << 18)
1817 /** Selects 8x oversampling */
1818 # define TV_OVERSAMPLE_8X               (3 << 18)
1819 /** Selects progressive mode rather than interlaced */
1820 # define TV_PROGRESSIVE                 (1 << 17)
1821 /** Sets the colorburst to PAL mode.  Required for non-M PAL modes. */
1822 # define TV_PAL_BURST                   (1 << 16)
1823 /** Field for setting delay of Y compared to C */
1824 # define TV_YC_SKEW_MASK                (7 << 12)
1825 /** Enables a fix for 480p/576p standard definition modes on the 915GM only */
1826 # define TV_ENC_SDP_FIX                 (1 << 11)
1827 /**
1828  * Enables a fix for the 915GM only.
1829  *
1830  * Not sure what it does.
1831  */
1832 # define TV_ENC_C0_FIX                  (1 << 10)
1833 /** Bits that must be preserved by software */
1834 # define TV_CTL_SAVE                    ((1 << 11) | (3 << 9) | (7 << 6) | 0xf)
1835 # define TV_FUSE_STATE_MASK             (3 << 4)
1836 /** Read-only state that reports all features enabled */
1837 # define TV_FUSE_STATE_ENABLED          (0 << 4)
1838 /** Read-only state that reports that Macrovision is disabled in hardware*/
1839 # define TV_FUSE_STATE_NO_MACROVISION   (1 << 4)
1840 /** Read-only state that reports that TV-out is disabled in hardware. */
1841 # define TV_FUSE_STATE_DISABLED         (2 << 4)
1842 /** Normal operation */
1843 # define TV_TEST_MODE_NORMAL            (0 << 0)
1844 /** Encoder test pattern 1 - combo pattern */
1845 # define TV_TEST_MODE_PATTERN_1         (1 << 0)
1846 /** Encoder test pattern 2 - full screen vertical 75% color bars */
1847 # define TV_TEST_MODE_PATTERN_2         (2 << 0)
1848 /** Encoder test pattern 3 - full screen horizontal 75% color bars */
1849 # define TV_TEST_MODE_PATTERN_3         (3 << 0)
1850 /** Encoder test pattern 4 - random noise */
1851 # define TV_TEST_MODE_PATTERN_4         (4 << 0)
1852 /** Encoder test pattern 5 - linear color ramps */
1853 # define TV_TEST_MODE_PATTERN_5         (5 << 0)
1854 /**
1855  * This test mode forces the DACs to 50% of full output.
1856  *
1857  * This is used for load detection in combination with TVDAC_SENSE_MASK
1858  */
1859 # define TV_TEST_MODE_MONITOR_DETECT    (7 << 0)
1860 # define TV_TEST_MODE_MASK              (7 << 0)
1861 /** @} */
1862
1863 /** @defgroup TV_DAC
1864  * @{
1865  */
1866 #define TV_DAC                  0x68004
1867 /**
1868  * Reports that DAC state change logic has reported change (RO).
1869  *
1870  * This gets cleared when TV_DAC_STATE_EN is cleared
1871 */
1872 # define TVDAC_STATE_CHG                (1 << 31)
1873 # define TVDAC_SENSE_MASK               (7 << 28)
1874 /** Reports that DAC A voltage is above the detect threshold */
1875 # define TVDAC_A_SENSE                  (1 << 30)
1876 /** Reports that DAC B voltage is above the detect threshold */
1877 # define TVDAC_B_SENSE                  (1 << 29)
1878 /** Reports that DAC C voltage is above the detect threshold */
1879 # define TVDAC_C_SENSE                  (1 << 28)
1880 /**
1881  * Enables DAC state detection logic, for load-based TV detection.
1882  *
1883  * The PLL of the chosen pipe (in TV_CTL) must be running, and the encoder set
1884  * to off, for load detection to work.
1885  */
1886 # define TVDAC_STATE_CHG_EN             (1 << 27)
1887 /** Sets the DAC A sense value to high */
1888 # define TVDAC_A_SENSE_CTL              (1 << 26)
1889 /** Sets the DAC B sense value to high */
1890 # define TVDAC_B_SENSE_CTL              (1 << 25)
1891 /** Sets the DAC C sense value to high */
1892 # define TVDAC_C_SENSE_CTL              (1 << 24)
1893 /** Overrides the ENC_ENABLE and DAC voltage levels */
1894 # define DAC_CTL_OVERRIDE               (1 << 7)
1895 /** Sets the slew rate.  Must be preserved in software */
1896 # define ENC_TVDAC_SLEW_FAST            (1 << 6)
1897 # define DAC_A_1_3_V                    (0 << 4)
1898 # define DAC_A_1_1_V                    (1 << 4)
1899 # define DAC_A_0_7_V                    (2 << 4)
1900 # define DAC_A_OFF                      (3 << 4)
1901 # define DAC_B_1_3_V                    (0 << 2)
1902 # define DAC_B_1_1_V                    (1 << 2)
1903 # define DAC_B_0_7_V                    (2 << 2)
1904 # define DAC_B_OFF                      (3 << 2)
1905 # define DAC_C_1_3_V                    (0 << 0)
1906 # define DAC_C_1_1_V                    (1 << 0)
1907 # define DAC_C_0_7_V                    (2 << 0)
1908 # define DAC_C_OFF                      (3 << 0)
1909 /** @} */
1910
1911 /**
1912  * CSC coefficients are stored in a floating point format with 9 bits of
1913  * mantissa and 2 or 3 bits of exponent.  The exponent is represented as 2**-n,
1914  * where 2-bit exponents are unsigned n, and 3-bit exponents are signed n with
1915  * -1 (0x3) being the only legal negative value.
1916  */
1917 #define TV_CSC_Y                0x68010
1918 # define TV_RY_MASK                     0x07ff0000
1919 # define TV_RY_SHIFT                    16
1920 # define TV_GY_MASK                     0x00000fff
1921 # define TV_GY_SHIFT                    0
1922
1923 #define TV_CSC_Y2               0x68014
1924 # define TV_BY_MASK                     0x07ff0000
1925 # define TV_BY_SHIFT                    16
1926 /**
1927  * Y attenuation for component video.
1928  *
1929  * Stored in 1.9 fixed point.
1930  */
1931 # define TV_AY_MASK                     0x000003ff
1932 # define TV_AY_SHIFT                    0
1933
1934 #define TV_CSC_U                0x68018
1935 # define TV_RU_MASK                     0x07ff0000
1936 # define TV_RU_SHIFT                    16
1937 # define TV_GU_MASK                     0x000007ff
1938 # define TV_GU_SHIFT                    0
1939
1940 #define TV_CSC_U2               0x6801c
1941 # define TV_BU_MASK                     0x07ff0000
1942 # define TV_BU_SHIFT                    16
1943 /**
1944  * U attenuation for component video.
1945  *
1946  * Stored in 1.9 fixed point.
1947  */
1948 # define TV_AU_MASK                     0x000003ff
1949 # define TV_AU_SHIFT                    0
1950
1951 #define TV_CSC_V                0x68020
1952 # define TV_RV_MASK                     0x0fff0000
1953 # define TV_RV_SHIFT                    16
1954 # define TV_GV_MASK                     0x000007ff
1955 # define TV_GV_SHIFT                    0
1956
1957 #define TV_CSC_V2               0x68024
1958 # define TV_BV_MASK                     0x07ff0000
1959 # define TV_BV_SHIFT                    16
1960 /**
1961  * V attenuation for component video.
1962  *
1963  * Stored in 1.9 fixed point.
1964  */
1965 # define TV_AV_MASK                     0x000007ff
1966 # define TV_AV_SHIFT                    0
1967
1968 /** @defgroup TV_CSC_KNOBS
1969  * @{
1970  */
1971 #define TV_CLR_KNOBS            0x68028
1972 /** 2s-complement brightness adjustment */
1973 # define TV_BRIGHTNESS_MASK             0xff000000
1974 # define TV_BRIGHTNESS_SHIFT            24
1975 /** Contrast adjustment, as a 2.6 unsigned floating point number */
1976 # define TV_CONTRAST_MASK               0x00ff0000
1977 # define TV_CONTRAST_SHIFT              16
1978 /** Saturation adjustment, as a 2.6 unsigned floating point number */
1979 # define TV_SATURATION_MASK             0x0000ff00
1980 # define TV_SATURATION_SHIFT            8
1981 /** Hue adjustment, as an integer phase angle in degrees */
1982 # define TV_HUE_MASK                    0x000000ff
1983 # define TV_HUE_SHIFT                   0
1984 /** @} */
1985
1986 /** @defgroup TV_CLR_LEVEL
1987  * @{
1988  */
1989 #define TV_CLR_LEVEL            0x6802c
1990 /** Controls the DAC level for black */
1991 # define TV_BLACK_LEVEL_MASK            0x01ff0000
1992 # define TV_BLACK_LEVEL_SHIFT           16
1993 /** Controls the DAC level for blanking */
1994 # define TV_BLANK_LEVEL_MASK            0x000001ff
1995 # define TV_BLANK_LEVEL_SHIFT           0
1996 /* @} */
1997
1998 /** @defgroup TV_H_CTL_1
1999  * @{
2000  */
2001 #define TV_H_CTL_1              0x68030
2002 /** Number of pixels in the hsync. */
2003 # define TV_HSYNC_END_MASK              0x1fff0000
2004 # define TV_HSYNC_END_SHIFT             16
2005 /** Total number of pixels minus one in the line (display and blanking). */
2006 # define TV_HTOTAL_MASK                 0x00001fff
2007 # define TV_HTOTAL_SHIFT                0
2008 /** @} */
2009
2010 /** @defgroup TV_H_CTL_2
2011  * @{
2012  */
2013 #define TV_H_CTL_2              0x68034
2014 /** Enables the colorburst (needed for non-component color) */
2015 # define TV_BURST_ENA                   (1 << 31)
2016 /** Offset of the colorburst from the start of hsync, in pixels minus one. */
2017 # define TV_HBURST_START_SHIFT          16
2018 # define TV_HBURST_START_MASK           0x1fff0000
2019 /** Length of the colorburst */
2020 # define TV_HBURST_LEN_SHIFT            0
2021 # define TV_HBURST_LEN_MASK             0x0001fff
2022 /** @} */
2023
2024 /** @defgroup TV_H_CTL_3
2025  * @{
2026  */
2027 #define TV_H_CTL_3              0x68038
2028 /** End of hblank, measured in pixels minus one from start of hsync */
2029 # define TV_HBLANK_END_SHIFT            16
2030 # define TV_HBLANK_END_MASK             0x1fff0000
2031 /** Start of hblank, measured in pixels minus one from start of hsync */
2032 # define TV_HBLANK_START_SHIFT          0
2033 # define TV_HBLANK_START_MASK           0x0001fff
2034 /** @} */
2035
2036 /** @defgroup TV_V_CTL_1
2037  * @{
2038  */
2039 #define TV_V_CTL_1              0x6803c
2040 /** XXX */
2041 # define TV_NBR_END_SHIFT               16
2042 # define TV_NBR_END_MASK                0x07ff0000
2043 /** XXX */
2044 # define TV_VI_END_F1_SHIFT             8
2045 # define TV_VI_END_F1_MASK              0x00003f00
2046 /** XXX */
2047 # define TV_VI_END_F2_SHIFT             0
2048 # define TV_VI_END_F2_MASK              0x0000003f
2049 /** @} */
2050
2051 /** @defgroup TV_V_CTL_2
2052  * @{
2053  */
2054 #define TV_V_CTL_2              0x68040
2055 /** Length of vsync, in half lines */
2056 # define TV_VSYNC_LEN_MASK              0x07ff0000
2057 # define TV_VSYNC_LEN_SHIFT             16
2058 /** Offset of the start of vsync in field 1, measured in one less than the
2059  * number of half lines.
2060  */
2061 # define TV_VSYNC_START_F1_MASK         0x00007f00
2062 # define TV_VSYNC_START_F1_SHIFT        8
2063 /**
2064  * Offset of the start of vsync in field 2, measured in one less than the
2065  * number of half lines.
2066  */
2067 # define TV_VSYNC_START_F2_MASK         0x0000007f
2068 # define TV_VSYNC_START_F2_SHIFT        0
2069 /** @} */
2070
2071 /** @defgroup TV_V_CTL_3
2072  * @{
2073  */
2074 #define TV_V_CTL_3              0x68044
2075 /** Enables generation of the equalization signal */
2076 # define TV_EQUAL_ENA                   (1 << 31)
2077 /** Length of vsync, in half lines */
2078 # define TV_VEQ_LEN_MASK                0x007f0000
2079 # define TV_VEQ_LEN_SHIFT               16
2080 /** Offset of the start of equalization in field 1, measured in one less than
2081  * the number of half lines.
2082  */
2083 # define TV_VEQ_START_F1_MASK           0x0007f00
2084 # define TV_VEQ_START_F1_SHIFT          8
2085 /**
2086  * Offset of the start of equalization in field 2, measured in one less than
2087  * the number of half lines.
2088  */
2089 # define TV_VEQ_START_F2_MASK           0x000007f
2090 # define TV_VEQ_START_F2_SHIFT          0
2091 /** @} */
2092
2093 /** @defgroup TV_V_CTL_4
2094  * @{
2095  */
2096 #define TV_V_CTL_4              0x68048
2097 /**
2098  * Offset to start of vertical colorburst, measured in one less than the
2099  * number of lines from vertical start.
2100  */
2101 # define TV_VBURST_START_F1_MASK        0x003f0000
2102 # define TV_VBURST_START_F1_SHIFT       16
2103 /**
2104  * Offset to the end of vertical colorburst, measured in one less than the
2105  * number of lines from the start of NBR.
2106  */
2107 # define TV_VBURST_END_F1_MASK          0x000000ff
2108 # define TV_VBURST_END_F1_SHIFT         0
2109 /** @} */
2110
2111 /** @defgroup TV_V_CTL_5
2112  * @{
2113  */
2114 #define TV_V_CTL_5              0x6804c
2115 /**
2116  * Offset to start of vertical colorburst, measured in one less than the
2117  * number of lines from vertical start.
2118  */
2119 # define TV_VBURST_START_F2_MASK        0x003f0000
2120 # define TV_VBURST_START_F2_SHIFT       16
2121 /**
2122  * Offset to the end of vertical colorburst, measured in one less than the
2123  * number of lines from the start of NBR.
2124  */
2125 # define TV_VBURST_END_F2_MASK          0x000000ff
2126 # define TV_VBURST_END_F2_SHIFT         0
2127 /** @} */
2128
2129 /** @defgroup TV_V_CTL_6
2130  * @{
2131  */
2132 #define TV_V_CTL_6              0x68050
2133 /**
2134  * Offset to start of vertical colorburst, measured in one less than the
2135  * number of lines from vertical start.
2136  */
2137 # define TV_VBURST_START_F3_MASK        0x003f0000
2138 # define TV_VBURST_START_F3_SHIFT       16
2139 /**
2140  * Offset to the end of vertical colorburst, measured in one less than the
2141  * number of lines from the start of NBR.
2142  */
2143 # define TV_VBURST_END_F3_MASK          0x000000ff
2144 # define TV_VBURST_END_F3_SHIFT         0
2145 /** @} */
2146
2147 /** @defgroup TV_V_CTL_7
2148  * @{
2149  */
2150 #define TV_V_CTL_7              0x68054
2151 /**
2152  * Offset to start of vertical colorburst, measured in one less than the
2153  * number of lines from vertical start.
2154  */
2155 # define TV_VBURST_START_F4_MASK        0x003f0000
2156 # define TV_VBURST_START_F4_SHIFT       16
2157 /**
2158  * Offset to the end of vertical colorburst, measured in one less than the
2159  * number of lines from the start of NBR.
2160  */
2161 # define TV_VBURST_END_F4_MASK          0x000000ff
2162 # define TV_VBURST_END_F4_SHIFT         0
2163 /** @} */
2164
2165 /** @defgroup TV_SC_CTL_1
2166  * @{
2167  */
2168 #define TV_SC_CTL_1             0x68060
2169 /** Turns on the first subcarrier phase generation DDA */
2170 # define TV_SC_DDA1_EN                  (1 << 31)
2171 /** Turns on the first subcarrier phase generation DDA */
2172 # define TV_SC_DDA2_EN                  (1 << 30)
2173 /** Turns on the first subcarrier phase generation DDA */
2174 # define TV_SC_DDA3_EN                  (1 << 29)
2175 /** Sets the subcarrier DDA to reset frequency every other field */
2176 # define TV_SC_RESET_EVERY_2            (0 << 24)
2177 /** Sets the subcarrier DDA to reset frequency every fourth field */
2178 # define TV_SC_RESET_EVERY_4            (1 << 24)
2179 /** Sets the subcarrier DDA to reset frequency every eighth field */
2180 # define TV_SC_RESET_EVERY_8            (2 << 24)
2181 /** Sets the subcarrier DDA to never reset the frequency */
2182 # define TV_SC_RESET_NEVER              (3 << 24)
2183 /** Sets the peak amplitude of the colorburst.*/
2184 # define TV_BURST_LEVEL_MASK            0x00ff0000
2185 # define TV_BURST_LEVEL_SHIFT           16
2186 /** Sets the increment of the first subcarrier phase generation DDA */
2187 # define TV_SCDDA1_INC_MASK             0x00000fff
2188 # define TV_SCDDA1_INC_SHIFT            0
2189 /** @} */
2190
2191 /** @defgroup TV_SC_CTL_2
2192  * @{
2193  */
2194 #define TV_SC_CTL_2             0x68064
2195 /** Sets the rollover for the second subcarrier phase generation DDA */
2196 # define TV_SCDDA2_SIZE_MASK            0x7fff0000
2197 # define TV_SCDDA2_SIZE_SHIFT           16
2198 /** Sets the increent of the second subcarrier phase generation DDA */
2199 # define TV_SCDDA2_INC_MASK             0x00007fff
2200 # define TV_SCDDA2_INC_SHIFT            0
2201 /** @} */
2202
2203 /** @defgroup TV_SC_CTL_3
2204  * @{
2205  */
2206 #define TV_SC_CTL_3             0x68068
2207 /** Sets the rollover for the third subcarrier phase generation DDA */
2208 # define TV_SCDDA3_SIZE_MASK            0x7fff0000
2209 # define TV_SCDDA3_SIZE_SHIFT           16
2210 /** Sets the increent of the third subcarrier phase generation DDA */
2211 # define TV_SCDDA3_INC_MASK             0x00007fff
2212 # define TV_SCDDA3_INC_SHIFT            0
2213 /** @} */
2214
2215 /** @defgroup TV_WIN_POS
2216  * @{
2217  */
2218 #define TV_WIN_POS              0x68070
2219 /** X coordinate of the display from the start of horizontal active */
2220 # define TV_XPOS_MASK                   0x1fff0000
2221 # define TV_XPOS_SHIFT                  16
2222 /** Y coordinate of the display from the start of vertical active (NBR) */
2223 # define TV_YPOS_MASK                   0x00000fff
2224 # define TV_YPOS_SHIFT                  0
2225 /** @} */
2226
2227 /** @defgroup TV_WIN_SIZE
2228  * @{
2229  */
2230 #define TV_WIN_SIZE             0x68074
2231 /** Horizontal size of the display window, measured in pixels*/
2232 # define TV_XSIZE_MASK                  0x1fff0000
2233 # define TV_XSIZE_SHIFT                 16
2234 /**
2235  * Vertical size of the display window, measured in pixels.
2236  *
2237  * Must be even for interlaced modes.
2238  */
2239 # define TV_YSIZE_MASK                  0x00000fff
2240 # define TV_YSIZE_SHIFT                 0
2241 /** @} */
2242
2243 /** @defgroup TV_FILTER_CTL_1
2244  * @{
2245  */
2246 #define TV_FILTER_CTL_1         0x68080
2247 /**
2248  * Enables automatic scaling calculation.
2249  *
2250  * If set, the rest of the registers are ignored, and the calculated values can
2251  * be read back from the register.
2252  */
2253 # define TV_AUTO_SCALE                  (1 << 31)
2254 /**
2255  * Disables the vertical filter.
2256  *
2257  * This is required on modes more than 1024 pixels wide */
2258 # define TV_V_FILTER_BYPASS             (1 << 29)
2259 /** Enables adaptive vertical filtering */
2260 # define TV_VADAPT                      (1 << 28)
2261 # define TV_VADAPT_MODE_MASK            (3 << 26)
2262 /** Selects the least adaptive vertical filtering mode */
2263 # define TV_VADAPT_MODE_LEAST           (0 << 26)
2264 /** Selects the moderately adaptive vertical filtering mode */
2265 # define TV_VADAPT_MODE_MODERATE        (1 << 26)
2266 /** Selects the most adaptive vertical filtering mode */
2267 # define TV_VADAPT_MODE_MOST            (3 << 26)
2268 /**
2269  * Sets the horizontal scaling factor.
2270  *
2271  * This should be the fractional part of the horizontal scaling factor divided
2272  * by the oversampling rate.  TV_HSCALE should be less than 1, and set to:
2273  *
2274  * (src width - 1) / ((oversample * dest width) - 1)
2275  */
2276 # define TV_HSCALE_FRAC_MASK            0x00003fff
2277 # define TV_HSCALE_FRAC_SHIFT           0
2278 /** @} */
2279
2280 /** @defgroup TV_FILTER_CTL_2
2281  * @{
2282  */
2283 #define TV_FILTER_CTL_2         0x68084
2284 /**
2285  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
2286  *
2287  * TV_VSCALE should be (src height - 1) / ((interlace * dest height) - 1)
2288  */
2289 # define TV_VSCALE_INT_MASK             0x00038000
2290 # define TV_VSCALE_INT_SHIFT            15
2291 /**
2292  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
2293  *
2294  * \sa TV_VSCALE_INT_MASK
2295  */
2296 # define TV_VSCALE_FRAC_MASK            0x00007fff
2297 # define TV_VSCALE_FRAC_SHIFT           0
2298 /** @} */
2299
2300 /** @defgroup TV_FILTER_CTL_3
2301  * @{
2302  */
2303 #define TV_FILTER_CTL_3         0x68088
2304 /**
2305  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
2306  *
2307  * TV_VSCALE should be (src height - 1) / (1/4 * (dest height - 1))
2308  *
2309  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
2310  */
2311 # define TV_VSCALE_IP_INT_MASK          0x00038000
2312 # define TV_VSCALE_IP_INT_SHIFT         15
2313 /**
2314  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
2315  *
2316  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
2317  *
2318  * \sa TV_VSCALE_IP_INT_MASK
2319  */
2320 # define TV_VSCALE_IP_FRAC_MASK         0x00007fff
2321 # define TV_VSCALE_IP_FRAC_SHIFT                0
2322 /** @} */
2323
2324 /** @defgroup TV_CC_CONTROL
2325  * @{
2326  */
2327 #define TV_CC_CONTROL           0x68090
2328 # define TV_CC_ENABLE                   (1 << 31)
2329 /**
2330  * Specifies which field to send the CC data in.
2331  *
2332  * CC data is usually sent in field 0.
2333  */
2334 # define TV_CC_FID_MASK                 (1 << 27)
2335 # define TV_CC_FID_SHIFT                27
2336 /** Sets the horizontal position of the CC data.  Usually 135. */
2337 # define TV_CC_HOFF_MASK                0x03ff0000
2338 # define TV_CC_HOFF_SHIFT               16
2339 /** Sets the vertical position of the CC data.  Usually 21 */
2340 # define TV_CC_LINE_MASK                0x0000003f
2341 # define TV_CC_LINE_SHIFT               0
2342 /** @} */
2343
2344 /** @defgroup TV_CC_DATA
2345  * @{
2346  */
2347 #define TV_CC_DATA              0x68094
2348 # define TV_CC_RDY                      (1 << 31)
2349 /** Second word of CC data to be transmitted. */
2350 # define TV_CC_DATA_2_MASK              0x007f0000
2351 # define TV_CC_DATA_2_SHIFT             16
2352 /** First word of CC data to be transmitted. */
2353 # define TV_CC_DATA_1_MASK              0x0000007f
2354 # define TV_CC_DATA_1_SHIFT             0
2355 /** @}
2356  */
2357
2358 /** @{ */
2359 #define TV_H_LUMA_0             0x68100
2360 #define TV_H_LUMA_59            0x681ec
2361 #define TV_H_CHROMA_0           0x68200
2362 #define TV_H_CHROMA_59          0x682ec
2363 #define TV_V_LUMA_0             0x68300
2364 #define TV_V_LUMA_42            0x683a8
2365 #define TV_V_CHROMA_0           0x68400
2366 #define TV_V_CHROMA_42          0x684a8
2367 /** @} */
2368
2369 #define PIPEA_DSL               0x70000
2370
2371 #define PIPEACONF 0x70008
2372 #define PIPEACONF_ENABLE        (1<<31)
2373 #define PIPEACONF_DISABLE       0
2374 #define PIPEACONF_DOUBLE_WIDE   (1<<30)
2375 #define I965_PIPECONF_ACTIVE    (1<<30)
2376 #define PIPEACONF_SINGLE_WIDE   0
2377 #define PIPEACONF_PIPE_UNLOCKED 0
2378 #define PIPEACONF_PIPE_LOCKED   (1<<25)
2379 #define PIPEACONF_PALETTE       0
2380 #define PIPEACONF_GAMMA         (1<<24)
2381 #define PIPECONF_FORCE_BORDER   (1<<25)
2382 #define PIPECONF_PROGRESSIVE    (0 << 21)
2383 #define PIPECONF_INTERLACE_W_FIELD_INDICATION   (6 << 21)
2384 #define PIPECONF_INTERLACE_FIELD_0_ONLY         (7 << 21)
2385 /* ironlake: gamma */
2386 #define PIPECONF_PALETTE_8BIT   (0<<24)
2387 #define PIPECONF_PALETTE_10BIT  (1<<24)
2388 #define PIPECONF_PALETTE_12BIT  (2<<24)
2389 #define PIPECONF_FORCE_BORDER   (1<<25)
2390 #define PIPECONF_PROGRESSIVE    (0 << 21)
2391 #define PIPECONF_INTERLACE_W_FIELD_INDICATION   (6 << 21)
2392 #define PIPECONF_INTERLACE_FIELD_0_ONLY         (7 << 21)
2393 /* ironlake */
2394 #define PIPECONF_MSA_TIMING_DELAY       (0<<18) /* for eDP */
2395 #define PIPECONF_NO_DYNAMIC_RATE_CHANGE (0 << 16)
2396 #define PIPECONF_NO_ROTATION            (0<<14)
2397 #define PIPECONF_FULL_COLOR_RANGE       (0<<13)
2398 #define PIPECONF_CE_COLOR_RANGE         (1<<13)
2399 #define PIPECONF_COLOR_SPACE_RGB        (0<<11)
2400 #define PIPECONF_COLOR_SPACE_YUV601     (1<<11)
2401 #define PIPECONF_COLOR_SPACE_YUV709     (2<<11)
2402 #define PIPECONF_CONNECT_DEFAULT        (0<<9)
2403 #define PIPECONF_8BPP                   (0<<5)
2404 #define PIPECONF_10BPP                  (1<<5)
2405 #define PIPECONF_6BPP                   (2<<5)
2406 #define PIPECONF_12BPP                  (3<<5)
2407 #define PIPECONF_ENABLE_DITHER          (1<<4)
2408 #define PIPECONF_DITHER_SPATIAL         (0<<2)
2409 #define PIPECONF_DITHER_ST1             (1<<2)
2410 #define PIPECONF_DITHER_ST2             (2<<2)
2411 #define PIPECONF_DITHER_TEMPORAL        (3<<2)
2412
2413 #define PIPEAGCMAXRED           0x70010
2414 #define PIPEAGCMAXGREEN         0x70014
2415 #define PIPEAGCMAXBLUE          0x70018
2416 #define PIPEASTAT               0x70024
2417 # define FIFO_UNDERRUN          (1 << 31)
2418 # define CRC_ERROR_ENABLE       (1 << 29)
2419 # define CRC_DONE_ENABLE        (1 << 28)
2420 # define GMBUS_EVENT_ENABLE     (1 << 27)
2421 # define VSYNC_INT_ENABLE       (1 << 25)
2422 # define DLINE_COMPARE_ENABLE   (1 << 24)
2423 # define DPST_EVENT_ENABLE      (1 << 23)
2424 # define LBLC_EVENT_ENABLE      (1 << 22)
2425 # define OFIELD_INT_ENABLE      (1 << 21)
2426 # define EFIELD_INT_ENABLE      (1 << 20)
2427 # define SVBLANK_INT_ENABLE     (1 << 18)
2428 # define VBLANK_INT_ENABLE      (1 << 17)
2429 # define OREG_UPDATE_ENABLE     (1 << 16)
2430 # define CRC_ERROR_INT_STATUS   (1 << 13)
2431 # define CRC_DONE_INT_STATUS    (1 << 12)
2432 # define GMBUS_INT_STATUS       (1 << 11)
2433 # define VSYNC_INT_STATUS       (1 << 9)
2434 # define DLINE_COMPARE_STATUS   (1 << 8)
2435 # define DPST_EVENT_STATUS      (1 << 7)
2436 # define LBLC_EVENT_STATUS      (1 << 6)
2437 # define OFIELD_INT_STATUS      (1 << 5)
2438 # define EFIELD_INT_STATUS      (1 << 4)
2439 # define SVBLANK_INT_STATUS     (1 << 2)
2440 # define VBLANK_INT_STATUS      (1 << 1)
2441 # define OREG_UPDATE_STATUS     (1 << 0)
2442                                  
2443
2444 #define DSPARB                  0x70030
2445 #define   DSPARB_CSTART_SHIFT   7
2446 #define   DSPARB_BSTART_SHIFT   0
2447 #define   DSPARB_BEND_SHIFT     9 /* on 855 */
2448 #define   DSPARB_AEND_SHIFT     0
2449 #define DSPFW1                  0x70034
2450 #define DSPFW2                  0x70038
2451 #define DSPFW3                  0x7003c
2452 /*
2453  * The two pipe frame counter registers are not synchronized, so
2454  * reading a stable value is somewhat tricky. The following code 
2455  * should work:
2456  *
2457  *  do {
2458  *    high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >> PIPE_FRAME_HIGH_SHIFT;
2459  *    low1 =  ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >> PIPE_FRAME_LOW_SHIFT);
2460  *    high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >> PIPE_FRAME_HIGH_SHIFT);
2461  *  } while (high1 != high2);
2462  *  frame = (high1 << 8) | low1;
2463  */
2464 #define PIPEAFRAMEHIGH          0x70040
2465 #define PIPE_FRAME_HIGH_MASK    0x0000ffff
2466 #define PIPE_FRAME_HIGH_SHIFT   0
2467 #define PIPEAFRAMEPIXEL         0x70044
2468 #define PIPE_FRAME_LOW_MASK     0xff000000
2469 #define PIPE_FRAME_LOW_SHIFT    24
2470 /*
2471  * Pixel within the current frame is counted in the PIPEAFRAMEPIXEL register
2472  * and is 24 bits wide.
2473  */
2474 #define PIPE_PIXEL_MASK         0x00ffffff
2475 #define PIPE_PIXEL_SHIFT        0
2476
2477 /*
2478  * Computing GMCH M and N values.
2479  *
2480  * GMCH M/N = dot clock * bytes per pixel / ls_clk * # of lanes
2481  *
2482  * ls_clk (we assume) is the DP link clock (1.62 or 2.7 GHz)
2483  *
2484  * The GMCH value is used internally
2485  */
2486 #define PIPEA_GMCH_DATA_M       0x70050
2487
2488 /* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */
2489 #define PIPE_GMCH_DATA_M_TU_SIZE_MASK   (0x3f << 25)
2490 #define PIPE_GMCH_DATA_M_TU_SIZE_SHIFT  25
2491
2492 #define PIPE_GMCH_DATA_M_MASK           (0xffffff)
2493
2494 #define PIPEA_GMCH_DATA_N       0x70054
2495 #define PIPE_GMCH_DATA_N_MASK           (0xffffff)
2496
2497 /*
2498  * Computing Link M and N values.
2499  *
2500  * Link M / N = pixel_clock / ls_clk
2501  *
2502  * (the DP spec calls pixel_clock the 'strm_clk')
2503  *
2504  * The Link value is transmitted in the Main Stream
2505  * Attributes and VB-ID.
2506  */
2507
2508 #define PIPEA_DP_LINK_M         0x70060
2509 #define PIPEA_DP_LINK_M_MASK    (0xffffff)
2510
2511 #define PIPEA_DP_LINK_N         0x70064
2512 #define PIPEA_DP_LINK_N_MASK    (0xffffff)
2513
2514 #define PIPEB_DSL               0x71000
2515
2516 #define PIPEBCONF               0x71008
2517
2518 #define PIPEBGCMAXRED           0x71010
2519 #define PIPEBGCMAXGREEN         0x71014
2520 #define PIPEBGCMAXBLUE          0x71018
2521 #define PIPEBSTAT               0x71024
2522 #define PIPEBFRAMEHIGH          0x71040
2523 #define PIPEBFRAMEPIXEL         0x71044
2524
2525 #define PIPEB_GMCH_DATA_M       0x71050
2526 #define PIPEB_GMCH_DATA_N       0x71054
2527 #define PIPEB_DP_LINK_M         0x71060
2528 #define PIPEB_DP_LINK_N         0x71064
2529
2530 #define PIPECCONF               0x72008
2531
2532 #define PIPECGCMAXRED           0x72010
2533 #define PIPECGCMAXGREEN         0x72014
2534 #define PIPECGCMAXBLUE          0x72018
2535 #define PIPECSTAT               0x72024
2536 #define PIPECFRAMEHIGH          0x72040
2537 #define PIPECFRAMEPIXEL         0x72044
2538
2539 #define PIPEC_GMCH_DATA_M       0x72050
2540 #define PIPEC_GMCH_DATA_N       0x72054
2541 #define PIPEC_DP_LINK_M         0x72060
2542 #define PIPEC_DP_LINK_N         0x72064
2543
2544 #define DSPACNTR                0x70180
2545 #define DSPBCNTR                0x71180
2546 #define DSPCCNTR                0x72180
2547 #define DISPLAY_PLANE_ENABLE                    (1<<31)
2548 #define DISPLAY_PLANE_DISABLE                   0
2549 #define DISPLAY_PLANE_TILED                     (1<<10)
2550 #define DISPPLANE_GAMMA_ENABLE                  (1<<30)
2551 #define DISPPLANE_GAMMA_DISABLE                 0
2552 #define DISPPLANE_PIXFORMAT_MASK                (0xf<<26)
2553 #define DISPPLANE_8BPP                          (0x2<<26)
2554 #define DISPPLANE_15_16BPP                      (0x4<<26)
2555 #define DISPPLANE_16BPP                         (0x5<<26)
2556 #define DISPPLANE_32BPP_NO_ALPHA                (0x6<<26)
2557 #define DISPPLANE_32BPP                         (0x7<<26)
2558 #define DISPPLANE_STEREO_ENABLE                 (1<<25)
2559 #define DISPPLANE_STEREO_DISABLE                0
2560 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
2561 #define DISPPLANE_SEL_PIPE_A                    0
2562 #define DISPPLANE_SEL_PIPE_B                    (1<<24)
2563 #define DISPPLANE_SRC_KEY_ENABLE                (1<<22)
2564 #define DISPPLANE_SRC_KEY_DISABLE               0
2565 #define DISPPLANE_LINE_DOUBLE                   (1<<20)
2566 #define DISPPLANE_NO_LINE_DOUBLE                0
2567 #define DISPPLANE_STEREO_POLARITY_FIRST         0
2568 #define DISPPLANE_STEREO_POLARITY_SECOND        (1<<18)
2569 /* plane B only */
2570 #define DISPPLANE_ALPHA_TRANS_ENABLE            (1<<15)
2571 #define DISPPLANE_ALPHA_TRANS_DISABLE           0
2572 #define DISPPLANE_SPRITE_ABOVE_DISPLAYA         0
2573 #define DISPPLANE_SPRITE_ABOVE_OVERLAY          (1)
2574
2575 #define DSPABASE                0x70184
2576 #define DSPASTRIDE              0x70188
2577
2578 #define DSPBBASE                0x71184
2579 #define DSPBADDR                DSPBBASE
2580 #define DSPBSTRIDE              0x71188
2581
2582 #define DSPCBASE                0x72184
2583 #define DSPCADDR                DSPCBASE
2584 #define DSPCSTRIDE              0x72188
2585
2586 #define DSPAKEYVAL              0x70194
2587 #define DSPAKEYMASK             0x70198
2588
2589 #define DSPAPOS                 0x7018C /* reserved */
2590 #define DSPASIZE                0x70190
2591 #define DSPBPOS                 0x7118C
2592 #define DSPBSIZE                0x71190
2593
2594 #define DSPASURF                0x7019C
2595 #define DSPATILEOFF             0x701A4
2596
2597 #define DSPBSURF                0x7119C
2598 #define DSPBTILEOFF             0x711A4
2599
2600 #define DSPCSURF                0x7219C
2601 #define DSPCTILEOFF             0x721A4
2602
2603 #define VGACNTRL                0x71400
2604 # define VGA_DISP_DISABLE                       (1 << 31)
2605 # define VGA_2X_MODE                            (1 << 30)
2606 # define VGA_PIPE_B_SELECT                      (1 << 29)
2607
2608 /* Various masks for reserved bits, etc. */
2609 #define I830_FWATER1_MASK        (~((1<<11)|(1<<10)|(1<<9)|      \
2610         (1<<8)|(1<<26)|(1<<25)|(1<<24)|(1<<5)|(1<<4)|(1<<3)|    \
2611         (1<<2)|(1<<1)|1|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)))
2612 #define I830_FWATER2_MASK ~(0)
2613
2614 #define DV0A_RESERVED ((1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1)
2615 #define DV0B_RESERVED ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1)
2616 #define VGA0_N_DIVISOR_MASK     ((1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
2617 #define VGA0_M1_DIVISOR_MASK    ((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8))
2618 #define VGA0_M2_DIVISOR_MASK    ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
2619 #define VGA0_M1M2N_RESERVED     ~(VGA0_N_DIVISOR_MASK|VGA0_M1_DIVISOR_MASK|VGA0_M2_DIVISOR_MASK)
2620 #define VGA0_POSTDIV_MASK       ((1<<7)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
2621 #define VGA1_POSTDIV_MASK       ((1<<15)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8))
2622 #define VGA_POSTDIV_RESERVED    ~(VGA0_POSTDIV_MASK|VGA1_POSTDIV_MASK|(1<<7)|(1<<15))
2623 #define DPLLA_POSTDIV_MASK ((1<<23)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
2624 #define DPLLA_RESERVED     ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<22)|(1<<15)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
2625 #define ADPA_RESERVED   ((1<<2)|(1<<1)|1|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
2626 #define SUPER_WORD              32
2627 #define BURST_A_MASK    ((1<<11)|(1<<10)|(1<<9)|(1<<8))
2628 #define BURST_B_MASK    ((1<<26)|(1<<25)|(1<<24))
2629 #define WATER_A_MASK    ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
2630 #define WATER_B_MASK    ((1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
2631 #define WATER_RESERVED  ((1<<31)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<7)|(1<<6))
2632 #define PIPEACONF_RESERVED ((1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff)
2633 #define PIPEBCONF_RESERVED ((1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff)
2634 #define DSPACNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0xffff)
2635 #define DSPBCNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0x7ffe)
2636
2637 #define I830_GMCH_CTRL          0x52
2638
2639 #define I830_GMCH_ENABLED       0x4
2640 #define I830_GMCH_MEM_MASK      0x1
2641 #define I830_GMCH_MEM_64M       0x1
2642 #define I830_GMCH_MEM_128M      0
2643
2644 #define I830_GMCH_GMS_MASK                      0x70
2645 #define I830_GMCH_GMS_DISABLED                  0x00
2646 #define I830_GMCH_GMS_LOCAL                     0x10
2647 #define I830_GMCH_GMS_STOLEN_512                0x20
2648 #define I830_GMCH_GMS_STOLEN_1024               0x30
2649 #define I830_GMCH_GMS_STOLEN_8192               0x40
2650
2651 #define I830_RDRAM_CHANNEL_TYPE         0x03010
2652 #define I830_RDRAM_ND(x)                        (((x) & 0x20) >> 5)
2653 #define I830_RDRAM_DDT(x)                       (((x) & 0x18) >> 3)
2654
2655 #define I855_GMCH_GMS_MASK                      (0xF << 4)
2656 #define I855_GMCH_GMS_DISABLED                  0x00
2657 #define I855_GMCH_GMS_STOLEN_1M                 (0x1 << 4)
2658 #define I855_GMCH_GMS_STOLEN_4M                 (0x2 << 4)
2659 #define I855_GMCH_GMS_STOLEN_8M                 (0x3 << 4)
2660 #define I855_GMCH_GMS_STOLEN_16M                (0x4 << 4)
2661 #define I855_GMCH_GMS_STOLEN_32M                (0x5 << 4)
2662 #define I915G_GMCH_GMS_STOLEN_48M               (0x6 << 4)
2663 #define I915G_GMCH_GMS_STOLEN_64M               (0x7 << 4)
2664 #define G33_GMCH_GMS_STOLEN_128M                (0x8 << 4)
2665 #define G33_GMCH_GMS_STOLEN_256M                (0x9 << 4)
2666 #define INTEL_GMCH_GMS_STOLEN_96M               (0xa << 4)
2667 #define INTEL_GMCH_GMS_STOLEN_160M              (0xb << 4)
2668 #define INTEL_GMCH_GMS_STOLEN_224M              (0xc << 4)
2669 #define INTEL_GMCH_GMS_STOLEN_352M              (0xd << 4)
2670
2671
2672 #define I85X_CAPID                      0x44
2673 #define I85X_VARIANT_MASK                       0x7
2674 #define I85X_VARIANT_SHIFT                      5
2675 #define I855_GME                                0x0
2676 #define I855_GM                                 0x4
2677 #define I852_GME                                0x2
2678 #define I852_GM                                 0x5
2679
2680 #define I915_GCFGC                      0xf0
2681 #define I915_LOW_FREQUENCY_ENABLE               (1 << 7)
2682 #define I915_DISPLAY_CLOCK_190_200_MHZ          (0 << 4)
2683 #define I915_DISPLAY_CLOCK_333_MHZ              (4 << 4)
2684 #define I915_DISPLAY_CLOCK_MASK                 (7 << 4)
2685
2686 #define I855_HPLLCC                     0xc0
2687 #define I855_CLOCK_CONTROL_MASK                 (3 << 0)
2688 #define I855_CLOCK_133_200                      (0 << 0)
2689 #define I855_CLOCK_100_200                      (1 << 0)
2690 #define I855_CLOCK_100_133                      (2 << 0)
2691 #define I855_CLOCK_166_250                      (3 << 0)
2692
2693 /* BLT commands */
2694 #define COLOR_BLT_CMD           ((2<<29)|(0x40<<22)|(0x3))
2695 #define COLOR_BLT_WRITE_ALPHA   (1<<21)
2696 #define COLOR_BLT_WRITE_RGB     (1<<20)
2697
2698 #define XY_COLOR_BLT_CMD                ((2<<29)|(0x50<<22)|(0x4))
2699 #define XY_COLOR_BLT_WRITE_ALPHA        (1<<21)
2700 #define XY_COLOR_BLT_WRITE_RGB          (1<<20)
2701 #define XY_COLOR_BLT_TILED              (1<<11)
2702
2703 #define XY_SETUP_CLIP_BLT_CMD           ((2<<29)|(3<<22)|1)
2704
2705 #define XY_SRC_COPY_BLT_CMD             ((2<<29)|(0x53<<22)|6)
2706 #define XY_SRC_COPY_BLT_WRITE_ALPHA     (1<<21)
2707 #define XY_SRC_COPY_BLT_WRITE_RGB       (1<<20)
2708 #define XY_SRC_COPY_BLT_SRC_TILED       (1<<15)
2709 #define XY_SRC_COPY_BLT_DST_TILED       (1<<11)
2710
2711 #define SRC_COPY_BLT_CMD                ((2<<29)|(0x43<<22)|0x4)
2712 #define SRC_COPY_BLT_WRITE_ALPHA        (1<<21)
2713 #define SRC_COPY_BLT_WRITE_RGB          (1<<20)
2714
2715 #define XY_PAT_BLT_IMMEDIATE            ((2<<29)|(0x72<<22))
2716
2717 #define XY_MONO_PAT_BLT_CMD             ((0x2<<29)|(0x52<<22)|0x7)
2718 #define XY_MONO_PAT_VERT_SEED           ((1<<10)|(1<<9)|(1<<8))
2719 #define XY_MONO_PAT_HORT_SEED           ((1<<14)|(1<<13)|(1<<12))
2720 #define XY_MONO_PAT_BLT_WRITE_ALPHA     (1<<21)
2721 #define XY_MONO_PAT_BLT_WRITE_RGB       (1<<20)
2722
2723 #define XY_MONO_SRC_BLT_CMD             ((0x2<<29)|(0x54<<22)|(0x6))
2724 #define XY_MONO_SRC_BLT_WRITE_ALPHA     (1<<21)
2725 #define XY_MONO_SRC_BLT_WRITE_RGB       (1<<20)
2726
2727 #define MI_STORE_DWORD_IMM              ((0x20<<23)|2)
2728 #define   MI_MEM_VIRTUAL        (1 << 22) /* 965+ only */
2729
2730 #define MI_SET_CONTEXT                  (0x18<<23)
2731 #define CTXT_NO_RESTORE                 (1)
2732 #define CTXT_PALETTE_SAVE_DISABLE       (1<<3)
2733 #define CTXT_PALETTE_RESTORE_DISABLE    (1<<2)
2734
2735 /* Dword 0 */
2736 #define MI_VERTEX_BUFFER                (0x17<<23)
2737 #define MI_VERTEX_BUFFER_IDX(x)         (x<<20)
2738 #define MI_VERTEX_BUFFER_PITCH(x)       (x<<13)
2739 #define MI_VERTEX_BUFFER_WIDTH(x)       (x<<6)
2740 /* Dword 1 */
2741 #define MI_VERTEX_BUFFER_DISABLE        (1)
2742
2743 /* Overlay Flip */
2744 #define MI_OVERLAY_FLIP                 (0x11<<23)
2745 #define MI_OVERLAY_FLIP_CONTINUE        (0<<21)
2746 #define MI_OVERLAY_FLIP_ON              (1<<21)
2747 #define MI_OVERLAY_FLIP_OFF             (2<<21)
2748
2749 /* Wait for Events */
2750 #define MI_WAIT_FOR_EVENT               (0x03<<23)
2751 #define MI_WAIT_FOR_PIPEB_SVBLANK       (1<<18)
2752 #define MI_WAIT_FOR_PIPEA_SVBLANK       (1<<17)
2753 #define MI_WAIT_FOR_OVERLAY_FLIP        (1<<16)
2754 #define MI_WAIT_FOR_PIPEB_VBLANK        (1<<7)
2755 #define MI_WAIT_FOR_PIPEA_VBLANK        (1<<3)
2756 #define MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW      (1<<5)
2757 #define MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW      (1<<1)
2758
2759 #define MI_LOAD_SCAN_LINES_INCL         (0x12<<23)
2760
2761 /* Flush */
2762 #define MI_FLUSH                        (0x04<<23)
2763 #define MI_WRITE_DIRTY_STATE            (1<<4)
2764 #define MI_END_SCENE                    (1<<3)
2765 #define MI_GLOBAL_SNAPSHOT_COUNT_RESET  (1<<3)
2766 #define MI_INHIBIT_RENDER_CACHE_FLUSH   (1<<2)
2767 #define MI_STATE_INSTRUCTION_CACHE_FLUSH (1<<1)
2768 #define MI_INVALIDATE_MAP_CACHE         (1<<0)
2769 /* broadwater flush bits */
2770 #define BRW_MI_GLOBAL_SNAPSHOT_RESET   (1 << 3)
2771
2772 /* Noop */
2773 #define MI_NOOP                         0x00
2774 #define MI_NOOP_WRITE_ID                (1<<22)
2775 #define MI_NOOP_ID_MASK                 (1<<22 - 1)
2776
2777 #define STATE3D_COLOR_FACTOR    ((0x3<<29)|(0x1d<<24)|(0x01<<16))
2778
2779 /* Batch */
2780 #define MI_BATCH_BUFFER         ((0x30 << 23) | 1)
2781 #define MI_BATCH_BUFFER_START   (0x31 << 23)
2782 #define MI_BATCH_BUFFER_END     (0xA << 23)
2783 #define MI_BATCH_NON_SECURE             (1)
2784 #define MI_BATCH_NON_SECURE_I965        (1 << 8)
2785
2786 #define MAX_DISPLAY_PIPES       2
2787
2788 typedef enum {
2789    CrtIndex = 0,
2790    TvIndex,
2791    DfpIndex,
2792    LfpIndex,
2793    Crt2Index,
2794    Tv2Index,
2795    Dfp2Index,
2796    Lfp2Index,
2797    NumDisplayTypes
2798 } DisplayType;
2799
2800 /* What's connected to the pipes (as reported by the BIOS) */
2801 #define PIPE_ACTIVE_MASK                0xff
2802 #define PIPE_CRT_ACTIVE                 (1 << CrtIndex)
2803 #define PIPE_TV_ACTIVE                  (1 << TvIndex)
2804 #define PIPE_DFP_ACTIVE                 (1 << DfpIndex)
2805 #define PIPE_LCD_ACTIVE                 (1 << LfpIndex)
2806 #define PIPE_CRT2_ACTIVE                (1 << Crt2Index)
2807 #define PIPE_TV2_ACTIVE                 (1 << Tv2Index)
2808 #define PIPE_DFP2_ACTIVE                (1 << Dfp2Index)
2809 #define PIPE_LCD2_ACTIVE                (1 << Lfp2Index)
2810
2811 #define PIPE_SIZED_DISP_MASK            (PIPE_DFP_ACTIVE |      \
2812                                          PIPE_LCD_ACTIVE |      \
2813                                          PIPE_DFP2_ACTIVE)
2814
2815 #define PIPE_A_SHIFT                    0
2816 #define PIPE_B_SHIFT                    8
2817 #define PIPE_SHIFT(n)                   ((n) == 0 ? \
2818                                          PIPE_A_SHIFT : PIPE_B_SHIFT)
2819
2820 /*
2821  * Some BIOS scratch area registers.  The 845 (and 830?) store the amount
2822  * of video memory available to the BIOS in SWF1.
2823  */
2824
2825 #define SWF0                    0x71410
2826 #define SWF1                    0x71414
2827 #define SWF2                    0x71418
2828 #define SWF3                    0x7141c
2829 #define SWF4                    0x71420
2830 #define SWF5                    0x71424
2831 #define SWF6                    0x71428
2832
2833 /*
2834  * 855 scratch registers.
2835  */
2836 #define SWF00                   0x70410
2837 #define SWF01                   0x70414
2838 #define SWF02                   0x70418
2839 #define SWF03                   0x7041c
2840 #define SWF04                   0x70420
2841 #define SWF05                   0x70424
2842 #define SWF06                   0x70428
2843
2844 #define SWF10                   SWF0
2845 #define SWF11                   SWF1
2846 #define SWF12                   SWF2
2847 #define SWF13                   SWF3
2848 #define SWF14                   SWF4
2849 #define SWF15                   SWF5
2850 #define SWF16                   SWF6
2851
2852 #define SWF30                   0x72414
2853 #define SWF31                   0x72418
2854 #define SWF32                   0x7241c
2855
2856 /*
2857  * Overlay registers.  These are overlay registers accessed via MMIO.
2858  * Those loaded via the overlay register page are defined in i830_video.c.
2859  */
2860 #define OVADD                   0x30000
2861
2862 #define DOVSTA                  0x30008
2863 #define OC_BUF                  (0x3<<20)
2864
2865 #define OGAMC5                  0x30010
2866 #define OGAMC4                  0x30014
2867 #define OGAMC3                  0x30018
2868 #define OGAMC2                  0x3001c
2869 #define OGAMC1                  0x30020
2870 #define OGAMC0                  0x30024
2871
2872
2873 /*
2874  * Palette registers
2875  */
2876 #define PALETTE_A               0x0a000
2877 #define PALETTE_B               0x0a800
2878
2879 /* Framebuffer compression */
2880 #define FBC_CFB_BASE            0x03200 /* 4k page aligned */
2881 #define FBC_LL_BASE             0x03204 /* 4k page aligned */
2882 #define FBC_CONTROL             0x03208
2883 #define   FBC_CTL_EN            (1<<31)
2884 #define   FBC_CTL_PERIODIC      (1<<30)
2885 #define   FBC_CTL_INTERVAL_SHIFT (16)
2886 #define   FBC_CTL_UNCOMPRESSIBLE (1<<14)
2887 #define   FBC_CTL_STRIDE_SHIFT  (5)
2888 #define   FBC_CTL_FENCENO       (1<<0)
2889 #define FBC_COMMAND             0x0320c
2890 #define   FBC_CMD_COMPRESS      (1<<0)
2891 #define FBC_STATUS              0x03210
2892 #define   FBC_STAT_COMPRESSING  (1<<31)
2893 #define   FBC_STAT_COMPRESSED   (1<<30)
2894 #define   FBC_STAT_MODIFIED     (1<<29)
2895 #define   FBC_STAT_CURRENT_LINE (1<<0)
2896 #define FBC_CONTROL2            0x03214
2897 #define   FBC_CTL_FENCE_DBL     (0<<4)
2898 #define   FBC_CTL_IDLE_IMM      (0<<2)
2899 #define   FBC_CTL_IDLE_FULL     (1<<2)
2900 #define   FBC_CTL_IDLE_LINE     (2<<2)
2901 #define   FBC_CTL_IDLE_DEBUG    (3<<2)
2902 #define   FBC_CTL_CPU_FENCE     (1<<1)
2903 #define   FBC_CTL_PLANEA        (0<<0)
2904 #define   FBC_CTL_PLANEB        (1<<0)
2905 #define FBC_FENCE_OFF           0x0321b
2906 #define FBC_MOD_NUM             0x03220
2907 #define FBC_TAG_DEBUG           0x03300
2908
2909 #define FBC_LL_SIZE             (1536)
2910 #define FBC_LL_PAD              (32)
2911
2912 /* Framebuffer compression version 2 */
2913 #define DPFC_CB_BASE            0x3200
2914 #define DPFC_CONTROL            0x3208
2915 #define   DPFC_CTL_EN           (1<<31)
2916 #define   DPFC_CTL_PLANEA       (0<<30)
2917 #define   DPFC_CTL_PLANEB       (1<<30)
2918 #define   DPFC_CTL_FENCE_EN     (1<<29)
2919 #define   DPFC_CTL_LIMIT_1X     (0<<6)
2920 #define   DPFC_CTL_LIMIT_2X     (1<<6)
2921 #define   DPFC_CTL_LIMIT_4X     (2<<6)
2922 #define DPFC_RECOMP_CTL         0x320c
2923 #define   DPFC_RECOMP_STALL_EN  (1<<27)
2924 #define   DPFC_RECOMP_STALL_WM_SHIFT (16)
2925 #define   DPFC_RECOMP_STALL_WM_MASK (0x07ff0000)
2926 #define   DPFC_RECOMP_TIMER_COUNT_SHIFT (0)
2927 #define   DPFC_RECOMP_TIMER_COUNT_MASK (0x0000003f)
2928 #define DPFC_STATUS             0x3210
2929 #define   DPFC_INVAL_SEG_SHIFT  (16)
2930 #define   DPFC_INVAL_SEG_MASK   (0x07ff0000)
2931 #define   DPFC_COMP_SEG_SHIFT   (0)
2932 #define   DPFC_COMP_SEG_MASK    (0x000003ff)
2933 #define DPFC_STATUS2            0x3214
2934 #define DPFC_FENCE_YOFF         0x3218
2935
2936 #define PEG_BAND_GAP_DATA       0x14d68
2937
2938 #define MCHBAR_RENDER_STANDBY   0x111B8
2939 #define RENDER_STANDBY_ENABLE   (1 << 30)
2940
2941
2942 /* Ironlake */
2943
2944 /* warmup time in us */
2945 #define WARMUP_PCH_REF_CLK_SSC_MOD      1
2946 #define WARMUP_PCH_FDI_RECEIVER_PLL     25
2947 #define WARMUP_PCH_DPLL                 50
2948 #define WARMUP_CPU_DP_PLL               20
2949 #define WARMUP_CPU_FDI_TRANSMITTER_PLL  10
2950 #define WARMUP_DMI_LATENCY              20
2951 #define FDI_TRAIN_PATTERN_1_TIME        0.5
2952 #define FDI_TRAIN_PATTERN_2_TIME        1.5
2953 #define FDI_ONE_IDLE_PATTERN_TIME       31
2954
2955 #define CPU_VGACNTRL            0x41000
2956
2957 #define DIGITAL_PORT_HOTPLUG_CNTRL      0x44030
2958 #define  DIGITAL_PORTA_HOTPLUG_ENABLE           (1 << 4)
2959 #define  DIGITAL_PORTA_SHORT_PULSE_2MS          (0 << 2)
2960 #define  DIGITAL_PORTA_SHORT_PULSE_4_5MS        (1 << 2)
2961 #define  DIGITAL_PORTA_SHORT_PULSE_6MS          (2 << 2)
2962 #define  DIGITAL_PORTA_SHORT_PULSE_100MS        (3 << 2)
2963 #define  DIGITAL_PORTA_NO_DETECT                (0 << 0)
2964 #define  DIGITAL_PORTA_LONG_PULSE_DETECT_MASK   (1 << 1)
2965 #define  DIGITAL_PORTA_SHORT_PULSE_DETECT_MASK  (1 << 0)
2966
2967 /* refresh rate hardware control */
2968 #define RR_HW_CTL       0x45300
2969 #define  RR_HW_LOW_POWER_FRAMES_MASK    0xff
2970 #define  RR_HW_HIGH_POWER_FRAMES_MASK   0xff00
2971
2972 #define FDI_PLL_BIOS_0                  0x46000
2973 #define FDI_PLL_BIOS_1                  0x46004
2974 #define FDI_PLL_BIOS_2                  0x46008
2975 #define DISPLAY_PORT_PLL_BIOS_0         0x4600c
2976 #define DISPLAY_PORT_PLL_BIOS_1         0x46010
2977 #define DISPLAY_PORT_PLL_BIOS_2         0x46014
2978
2979 #define FDI_PLL_FREQ_CTL        0x46030
2980 #define  FDI_PLL_FREQ_CHANGE_REQUEST    (1<<24)
2981 #define  FDI_PLL_FREQ_LOCK_LIMIT_MASK   0xfff00
2982 #define  FDI_PLL_FREQ_DISABLE_COUNT_LIMIT_MASK  0xff
2983
2984 #define PIPEA_DATA_M1           0x60030
2985 #define  TU_SIZE(x)             (((x)-1) << 25) /* default size 64 */
2986 #define  TU_SIZE_MASK           0x7e000000
2987 #define  PIPEA_DATA_M1_OFFSET   0
2988 #define PIPEA_DATA_N1           0x60034
2989 #define  PIPEA_DATA_N1_OFFSET   0
2990
2991 #define PIPEA_DATA_M2           0x60038
2992 #define  PIPEA_DATA_M2_OFFSET   0
2993 #define PIPEA_DATA_N2           0x6003c
2994 #define  PIPEA_DATA_N2_OFFSET   0
2995
2996 #define PIPEA_LINK_M1           0x60040
2997 #define  PIPEA_LINK_M1_OFFSET   0
2998 #define PIPEA_LINK_N1           0x60044
2999 #define  PIPEA_LINK_N1_OFFSET   0
3000
3001 #define PIPEA_LINK_M2           0x60048
3002 #define  PIPEA_LINK_M2_OFFSET   0
3003 #define PIPEA_LINK_N2           0x6004c
3004 #define  PIPEA_LINK_N2_OFFSET   0
3005
3006 /* PIPEB timing regs are same start from 0x61000 */
3007
3008 #define PIPEB_DATA_M1           0x61030
3009 #define PIPEB_DATA_N1           0x61034
3010
3011 #define PIPEB_DATA_M2           0x61038
3012 #define PIPEB_DATA_N2           0x6103c
3013
3014 #define PIPEB_LINK_M1           0x61040
3015 #define PIPEB_LINK_N1           0x61044
3016
3017 #define PIPEB_LINK_M2           0x61048
3018 #define PIPEB_LINK_N2           0x6104c
3019
3020 /* PIPEC timing regs */
3021
3022 #define PIPEC_DATA_M1           0x62030
3023 #define PIPEC_DATA_N1           0x62034
3024
3025 #define PIPEC_DATA_M2           0x62038
3026 #define PIPEC_DATA_N2           0x6203c
3027
3028 #define PIPEC_LINK_M1           0x62040
3029 #define PIPEC_LINK_N1           0x62044
3030
3031 #define PIPEC_LINK_M2           0x62048
3032 #define PIPEC_LINK_N2           0x6204c
3033
3034 /* PIPECONF for pipe A/B addr is same */
3035
3036 /* cusor A is only connected to pipe A,
3037    cursor B is connected to pipe B. Otherwise no change. */
3038
3039 /* Plane A/B, DSPACNTR/DSPBCNTR addr not changed */
3040
3041 /* CPU panel fitter */
3042 #define PFA_CTL_1               0x68080
3043 #define PFB_CTL_1               0x68880
3044 #define PFC_CTL_1               0x69080
3045 #define  PF_ENABLE              (1<<31)
3046 #define PFA_CTL_2               0x68084
3047 #define PFB_CTL_2               0x68884
3048 #define PFC_CTL_2               0x69084
3049 #define PFA_CTL_3               0x68088
3050 #define PFB_CTL_3               0x68888
3051 #define PFC_CTL_3               0x69088
3052 #define PFA_CTL_4               0x68090
3053 #define PFB_CTL_4               0x68890
3054 #define PFC_CTL_4               0x69090
3055
3056 #define PFA_WIN_POS             0x68070
3057 #define PFB_WIN_POS             0x68870
3058 #define PFC_WIN_POS             0x69070
3059 #define PFA_WIN_SIZE            0x68074
3060 #define PFB_WIN_SIZE            0x68874
3061 #define PFC_WIN_SIZE            0x69074
3062
3063 /* legacy palette */
3064 #define LGC_PALETTE_A           0x4a000
3065 #define LGC_PALETTE_B           0x4a800
3066
3067 /* interrupts */
3068 #define DE_MASTER_IRQ_CONTROL   (1 << 31)
3069 #define DE_SPRITEB_FLIP_DONE    (1 << 29)
3070 #define DE_SPRITEA_FLIP_DONE    (1 << 28)
3071 #define DE_PLANEB_FLIP_DONE     (1 << 27)
3072 #define DE_PLANEA_FLIP_DONE     (1 << 26)
3073 #define DE_PCU_EVENT            (1 << 25)
3074 #define DE_GTT_FAULT            (1 << 24)
3075 #define DE_POISON               (1 << 23)
3076 #define DE_PERFORM_COUNTER      (1 << 22)
3077 #define DE_PCH_EVENT            (1 << 21)
3078 #define DE_AUX_CHANNEL_A        (1 << 20)
3079 #define DE_DP_A_HOTPLUG         (1 << 19)
3080 #define DE_GSE                  (1 << 18)
3081 #define DE_PIPEB_VBLANK         (1 << 15)
3082 #define DE_PIPEB_EVEN_FIELD     (1 << 14)
3083 #define DE_PIPEB_ODD_FIELD      (1 << 13)
3084 #define DE_PIPEB_LINE_COMPARE   (1 << 12)
3085 #define DE_PIPEB_VSYNC          (1 << 11)
3086 #define DE_PIPEB_FIFO_UNDERRUN  (1 << 8)
3087 #define DE_PIPEA_VBLANK         (1 << 7)
3088 #define DE_PIPEA_EVEN_FIELD     (1 << 6)
3089 #define DE_PIPEA_ODD_FIELD      (1 << 5)
3090 #define DE_PIPEA_LINE_COMPARE   (1 << 4)
3091 #define DE_PIPEA_VSYNC          (1 << 3)
3092 #define DE_PIPEA_FIFO_UNDERRUN  (1 << 0)
3093
3094 #define DEISR   0x44000
3095 #define DEIMR   0x44004
3096 #define DEIIR   0x44008
3097 #define DEIER   0x4400c
3098
3099 /* GT interrupt */
3100 #define GT_SYNC_STATUS          (1 << 2)
3101 #define GT_USER_INTERRUPT       (1 << 0)
3102
3103 #define GTISR   0x44010
3104 #define GTIMR   0x44014
3105 #define GTIIR   0x44018
3106 #define GTIER   0x4401c
3107
3108 /* PCH */
3109
3110 /* south display engine interrupt */
3111 #define SDE_CRT_HOTPLUG         (1 << 11)
3112 #define SDE_PORTD_HOTPLUG       (1 << 10)
3113 #define SDE_PORTC_HOTPLUG       (1 << 9)
3114 #define SDE_PORTB_HOTPLUG       (1 << 8)
3115 #define SDE_SDVOB_HOTPLUG       (1 << 6)
3116
3117 #define SDEISR  0xc4000
3118 #define SDEIMR  0xc4004
3119 #define SDEIIR  0xc4008
3120 #define SDEIER  0xc400c
3121
3122 /* digital port hotplug */
3123 #define PCH_PORT_HOTPLUG        0xc4030
3124 #define PORTD_HOTPLUG_ENABLE            (1 << 20)
3125 #define PORTD_PULSE_DURATION_2ms        (0)
3126 #define PORTD_PULSE_DURATION_4_5ms      (1 << 18)
3127 #define PORTD_PULSE_DURATION_6ms        (2 << 18)
3128 #define PORTD_PULSE_DURATION_100ms      (3 << 18)
3129 #define PORTD_HOTPLUG_NO_DETECT         (0)
3130 #define PORTD_HOTPLUG_SHORT_DETECT      (1 << 16)
3131 #define PORTD_HOTPLUG_LONG_DETECT       (1 << 17)
3132 #define PORTC_HOTPLUG_ENABLE            (1 << 12)
3133 #define PORTC_PULSE_DURATION_2ms        (0)
3134 #define PORTC_PULSE_DURATION_4_5ms      (1 << 10)
3135 #define PORTC_PULSE_DURATION_6ms        (2 << 10)
3136 #define PORTC_PULSE_DURATION_100ms      (3 << 10)
3137 #define PORTC_HOTPLUG_NO_DETECT         (0)
3138 #define PORTC_HOTPLUG_SHORT_DETECT      (1 << 8)
3139 #define PORTC_HOTPLUG_LONG_DETECT       (1 << 9)
3140 #define PORTB_HOTPLUG_ENABLE            (1 << 4)
3141 #define PORTB_PULSE_DURATION_2ms        (0)
3142 #define PORTB_PULSE_DURATION_4_5ms      (1 << 2)
3143 #define PORTB_PULSE_DURATION_6ms        (2 << 2)
3144 #define PORTB_PULSE_DURATION_100ms      (3 << 2)
3145 #define PORTB_HOTPLUG_NO_DETECT         (0)
3146 #define PORTB_HOTPLUG_SHORT_DETECT      (1 << 0)
3147 #define PORTB_HOTPLUG_LONG_DETECT       (1 << 1)
3148
3149 #define PCH_GPIOA               0xc5010
3150 #define PCH_GPIOB               0xc5014
3151 #define PCH_GPIOC               0xc5018
3152 #define PCH_GPIOD               0xc501c
3153 #define PCH_GPIOE               0xc5020
3154 #define PCH_GPIOF               0xc5024
3155 #define PCH_GMBUS0              0xc5100
3156 #define PCH_GMBUS1              0xc5104
3157 #define PCH_GMBUS2              0xc5108
3158 #define PCH_GMBUS3              0xc510c
3159 #define PCH_GMBUS4              0xc5110
3160 #define PCH_GMBUS5              0xc5120
3161
3162 #define PCH_DPLL_A              0xc6014
3163 #define PCH_DPLL_B              0xc6018
3164
3165 #define PCH_FPA0                0xc6040
3166 #define PCH_FPA1                0xc6044
3167 #define PCH_FPB0                0xc6048
3168 #define PCH_FPB1                0xc604c
3169
3170 #define PCH_DPLL_TEST           0xc606c
3171
3172 #define PCH_DREF_CONTROL        0xC6200
3173 #define  DREF_CONTROL_MASK      0x7fc3
3174 #define  DREF_CPU_SOURCE_OUTPUT_DISABLE         (0<<13)
3175 #define  DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD      (2<<13)
3176 #define  DREF_CPU_SOURCE_OUTPUT_NONSPREAD       (3<<13)
3177 #define  DREF_SSC_SOURCE_DISABLE                (0<<11)
3178 #define  DREF_SSC_SOURCE_ENABLE                 (2<<11)
3179 #define  DREF_NONSPREAD_SOURCE_DISABLE          (0<<9)
3180 #define  DREF_NONSPREAD_SOURCE_ENABLE           (2<<9)
3181 #define  DREF_SUPERSPREAD_SOURCE_DISABLE        (0<<7)
3182 #define  DREF_SUPERSPREAD_SOURCE_ENABLE         (2<<7)
3183 #define  DREF_SSC4_DOWNSPREAD                   (0<<6)
3184 #define  DREF_SSC4_CENTERSPREAD                 (1<<6)
3185 #define  DREF_SSC1_DISABLE                      (0<<1)
3186 #define  DREF_SSC1_ENABLE                       (1<<1)
3187 #define  DREF_SSC4_DISABLE                      (0)
3188 #define  DREF_SSC4_ENABLE                       (1)
3189
3190 #define PCH_RAWCLK_FREQ         0xc6204
3191 #define  FDL_TP1_TIMER_SHIFT    12
3192 #define  FDL_TP1_TIMER_MASK     (3<<12)
3193 #define  FDL_TP2_TIMER_SHIFT    10
3194 #define  FDL_TP2_TIMER_MASK     (3<<10)
3195 #define  RAWCLK_FREQ_MASK       0x3ff
3196
3197 #define PCH_DPLL_TMR_CFG        0xc6208
3198
3199 #define PCH_SSC4_PARMS          0xc6210
3200 #define PCH_SSC4_AUX_PARMS      0xc6214
3201
3202 /* CPT */
3203 #define PCH_DPLL_ANALOG_CTL     0xc6300
3204
3205 #define PCH_DPLL_SEL            0xc7000
3206 #define  TRANSA_DPLL_ENABLE     (1<<3)
3207 #define  TRANSA_DPLLA_SEL       (0)
3208 #define  TRANSA_DPLLB_SEL       (1<<0)
3209 #define  TRANSB_DPLL_ENABLE     (1<<7)
3210 #define  TRANSB_DPLLA_SEL       (0<<4)
3211 #define  TRANSB_DPLLB_SEL       (1<<4)
3212 #define  TRANSC_DPLL_ENABLE     (1<<11)
3213 #define  TRANSC_DPLLA_SEL       (0<<8)
3214 #define  TRANSC_DPLLB_SEL       (1<<8)
3215
3216 /* transcoder */
3217
3218 #define TRANS_HTOTAL_A          0xe0000
3219 #define  TRANS_HTOTAL_SHIFT     16
3220 #define  TRANS_HACTIVE_SHIFT    0
3221 #define TRANS_HBLANK_A          0xe0004
3222 #define  TRANS_HBLANK_END_SHIFT 16
3223 #define  TRANS_HBLANK_START_SHIFT 0
3224 #define TRANS_HSYNC_A           0xe0008
3225 #define  TRANS_HSYNC_END_SHIFT  16
3226 #define  TRANS_HSYNC_START_SHIFT 0
3227 #define TRANS_VTOTAL_A          0xe000c
3228 #define  TRANS_VTOTAL_SHIFT     16
3229 #define  TRANS_VACTIVE_SHIFT    0
3230 #define TRANS_VBLANK_A          0xe0010
3231 #define  TRANS_VBLANK_END_SHIFT 16
3232 #define  TRANS_VBLANK_START_SHIFT 0
3233 #define TRANS_VSYNC_A           0xe0014
3234 #define  TRANS_VSYNC_END_SHIFT  16
3235 #define  TRANS_VSYNC_START_SHIFT 0
3236 #define TRANS_VSYNCSHIFT_A      0xe0028
3237
3238 #define TRANSA_DATA_M1          0xe0030
3239 #define TRANSA_DATA_N1          0xe0034
3240 #define TRANSA_DATA_M2          0xe0038
3241 #define TRANSA_DATA_N2          0xe003c
3242 #define TRANSA_DP_LINK_M1       0xe0040
3243 #define TRANSA_DP_LINK_N1       0xe0044
3244 #define TRANSA_DP_LINK_M2       0xe0048
3245 #define TRANSA_DP_LINK_N2       0xe004c
3246
3247 #define TRANS_HTOTAL_B          0xe1000
3248 #define TRANS_HBLANK_B          0xe1004
3249 #define TRANS_HSYNC_B           0xe1008
3250 #define TRANS_VTOTAL_B          0xe100c
3251 #define TRANS_VBLANK_B          0xe1010
3252 #define TRANS_VSYNC_B           0xe1014
3253 #define TRANS_VSYNCSHIFT_B      0xe1028
3254
3255 #define TRANSB_DATA_M1          0xe1030
3256 #define TRANSB_DATA_N1          0xe1034
3257 #define TRANSB_DATA_M2          0xe1038
3258 #define TRANSB_DATA_N2          0xe103c
3259 #define TRANSB_DP_LINK_M1       0xe1040
3260 #define TRANSB_DP_LINK_N1       0xe1044
3261 #define TRANSB_DP_LINK_M2       0xe1048
3262 #define TRANSB_DP_LINK_N2       0xe104c
3263
3264 #define TRANS_HTOTAL_C          0xe2000
3265 #define TRANS_HBLANK_C          0xe2004
3266 #define TRANS_HSYNC_C           0xe2008
3267 #define TRANS_VTOTAL_C          0xe200c
3268 #define TRANS_VBLANK_C          0xe2010
3269 #define TRANS_VSYNC_C           0xe2014
3270 #define TRANS_VSYNCSHIFT_C      0xe2028
3271
3272 #define TRANSC_DATA_M1          0xe2030
3273 #define TRANSC_DATA_N1          0xe2034
3274 #define TRANSC_DATA_M2          0xe2038
3275 #define TRANSC_DATA_N2          0xe203c
3276 #define TRANSC_DP_LINK_M1       0xe2040
3277 #define TRANSC_DP_LINK_N1       0xe2044
3278 #define TRANSC_DP_LINK_M2       0xe2048
3279 #define TRANSC_DP_LINK_N2       0xe204c
3280
3281 #define TRANSACONF              0xf0008
3282 #define TRANSBCONF              0xf1008
3283 #define TRANSCCONF              0xf2008
3284 #define  TRANS_DISABLE          (0<<31)
3285 #define  TRANS_ENABLE           (1<<31)
3286 #define  TRANS_STATE_MASK       (1<<30)
3287 #define  TRANS_STATE_DISABLE    (0<<30)
3288 #define  TRANS_STATE_ENABLE     (1<<30)
3289 #define  TRANS_FSYNC_DELAY_HB1  (0<<27)
3290 #define  TRANS_FSYNC_DELAY_HB2  (1<<27)
3291 #define  TRANS_FSYNC_DELAY_HB3  (2<<27)
3292 #define  TRANS_FSYNC_DELAY_HB4  (3<<27)
3293 #define  TRANS_DP_AUDIO_ONLY    (1<<26)
3294 #define  TRANS_DP_VIDEO_AUDIO   (0<<26)
3295 #define  TRANS_PROGRESSIVE      (0<<21)
3296 #define  TRANS_8BPC             (0<<5)
3297 #define  TRANS_10BPC            (1<<5)
3298 #define  TRANS_6BPC             (2<<5)
3299 #define  TRANS_12BPC            (3<<5)
3300
3301 #define FDI_RXA_CHICKEN         0xc200c
3302 #define FDI_RXB_CHICKEN         0xc2010
3303 #define  FDI_RX_PHASE_SYNC_POINTER_ENABLE       (1)
3304
3305 /* CPU: FDI_TX */
3306 #define FDI_TXA_CTL             0x60100
3307 #define FDI_TXB_CTL             0x61100
3308 #define FDI_TXC_CTL             0x62100
3309 #define  FDI_TX_DISABLE         (0<<31)
3310 #define  FDI_TX_ENABLE          (1<<31)
3311 #define  FDI_LINK_TRAIN_PATTERN_1       (0<<28)
3312 #define  FDI_LINK_TRAIN_PATTERN_2       (1<<28)
3313 #define  FDI_LINK_TRAIN_PATTERN_IDLE    (2<<28)
3314 #define  FDI_LINK_TRAIN_NONE            (3<<28)
3315 #define  FDI_LINK_TRAIN_VOLTAGE_0_4V    (0<<25)
3316 #define  FDI_LINK_TRAIN_VOLTAGE_0_6V    (1<<25)
3317 #define  FDI_LINK_TRAIN_VOLTAGE_0_8V    (2<<25)
3318 #define  FDI_LINK_TRAIN_VOLTAGE_1_2V    (3<<25)
3319 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_NONE (0<<22)
3320 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_1_5X (1<<22)
3321 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_2X   (2<<22)
3322 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_3X   (3<<22)
3323 /* ILK always use 400mV 0dB for voltage swing and pre-emphasis level.
3324    SNB has different settings. */
3325 /* SNB A-stepping */
3326 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_A         (0x38<<22)
3327 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_A         (0x02<<22)
3328 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_A       (0x01<<22)
3329 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_A         (0x0<<22)
3330 /* SNB B-stepping */
3331 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_B         (0x0<<22)
3332 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_B         (0x3a<<22)
3333 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_B       (0x39<<22)
3334 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_B         (0x38<<22)
3335 #define  FDI_LINK_TRAIN_VOL_EMP_MASK            (0x3f<<22)
3336 #define  FDI_DP_PORT_WIDTH_X1           (0<<19)
3337 #define  FDI_DP_PORT_WIDTH_X2           (1<<19)
3338 #define  FDI_DP_PORT_WIDTH_X3           (2<<19)
3339 #define  FDI_DP_PORT_WIDTH_X4           (3<<19)
3340 #define  FDI_TX_ENHANCE_FRAME_ENABLE    (1<<18)
3341 /* Ironlake: hardwired to 1 */
3342 #define  FDI_TX_PLL_ENABLE              (1<<14)
3343 /* both Tx and Rx */
3344 #define  FDI_SCRAMBLING_ENABLE          (0<<7)
3345 #define  FDI_SCRAMBLING_DISABLE         (1<<7)
3346
3347 /* Additional cpu TX control regs, from ivb bspec */
3348 #define DPAFE_BMFUNC            0x6c024
3349 #define DPAFE_DL_IREFCAL0       0x6c02c
3350 #define DPAFE_DL_IREFCAL1       0x6c030
3351 #define DPAFE_DP_IREFCAL        0x6c034
3352
3353 /* FDI_RX, FDI_X is hard-wired to Transcoder_X */
3354 #define FDI_RXA_CTL             0xf000c
3355 #define FDI_RXB_CTL             0xf100c
3356 #define FDI_RXC_CTL             0xf200c
3357 #define  FDI_RX_ENABLE          (1<<31)
3358 #define  FDI_RX_DISABLE         (0<<31)
3359 /* train, dp width same as FDI_TX */
3360 #define  FDI_DP_PORT_WIDTH_X8           (7<<19)
3361 #define  FDI_8BPC                       (0<<16)
3362 #define  FDI_10BPC                      (1<<16)
3363 #define  FDI_6BPC                       (2<<16)
3364 #define  FDI_12BPC                      (3<<16)
3365 #define  FDI_LINK_REVERSE_OVERWRITE     (1<<15)
3366 #define  FDI_DMI_LINK_REVERSE_MASK      (1<<14)
3367 #define  FDI_RX_PLL_ENABLE              (1<<13)
3368 #define  FDI_FS_ERR_CORRECT_ENABLE      (1<<11)
3369 #define  FDI_FE_ERR_CORRECT_ENABLE      (1<<10)
3370 #define  FDI_FS_ERR_REPORT_ENABLE       (1<<9)
3371 #define  FDI_FE_ERR_REPORT_ENABLE       (1<<8)
3372 #define  FDI_RX_ENHANCE_FRAME_ENABLE    (1<<6)
3373 #define  FDI_SEL_RAWCLK                 (0<<4)
3374 #define  FDI_SEL_PCDCLK                 (1<<4)
3375 /* CPT */
3376 #define  FDI_AUTO_TRAINING                      (1<<10)
3377 #define  FDI_LINK_TRAIN_PATTERN_1_CPT           (0<<8)
3378 #define  FDI_LINK_TRAIN_PATTERN_2_CPT           (1<<8)
3379 #define  FDI_LINK_TRAIN_PATTERN_IDLE_CPT        (2<<8)
3380 #define  FDI_LINK_TRAIN_NORMAL_CPT              (3<<8)
3381 #define  FDI_LINK_TRAIN_PATTERN_MASK_CPT        (3<<8)
3382
3383 #define FDI_RXA_MISC            0xf0010
3384 #define FDI_RXB_MISC            0xf1010
3385 #define FDI_RXC_MISC            0xf2010
3386 #define FDI_RXA_TUSIZE1         0xf0030
3387 #define FDI_RXA_TUSIZE2         0xf0038
3388 #define FDI_RXB_TUSIZE1         0xf1030
3389 #define FDI_RXB_TUSIZE2         0xf1038
3390 #define FDI_RXC_TUSIZE1         0xf2030
3391 #define FDI_RXC_TUSIZE2         0xf2038
3392
3393 /* FDI_RX interrupt register format */
3394 #define FDI_RX_INTER_LANE_ALIGN         (1<<10)
3395 #define FDI_RX_SYMBOL_LOCK              (1<<9) /* train 2 */
3396 #define FDI_RX_BIT_LOCK                 (1<<8) /* train 1 */
3397 #define FDI_RX_TRAIN_PATTERN_2_FAIL     (1<<7)
3398 #define FDI_RX_FS_CODE_ERR              (1<<6)
3399 #define FDI_RX_FE_CODE_ERR              (1<<5)
3400 #define FDI_RX_SYMBOL_ERR_RATE_ABOVE    (1<<4)
3401 #define FDI_RX_HDCP_LINK_FAIL           (1<<3)
3402 #define FDI_RX_PIXEL_FIFO_OVERFLOW      (1<<2)
3403 #define FDI_RX_CROSS_CLOCK_OVERFLOW     (1<<1)
3404 #define FDI_RX_SYMBOL_QUEUE_OVERFLOW    (1<<0)
3405
3406 #define FDI_RXA_IIR             0xf0014
3407 #define FDI_RXA_IMR             0xf0018
3408 #define FDI_RXB_IIR             0xf1014
3409 #define FDI_RXB_IMR             0xf1018
3410
3411 #define FDI_PLL_CTL_1           0xfe000
3412 #define FDI_PLL_CTL_2           0xfe004
3413
3414 /* CRT */
3415 #define PCH_ADPA                0xe1100
3416 #define  ADPA_TRANS_SELECT_MASK (1<<30)
3417 #define  ADPA_TRANS_A_SELECT    0
3418 #define  ADPA_TRANS_B_SELECT    (1<<30)
3419 /* HPD is here */
3420 #define  ADPA_CRT_HOTPLUG_MASK  0x03ff0000 /* bit 25-16 */
3421 #define  ADPA_CRT_HOTPLUG_MONITOR_NONE  (0<<24)
3422 #define  ADPA_CRT_HOTPLUG_MONITOR_MASK  (3<<24)
3423 #define  ADPA_CRT_HOTPLUG_MONITOR_COLOR (3<<24)
3424 #define  ADPA_CRT_HOTPLUG_MONITOR_MONO  (2<<24)
3425 #define  ADPA_CRT_HOTPLUG_ENABLE        (1<<23)
3426 #define  ADPA_CRT_HOTPLUG_PERIOD_64     (0<<22)
3427 #define  ADPA_CRT_HOTPLUG_PERIOD_128    (1<<22)
3428 #define  ADPA_CRT_HOTPLUG_WARMUP_5MS    (0<<21)
3429 #define  ADPA_CRT_HOTPLUG_WARMUP_10MS   (1<<21)
3430 #define  ADPA_CRT_HOTPLUG_SAMPLE_2S     (0<<20)
3431 #define  ADPA_CRT_HOTPLUG_SAMPLE_4S     (1<<20)
3432 #define  ADPA_CRT_HOTPLUG_VOLTAGE_40    (0<<18)
3433 #define  ADPA_CRT_HOTPLUG_VOLTAGE_50    (1<<18)
3434 #define  ADPA_CRT_HOTPLUG_VOLTAGE_60    (2<<18)
3435 #define  ADPA_CRT_HOTPLUG_VOLTAGE_70    (3<<18)
3436 #define  ADPA_CRT_HOTPLUG_VOLREF_325MV  (0<<17)
3437 #define  ADPA_CRT_HOTPLUG_VOLREF_475MV  (1<<17)
3438 #define  ADPA_CRT_HOTPLUG_FORCE_TRIGGER (1<<16)
3439 /* polarity control not changed */
3440
3441 /* or SDVOB */
3442 #define HDMIB   0xe1140
3443 #define  PORT_ENABLE    (1 << 31)
3444 #define  TRANSCODER_A   (0)
3445 #define  TRANSCODER_B   (1 << 30)
3446 #define  COLOR_FORMAT_8bpc      (0)
3447 #define  COLOR_FORMAT_12bpc     (3 << 26)
3448 #define  SDVOB_HOTPLUG_ENABLE   (1 << 23)
3449 #define  SDVO_ENCODING          (0)
3450 #define  TMDS_ENCODING          (2 << 10)
3451 #define  NULL_PACKET_VSYNC_ENABLE       (1 << 9)
3452 #define  SDVOB_BORDER_ENABLE    (1 << 7)
3453 #define  AUDIO_ENABLE           (1 << 6)
3454 #define  VSYNC_ACTIVE_HIGH      (1 << 4)
3455 #define  HSYNC_ACTIVE_HIGH      (1 << 3)
3456 #define  PORT_DETECTED          (1 << 2)
3457
3458 #define HDMIC   0xe1150
3459 #define HDMID   0xe1160
3460 #define PCH_LVDS                0xe1180
3461
3462 #define BLC_PWM_CPU_CTL2        0x48250
3463 #define  PWM_ENABLE             (1 << 31)
3464 #define  PWM_PIPE_A             (0 << 29)
3465 #define  PWM_PIPE_B             (1 << 29)
3466 #define BLC_PWM_CPU_CTL         0x48254
3467
3468 #define BLC_PWM_PCH_CTL1        0xc8250
3469 #define  PWM_PCH_ENABLE         (1 << 31)
3470 #define  PWM_POLARITY_ACTIVE_LOW        (1 << 29)
3471 #define  PWM_POLARITY_ACTIVE_HIGH       (0 << 29)
3472 #define  PWM_POLARITY_ACTIVE_LOW2       (1 << 28)
3473 #define  PWM_POLARITY_ACTIVE_HIGH2      (0 << 28)
3474
3475 #define BLC_PWM_PCH_CTL2        0xc8254
3476
3477 #define PCH_PP_STATUS           0xc7200
3478 #define PCH_PP_CONTROL          0xc7204
3479 #define  EDP_FORCE_VDD          (1 << 3)
3480 #define  EDP_BLC_ENABLE         (1 << 2)
3481 #define  PANEL_POWER_RESET      (1 << 1)
3482 #define  PANEL_POWER_OFF        (0 << 0)
3483 #define  PANEL_POWER_ON         (1 << 0)
3484 #define PCH_PP_ON_DELAYS        0xc7208
3485 #define  EDP_PANEL              (1 << 30)
3486 #define PCH_PP_OFF_DELAYS       0xc720c
3487 #define PCH_PP_DIVISOR          0xc7210
3488
3489 #define AUD_CONFIG              0x62000
3490 #define AUD_DEBUG               0x62010
3491 #define AUD_VID_DID             0x62020
3492 #define AUD_RID                 0x62024
3493 #define AUD_SUBN_CNT            0x62028
3494 #define AUD_FUNC_GRP            0x62040
3495 #define AUD_SUBN_CNT2           0x62044
3496 #define AUD_GRP_CAP             0x62048
3497 #define AUD_PWRST               0x6204c
3498 #define AUD_SUPPWR              0x62050
3499 #define AUD_SID                 0x62054
3500 #define AUD_OUT_CWCAP           0x62070
3501 #define AUD_OUT_PCMSIZE         0x62074
3502 #define AUD_OUT_STR             0x62078
3503 #define AUD_OUT_DIG_CNVT        0x6207c
3504 #define AUD_OUT_CH_STR          0x62080
3505 #define AUD_OUT_STR_DESC        0x62084
3506 #define AUD_PINW_CAP            0x620a0
3507 #define AUD_PIN_CAP             0x620a4
3508 #define AUD_PINW_CONNLNG        0x620a8
3509 #define AUD_PINW_CONNLST        0x620ac
3510 #define AUD_PINW_CNTR           0x620b0
3511 #define AUD_PINW_UNSOLRESP      0x620b8
3512 #define AUD_CNTL_ST             0x620b4
3513 #define AUD_PINW_CONFIG         0x620bc
3514 #define AUD_HDMIW_STATUS        0x620d4
3515 #define AUD_HDMIW_HDMIEDID      0x6210c
3516 #define AUD_HDMIW_INFOFR        0x62118
3517 #define AUD_CONV_CHCNT          0x62120
3518 #define AUD_CTS_ENABLE          0x62128
3519
3520 #define VIDEO_DIP_CTL           0x61170
3521 #define VIDEO_DIP_DATA          0x61178
3522
3523 /* CPT */
3524 #define TRANS_DP_CTL_A          0xe0300
3525 #define TRANS_DP_CTL_B          0xe1300
3526 #define TRANS_DP_CTL_C          0xe2300
3527 #define  TRANS_DP_OUTPUT_ENABLE (1<<31)
3528 #define  TRANS_DP_PORT_SEL_B    (0<<29)
3529 #define  TRANS_DP_PORT_SEL_C    (1<<29)
3530 #define  TRANS_DP_PORT_SEL_D    (2<<29)
3531 #define  TRANS_DP_PORT_SEL_MASK (3<<29)
3532 #define  TRANS_DP_AUDIO_ONLY    (1<<26)
3533 #define  TRANS_DP_ENH_FRAMING   (1<<18)
3534 #define  TRANS_DP_8BPC          (0<<9)
3535 #define  TRANS_DP_10BPC         (1<<9)
3536 #define  TRANS_DP_6BPC          (2<<9)
3537 #define  TRANS_DP_12BPC         (3<<9)
3538 #define  TRANS_DP_VSYNC_ACTIVE_HIGH     (1<<4)
3539 #define  TRANS_DP_VSYNC_ACTIVE_LOW      0
3540 #define  TRANS_DP_HSYNC_ACTIVE_HIGH     (1<<3)
3541 #define  TRANS_DP_HSYNC_ACTIVE_LOW      0
3542
3543 /* Debug regs */
3544 #define GEN6_TD_CTL             0x7000 /* <= GEN5 was at 0x8000 */
3545 #define GEN6_TD_CTL_FORCE_TD_BKPT (1<<4)
3546
3547 /* Port debugging
3548  */
3549
3550 #define PORT_DBG                    0x42308
3551 #define  PORT_DBG_DRRS_HW_STATE_OFF     (0<<30)
3552 #define  PORT_DBG_DRRS_HW_STATE_LOW     (1<<30)
3553 #define  PORT_DBG_DRRS_HW_STATE_HIGH    (2<<30)
3554
3555 /* RC6 residence counters
3556  */
3557 #define RC6_RESIDENCY_TIME          0x138108
3558 #define RC6p_RESIDENCY_TIME         0x13810C
3559 #define RC6pp_RESIDENCY_TIME        0x138110
3560
3561 #define GEN6_RPNSWREQ                           0xA008
3562 #define GEN6_RC_VIDEO_FREQ                      0xA00C
3563 #define GEN6_RC_CONTROL                         0xA090
3564 #define GEN6_RP_DOWN_TIMEOUT                    0xA010
3565 #define GEN6_RP_INTERRUPT_LIMITS                0xA014
3566 #define GEN6_RPSTAT1                            0xA01C
3567 #define GEN6_RP_CONTROL                         0xA024
3568 #define GEN6_RP_UP_THRESHOLD                    0xA02C
3569 #define GEN6_RP_DOWN_THRESHOLD                  0xA030
3570 #define GEN6_RP_CUR_UP_EI                       0xA050
3571 #define GEN6_RP_CUR_UP                          0xA054
3572 #define GEN6_RP_PREV_UP                         0xA058
3573 #define GEN6_RP_CUR_DOWN_EI                     0xA05C
3574 #define GEN6_RP_CUR_DOWN                        0xA060
3575 #define GEN6_RP_PREV_DOWN                       0xA064
3576 #define GEN6_RP_UP_EI                           0xA068
3577 #define GEN6_RP_DOWN_EI                         0xA06C
3578 #define GEN6_RP_IDLE_HYSTERSIS                  0xA070
3579 #define GEN6_RC_STATE                           0xA094
3580 #define GEN6_RC1_WAKE_RATE_LIMIT                0xA098
3581 #define GEN6_RC6_WAKE_RATE_LIMIT                0xA09C
3582 #define GEN6_RC6pp_WAKE_RATE_LIMIT              0xA0A0
3583 #define GEN6_RC_EVALUATION_INTERVAL             0xA0A8
3584 #define GEN6_RC_IDLE_HYSTERSIS                  0xA0AC
3585 #define GEN6_RC_SLEEP                           0xA0B0
3586 #define GEN6_RC1e_THRESHOLD                     0xA0B4
3587 #define GEN6_RC6_THRESHOLD                      0xA0B8
3588 #define GEN6_RC6p_THRESHOLD                     0xA0BC
3589 #define GEN6_RC6pp_THRESHOLD                    0xA0C0
3590 #define GEN6_PMINTRMSK                          0xA168
3591 #define GEN6_RC_EVALUATION_INTERVAL             0xA0A8
3592 #define GEN6_RC_IDLE_HYSTERSIS                  0xA0AC
3593 #define GEN6_PMIER                              0x4402C
3594 #define GEN6_PMIMR                              0x44024 /* rps_lock */
3595 #define GEN6_PMINTRMSK                          0xA168
3596
3597 /* Haswell-related items */
3598
3599 /* HSW Power Wells */
3600 #define HSW_PWR_WELL_CTL1                       0x45400         /* BIOS */
3601 #define HSW_PWR_WELL_CTL2                       0x45404         /* Driver */
3602 #define HSW_PWR_WELL_CTL3                       0x45408         /* KVMR */
3603 #define HSW_PWR_WELL_CTL4                       0x4540C         /* Debug */
3604 #define   HSW_PWR_WELL_ENABLE                   (1<<31)
3605 #define   HSW_PWR_WELL_STATE                    (1<<30)
3606 #define HSW_PWR_WELL_CTL5                       0x45410
3607 #define   HSW_PWR_WELL_ENABLE_SINGLE_STEP       (1<<31)
3608 #define   HSW_PWR_WELL_PWR_GATE_OVERRIDE        (1<<20)
3609 #define   HSW_PWR_WELL_FORCE_ON                 (1<<19)
3610 #define HSW_PWR_WELL_CTL6                       0x45414
3611
3612 /* Per-pipe DDI Function Control */
3613 #define PIPE_DDI_FUNC_CTL_A             0x60400
3614 #define PIPE_DDI_FUNC_CTL_B             0x61400
3615 #define PIPE_DDI_FUNC_CTL_C             0x62400
3616 #define PIPE_DDI_FUNC_CTL_EDP           0x6F400
3617 #define DDI_FUNC_CTL(pipe) _PIPE(pipe, \
3618                                         PIPE_DDI_FUNC_CTL_A, \
3619                                         PIPE_DDI_FUNC_CTL_B)
3620 #define  PIPE_DDI_FUNC_ENABLE           (1<<31)
3621 /* Those bits are ignored by pipe EDP since it can only connect to DDI A */
3622 #define  PIPE_DDI_PORT_MASK             (0xf<<28)
3623 #define  PIPE_DDI_SELECT_PORT(x)        ((x)<<28)
3624 #define  PIPE_DDI_MODE_SELECT_HDMI      (0<<24)
3625 #define  PIPE_DDI_MODE_SELECT_DVI       (1<<24)
3626 #define  PIPE_DDI_MODE_SELECT_DP_SST    (2<<24)
3627 #define  PIPE_DDI_MODE_SELECT_DP_MST    (3<<24)
3628 #define  PIPE_DDI_MODE_SELECT_FDI       (4<<24)
3629 #define  PIPE_DDI_BPC_8                 (0<<20)
3630 #define  PIPE_DDI_BPC_10                (1<<20)
3631 #define  PIPE_DDI_BPC_6                 (2<<20)
3632 #define  PIPE_DDI_BPC_12                (3<<20)
3633 #define  PIPE_DDI_BFI_ENABLE            (1<<4)
3634 #define  PIPE_DDI_PORT_WIDTH_X1         (0<<1)
3635 #define  PIPE_DDI_PORT_WIDTH_X2         (1<<1)
3636 #define  PIPE_DDI_PORT_WIDTH_X4         (3<<1)
3637
3638 /* DisplayPort Transport Control */
3639 #define DP_TP_CTL_A                             0x64040
3640 #define DP_TP_CTL_B                             0x64140
3641 #define DP_TP_CTL_C                             0x64240
3642 #define DP_TP_CTL_D                             0x64340
3643 #define DP_TP_CTL_E                             0x64440
3644 #define  DP_TP_CTL_ENABLE                       (1<<31)
3645 #define  DP_TP_CTL_MODE_SST                     (0<<27)
3646 #define  DP_TP_CTL_MODE_MST                     (1<<27)
3647 #define  DP_TP_CTL_ENHANCED_FRAME_ENABLE        (1<<18)
3648 #define  DP_TP_CTL_FDI_AUTOTRAIN                (1<<15)
3649 #define  DP_TP_CTL_LINK_TRAIN_MASK              (7<<8)
3650 #define  DP_TP_CTL_LINK_TRAIN_PAT1              (0<<8)
3651 #define  DP_TP_CTL_LINK_TRAIN_PAT2              (1<<8)
3652 #define  DP_TP_CTL_LINK_TRAIN_NORMAL            (3<<8)
3653
3654 /* DisplayPort Transport Status */
3655 #define DP_TP_STATUS_A                  0x64044
3656 #define DP_TP_STATUS_B                  0x64144
3657 #define DP_TP_STATUS_C                  0x64244
3658 #define DP_TP_STATUS_D                  0x64344
3659 #define DP_TP_STATUS_E                  0x64444
3660 #define  DP_TP_STATUS_AUTOTRAIN_DONE    (1<<12)
3661
3662 /* DDI Buffer Control */
3663 #define DDI_BUF_CTL_A                   0x64000
3664 #define DDI_BUF_CTL_B                   0x64100
3665 #define DDI_BUF_CTL_C                   0x64200
3666 #define DDI_BUF_CTL_D                   0x64300
3667 #define DDI_BUF_CTL_E                   0x64400
3668 #define  DDI_BUF_CTL_ENABLE             (1<<31)
3669 #define  DDI_BUF_EMP_400MV_0DB_HSW      (0<<24)   /* Sel0 */
3670 #define  DDI_BUF_EMP_400MV_3_5DB_HSW    (1<<24)   /* Sel1 */
3671 #define  DDI_BUF_EMP_400MV_6DB_HSW      (2<<24)   /* Sel2 */
3672 #define  DDI_BUF_EMP_400MV_9_5DB_HSW    (3<<24)   /* Sel3 */
3673 #define  DDI_BUF_EMP_600MV_0DB_HSW      (4<<24)   /* Sel4 */
3674 #define  DDI_BUF_EMP_600MV_3_5DB_HSW    (5<<24)   /* Sel5 */
3675 #define  DDI_BUF_EMP_600MV_6DB_HSW      (6<<24)   /* Sel6 */
3676 #define  DDI_BUF_EMP_800MV_0DB_HSW      (7<<24)   /* Sel7 */
3677 #define  DDI_BUF_EMP_800MV_3_5DB_HSW    (8<<24)   /* Sel8 */
3678 #define  DDI_BUF_EMP_MASK               (0xf<<24)
3679 #define  DDI_BUF_IS_IDLE                (1<<7)
3680 #define  DDI_PORT_WIDTH_X1              (0<<1)
3681 #define  DDI_PORT_WIDTH_X2              (1<<1)
3682 #define  DDI_PORT_WIDTH_X4              (3<<1)
3683 #define  DDI_INIT_DISPLAY_DETECTED      (1<<0)
3684
3685 /* LPT PIXCLK_GATE */
3686 #define PIXCLK_GATE             0xC6020
3687 #define  PIXCLK_GATE_UNGATE     1<<0
3688 #define  PIXCLK_GATE_GATE       0<<0
3689
3690 /* SPLL */
3691 #define SPLL_CTL                0x46020
3692 #define  SPLL_PLL_ENABLE        (1<<31)
3693 #define  SPLL_PLL_SCC           (1<<28)
3694 #define  SPLL_PLL_NON_SCC       (2<<28)
3695 #define  SPLL_PLL_FREQ_810MHz   (0<<26)
3696 #define  SPLL_PLL_FREQ_1350MHz  (1<<26)
3697
3698 /* WRPLL */
3699 #define WRPLL_CTL1                      0x46040
3700 #define WRPLL_CTL2                      0x46060
3701 #define  WRPLL_PLL_ENABLE               (1<<31)
3702 #define  WRPLL_PLL_SELECT_SSC           (0x01<<28)
3703 #define  WRPLL_PLL_SELECT_NON_SCC       (0x02<<28)
3704 #define  WRPLL_PLL_SELECT_LCPLL_2700    (0x03<<28)
3705 /* WRPLL divider programming */
3706 #define  WRPLL_DIVIDER_REFERENCE(x)     ((x)<<0)
3707 #define  WRPLL_DIVIDER_POST(x)          ((x)<<8)
3708 #define  WRPLL_DIVIDER_FEEDBACK(x)      ((x)<<16)
3709
3710 /* Port clock selection */
3711 #define PORT_CLK_SEL_A                  0x46100
3712 #define PORT_CLK_SEL_B                  0x46104
3713 #define PORT_CLK_SEL_C                  0x46108
3714 #define PORT_CLK_SEL_D                  0x4610C
3715 #define PORT_CLK_SEL_E                  0x46110
3716 #define  PORT_CLK_SEL_LCPLL_2700        (0<<29)
3717 #define  PORT_CLK_SEL_LCPLL_1350        (1<<29)
3718 #define  PORT_CLK_SEL_LCPLL_810         (2<<29)
3719 #define  PORT_CLK_SEL_SPLL              (3<<29)
3720 #define  PORT_CLK_SEL_WRPLL1            (4<<29)
3721 #define  PORT_CLK_SEL_WRPLL2            (5<<29)
3722
3723 /* Pipe clock selection */
3724 #define PIPE_CLK_SEL_A                  0x46140
3725 #define PIPE_CLK_SEL_B                  0x46144
3726 #define PIPE_CLK_SEL_C                  0x46148
3727 /* For each pipe, we need to select the corresponding port clock */
3728 #define  PIPE_CLK_SEL_DISABLED          (0x0<<29)
3729 #define  PIPE_CLK_SEL_PORT(x)           ((x+1)<<29)
3730
3731 /* LCPLL Control */
3732 #define LCPLL_CTL                       0x130040
3733 #define  LCPLL_PLL_DISABLE              (1<<31)
3734 #define  LCPLL_PLL_LOCK                 (1<<30)
3735 #define  LCPLL_CD_CLOCK_DISABLE         (1<<25)
3736 #define  LCPLL_CD2X_CLOCK_DISABLE       (1<<23)
3737
3738 /* Pipe WM_LINETIME - watermark line time */
3739 #define PIPE_WM_LINETIME_A              0x45270
3740 #define PIPE_WM_LINETIME_B              0x45274
3741 #define PIPE_WM_LINETIME_C              0x45278
3742 #define   PIPE_WM_LINETIME_MASK                         (0x1ff)
3743 #define   PIPE_WM_LINETIME_TIME(x)                      ((x))
3744 #define   PIPE_WM_LINETIME_IPS_LINETIME_MASK            (0x1ff<<16)
3745 #define   PIPE_WM_LINETIME_IPS_LINETIME(x)              ((x)<<16)
3746
3747 /* SFUSE_STRAP */
3748 #define SFUSE_STRAP                     0xc2014
3749 #define  SFUSE_STRAP_DDIB_DETECTED      (1<<2)
3750 #define  SFUSE_STRAP_DDIC_DETECTED      (1<<1)
3751 #define  SFUSE_STRAP_DDID_DETECTED      (1<<0)
3752
3753 /* Valleyview related items */
3754
3755 /* Valleyview DPIO registers */
3756 #define VLV_DISPLAY_BASE        0x180000
3757 #define DPIO_PKT                        0x2100
3758 #define  DPIO_RID                       (0 << 24)
3759 #define  DPIO_OP_WRITE          (1 << 16)
3760 #define  DPIO_OP_READ           (0 << 16)
3761 #define  DPIO_PORTID            (0x12 << 8)
3762 #define  DPIO_BYTE                      (0xf << 4)
3763 #define  DPIO_BUSY                      (1 << 0)
3764 #define DPIO_DATA                       0x2104
3765 #define DPIO_REG                        0x2108
3766
3767 #endif /* _I810_REG_H */