xref: /linux/drivers/gpu/drm/i915/i915_reg.h (revision 1a2ac6d7ecdcde74a4e16f31de64124160fc7237)
1 /* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
2  * All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef _I915_REG_H_
26 #define _I915_REG_H_
27 
28 #include "i915_reg_defs.h"
29 #include "display/intel_display_reg_defs.h"
30 
31 /**
32  * DOC: The i915 register macro definition style guide
33  *
34  * Follow the style described here for new macros, and while changing existing
35  * macros. Do **not** mass change existing definitions just to update the style.
36  *
37  * File Layout
38  * ~~~~~~~~~~~
39  *
40  * Keep helper macros near the top. For example, _PIPE() and friends.
41  *
42  * Prefix macros that generally should not be used outside of this file with
43  * underscore '_'. For example, _PIPE() and friends, single instances of
44  * registers that are defined solely for the use by function-like macros.
45  *
46  * Avoid using the underscore prefixed macros outside of this file. There are
47  * exceptions, but keep them to a minimum.
48  *
49  * There are two basic types of register definitions: Single registers and
50  * register groups. Register groups are registers which have two or more
51  * instances, for example one per pipe, port, transcoder, etc. Register groups
52  * should be defined using function-like macros.
53  *
54  * For single registers, define the register offset first, followed by register
55  * contents.
56  *
57  * For register groups, define the register instance offsets first, prefixed
58  * with underscore, followed by a function-like macro choosing the right
59  * instance based on the parameter, followed by register contents.
60  *
61  * Define the register contents (i.e. bit and bit field macros) from most
62  * significant to least significant bit. Indent the register content macros
63  * using two extra spaces between ``#define`` and the macro name.
64  *
65  * Define bit fields using ``REG_GENMASK(h, l)``. Define bit field contents
66  * using ``REG_FIELD_PREP(mask, value)``. This will define the values already
67  * shifted in place, so they can be directly OR'd together. For convenience,
68  * function-like macros may be used to define bit fields, but do note that the
69  * macros may be needed to read as well as write the register contents.
70  *
71  * Define bits using ``REG_BIT(N)``. Do **not** add ``_BIT`` suffix to the name.
72  *
73  * Group the register and its contents together without blank lines, separate
74  * from other registers and their contents with one blank line.
75  *
76  * Indent macro values from macro names using TABs. Align values vertically. Use
77  * braces in macro values as needed to avoid unintended precedence after macro
78  * substitution. Use spaces in macro values according to kernel coding
79  * style. Use lower case in hexadecimal values.
80  *
81  * Naming
82  * ~~~~~~
83  *
84  * Try to name registers according to the specs. If the register name changes in
85  * the specs from platform to another, stick to the original name.
86  *
87  * Try to re-use existing register macro definitions. Only add new macros for
88  * new register offsets, or when the register contents have changed enough to
89  * warrant a full redefinition.
90  *
91  * When a register macro changes for a new platform, prefix the new macro using
92  * the platform acronym or generation. For example, ``SKL_`` or ``GEN8_``. The
93  * prefix signifies the start platform/generation using the register.
94  *
95  * When a bit (field) macro changes or gets added for a new platform, while
96  * retaining the existing register macro, add a platform acronym or generation
97  * suffix to the name. For example, ``_SKL`` or ``_GEN8``.
98  *
99  * Examples
100  * ~~~~~~~~
101  *
102  * (Note that the values in the example are indented using spaces instead of
103  * TABs to avoid misalignment in generated documentation. Use TABs in the
104  * definitions.)::
105  *
106  *  #define _FOO_A                      0xf000
107  *  #define _FOO_B                      0xf001
108  *  #define FOO(pipe)                   _MMIO_PIPE(pipe, _FOO_A, _FOO_B)
109  *  #define   FOO_ENABLE                REG_BIT(31)
110  *  #define   FOO_MODE_MASK             REG_GENMASK(19, 16)
111  *  #define   FOO_MODE_BAR              REG_FIELD_PREP(FOO_MODE_MASK, 0)
112  *  #define   FOO_MODE_BAZ              REG_FIELD_PREP(FOO_MODE_MASK, 1)
113  *  #define   FOO_MODE_QUX_SNB          REG_FIELD_PREP(FOO_MODE_MASK, 2)
114  *
115  *  #define BAR                         _MMIO(0xb000)
116  *  #define GEN8_BAR                    _MMIO(0xb888)
117  */
118 
119 #define GU_CNTL				_MMIO(0x101010)
120 #define   LMEM_INIT			REG_BIT(7)
121 #define   DRIVERFLR			REG_BIT(31)
122 #define GU_DEBUG			_MMIO(0x101018)
123 #define   DRIVERFLR_STATUS		REG_BIT(31)
124 
125 #define GEN6_STOLEN_RESERVED		_MMIO(0x1082C0)
126 #define GEN6_STOLEN_RESERVED_ADDR_MASK	(0xFFF << 20)
127 #define GEN7_STOLEN_RESERVED_ADDR_MASK	(0x3FFF << 18)
128 #define GEN6_STOLEN_RESERVED_SIZE_MASK	(3 << 4)
129 #define GEN6_STOLEN_RESERVED_1M		(0 << 4)
130 #define GEN6_STOLEN_RESERVED_512K	(1 << 4)
131 #define GEN6_STOLEN_RESERVED_256K	(2 << 4)
132 #define GEN6_STOLEN_RESERVED_128K	(3 << 4)
133 #define GEN7_STOLEN_RESERVED_SIZE_MASK	(1 << 5)
134 #define GEN7_STOLEN_RESERVED_1M		(0 << 5)
135 #define GEN7_STOLEN_RESERVED_256K	(1 << 5)
136 #define GEN8_STOLEN_RESERVED_SIZE_MASK	(3 << 7)
137 #define GEN8_STOLEN_RESERVED_1M		(0 << 7)
138 #define GEN8_STOLEN_RESERVED_2M		(1 << 7)
139 #define GEN8_STOLEN_RESERVED_4M		(2 << 7)
140 #define GEN8_STOLEN_RESERVED_8M		(3 << 7)
141 #define GEN6_STOLEN_RESERVED_ENABLE	(1 << 0)
142 #define GEN11_STOLEN_RESERVED_ADDR_MASK	(0xFFFFFFFFFFFULL << 20)
143 
144 #define _VGA_MSR_WRITE _MMIO(0x3c2)
145 
146 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
147 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
148 #define GEN7_PIPE_DE_LOAD_SL(pipe) _MMIO_PIPE(pipe, _GEN7_PIPEA_DE_LOAD_SL, _GEN7_PIPEB_DE_LOAD_SL)
149 
150 /*
151  * Reset registers
152  */
153 #define DEBUG_RESET_I830		_MMIO(0x6070)
154 #define  DEBUG_RESET_FULL		(1 << 7)
155 #define  DEBUG_RESET_RENDER		(1 << 8)
156 #define  DEBUG_RESET_DISPLAY		(1 << 9)
157 
158 /*
159  * IOSF sideband
160  */
161 #define VLV_IOSF_DOORBELL_REQ			_MMIO(VLV_DISPLAY_BASE + 0x2100)
162 #define   IOSF_DEVFN_SHIFT			24
163 #define   IOSF_OPCODE_SHIFT			16
164 #define   IOSF_PORT_SHIFT			8
165 #define   IOSF_BYTE_ENABLES_SHIFT		4
166 #define   IOSF_BAR_SHIFT			1
167 #define   IOSF_SB_BUSY				(1 << 0)
168 #define   IOSF_PORT_BUNIT			0x03
169 #define   IOSF_PORT_PUNIT			0x04
170 #define   IOSF_PORT_NC				0x11
171 #define   IOSF_PORT_DPIO			0x12
172 #define   IOSF_PORT_GPIO_NC			0x13
173 #define   IOSF_PORT_CCK				0x14
174 #define   IOSF_PORT_DPIO_2			0x1a
175 #define   IOSF_PORT_FLISDSI			0x1b
176 #define   IOSF_PORT_GPIO_SC			0x48
177 #define   IOSF_PORT_GPIO_SUS			0xa8
178 #define   IOSF_PORT_CCU				0xa9
179 #define   CHV_IOSF_PORT_GPIO_N			0x13
180 #define   CHV_IOSF_PORT_GPIO_SE			0x48
181 #define   CHV_IOSF_PORT_GPIO_E			0xa8
182 #define   CHV_IOSF_PORT_GPIO_SW			0xb2
183 #define VLV_IOSF_DATA				_MMIO(VLV_DISPLAY_BASE + 0x2104)
184 #define VLV_IOSF_ADDR				_MMIO(VLV_DISPLAY_BASE + 0x2108)
185 
186 /* DPIO registers */
187 #define DPIO_DEVFN			0
188 
189 #define DPIO_CTL			_MMIO(VLV_DISPLAY_BASE + 0x2110)
190 #define  DPIO_MODSEL1			(1 << 3) /* if ref clk b == 27 */
191 #define  DPIO_MODSEL0			(1 << 2) /* if ref clk a == 27 */
192 #define  DPIO_SFR_BYPASS		(1 << 1)
193 #define  DPIO_CMNRST			(1 << 0)
194 
195 #define DPIO_PHY(pipe)			((pipe) >> 1)
196 
197 /*
198  * Per pipe/PLL DPIO regs
199  */
200 #define _VLV_PLL_DW3_CH0		0x800c
201 #define   DPIO_POST_DIV_SHIFT		(28) /* 3 bits */
202 #define   DPIO_POST_DIV_DAC		0
203 #define   DPIO_POST_DIV_HDMIDP		1 /* DAC 225-400M rate */
204 #define   DPIO_POST_DIV_LVDS1		2
205 #define   DPIO_POST_DIV_LVDS2		3
206 #define   DPIO_K_SHIFT			(24) /* 4 bits */
207 #define   DPIO_P1_SHIFT			(21) /* 3 bits */
208 #define   DPIO_P2_SHIFT			(16) /* 5 bits */
209 #define   DPIO_N_SHIFT			(12) /* 4 bits */
210 #define   DPIO_ENABLE_CALIBRATION	(1 << 11)
211 #define   DPIO_M1DIV_SHIFT		(8) /* 3 bits */
212 #define   DPIO_M2DIV_MASK		0xff
213 #define _VLV_PLL_DW3_CH1		0x802c
214 #define VLV_PLL_DW3(ch) _PIPE(ch, _VLV_PLL_DW3_CH0, _VLV_PLL_DW3_CH1)
215 
216 #define _VLV_PLL_DW5_CH0		0x8014
217 #define   DPIO_REFSEL_OVERRIDE		27
218 #define   DPIO_PLL_MODESEL_SHIFT	24 /* 3 bits */
219 #define   DPIO_BIAS_CURRENT_CTL_SHIFT	21 /* 3 bits, always 0x7 */
220 #define   DPIO_PLL_REFCLK_SEL_SHIFT	16 /* 2 bits */
221 #define   DPIO_PLL_REFCLK_SEL_MASK	3
222 #define   DPIO_DRIVER_CTL_SHIFT		12 /* always set to 0x8 */
223 #define   DPIO_CLK_BIAS_CTL_SHIFT	8 /* always set to 0x5 */
224 #define _VLV_PLL_DW5_CH1		0x8034
225 #define VLV_PLL_DW5(ch) _PIPE(ch, _VLV_PLL_DW5_CH0, _VLV_PLL_DW5_CH1)
226 
227 #define _VLV_PLL_DW7_CH0		0x801c
228 #define _VLV_PLL_DW7_CH1		0x803c
229 #define VLV_PLL_DW7(ch) _PIPE(ch, _VLV_PLL_DW7_CH0, _VLV_PLL_DW7_CH1)
230 
231 #define _VLV_PLL_DW8_CH0		0x8040
232 #define _VLV_PLL_DW8_CH1		0x8060
233 #define VLV_PLL_DW8(ch) _PIPE(ch, _VLV_PLL_DW8_CH0, _VLV_PLL_DW8_CH1)
234 
235 #define VLV_PLL_DW9_BCAST		0xc044
236 #define _VLV_PLL_DW9_CH0		0x8044
237 #define _VLV_PLL_DW9_CH1		0x8064
238 #define VLV_PLL_DW9(ch) _PIPE(ch, _VLV_PLL_DW9_CH0, _VLV_PLL_DW9_CH1)
239 
240 #define _VLV_PLL_DW10_CH0		0x8048
241 #define _VLV_PLL_DW10_CH1		0x8068
242 #define VLV_PLL_DW10(ch) _PIPE(ch, _VLV_PLL_DW10_CH0, _VLV_PLL_DW10_CH1)
243 
244 #define _VLV_PLL_DW11_CH0		0x804c
245 #define _VLV_PLL_DW11_CH1		0x806c
246 #define VLV_PLL_DW11(ch) _PIPE(ch, _VLV_PLL_DW11_CH0, _VLV_PLL_DW11_CH1)
247 
248 /* Spec for ref block start counts at DW10 */
249 #define VLV_REF_DW13			0x80ac
250 
251 #define VLV_CMN_DW0			0x8100
252 
253 /*
254  * Per DDI channel DPIO regs
255  */
256 
257 #define _VLV_PCS_DW0_CH0		0x8200
258 #define _VLV_PCS_DW0_CH1		0x8400
259 #define   DPIO_PCS_TX_LANE2_RESET	(1 << 16)
260 #define   DPIO_PCS_TX_LANE1_RESET	(1 << 7)
261 #define   DPIO_LEFT_TXFIFO_RST_MASTER2	(1 << 4)
262 #define   DPIO_RIGHT_TXFIFO_RST_MASTER2	(1 << 3)
263 #define VLV_PCS_DW0(ch) _PORT(ch, _VLV_PCS_DW0_CH0, _VLV_PCS_DW0_CH1)
264 
265 #define _VLV_PCS01_DW0_CH0		0x200
266 #define _VLV_PCS23_DW0_CH0		0x400
267 #define _VLV_PCS01_DW0_CH1		0x2600
268 #define _VLV_PCS23_DW0_CH1		0x2800
269 #define VLV_PCS01_DW0(ch) _PORT(ch, _VLV_PCS01_DW0_CH0, _VLV_PCS01_DW0_CH1)
270 #define VLV_PCS23_DW0(ch) _PORT(ch, _VLV_PCS23_DW0_CH0, _VLV_PCS23_DW0_CH1)
271 
272 #define _VLV_PCS_DW1_CH0		0x8204
273 #define _VLV_PCS_DW1_CH1		0x8404
274 #define   CHV_PCS_REQ_SOFTRESET_EN	(1 << 23)
275 #define   DPIO_PCS_CLK_CRI_RXEB_EIOS_EN	(1 << 22)
276 #define   DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN (1 << 21)
277 #define   DPIO_PCS_CLK_DATAWIDTH_SHIFT	(6)
278 #define   DPIO_PCS_CLK_SOFT_RESET	(1 << 5)
279 #define VLV_PCS_DW1(ch) _PORT(ch, _VLV_PCS_DW1_CH0, _VLV_PCS_DW1_CH1)
280 
281 #define _VLV_PCS01_DW1_CH0		0x204
282 #define _VLV_PCS23_DW1_CH0		0x404
283 #define _VLV_PCS01_DW1_CH1		0x2604
284 #define _VLV_PCS23_DW1_CH1		0x2804
285 #define VLV_PCS01_DW1(ch) _PORT(ch, _VLV_PCS01_DW1_CH0, _VLV_PCS01_DW1_CH1)
286 #define VLV_PCS23_DW1(ch) _PORT(ch, _VLV_PCS23_DW1_CH0, _VLV_PCS23_DW1_CH1)
287 
288 #define _VLV_PCS_DW8_CH0		0x8220
289 #define _VLV_PCS_DW8_CH1		0x8420
290 #define   CHV_PCS_USEDCLKCHANNEL_OVRRIDE	(1 << 20)
291 #define   CHV_PCS_USEDCLKCHANNEL		(1 << 21)
292 #define VLV_PCS_DW8(ch) _PORT(ch, _VLV_PCS_DW8_CH0, _VLV_PCS_DW8_CH1)
293 
294 #define _VLV_PCS01_DW8_CH0		0x0220
295 #define _VLV_PCS23_DW8_CH0		0x0420
296 #define _VLV_PCS01_DW8_CH1		0x2620
297 #define _VLV_PCS23_DW8_CH1		0x2820
298 #define VLV_PCS01_DW8(port) _PORT(port, _VLV_PCS01_DW8_CH0, _VLV_PCS01_DW8_CH1)
299 #define VLV_PCS23_DW8(port) _PORT(port, _VLV_PCS23_DW8_CH0, _VLV_PCS23_DW8_CH1)
300 
301 #define _VLV_PCS_DW9_CH0		0x8224
302 #define _VLV_PCS_DW9_CH1		0x8424
303 #define   DPIO_PCS_TX2MARGIN_MASK	(0x7 << 13)
304 #define   DPIO_PCS_TX2MARGIN_000	(0 << 13)
305 #define   DPIO_PCS_TX2MARGIN_101	(1 << 13)
306 #define   DPIO_PCS_TX1MARGIN_MASK	(0x7 << 10)
307 #define   DPIO_PCS_TX1MARGIN_000	(0 << 10)
308 #define   DPIO_PCS_TX1MARGIN_101	(1 << 10)
309 #define	VLV_PCS_DW9(ch) _PORT(ch, _VLV_PCS_DW9_CH0, _VLV_PCS_DW9_CH1)
310 
311 #define _VLV_PCS01_DW9_CH0		0x224
312 #define _VLV_PCS23_DW9_CH0		0x424
313 #define _VLV_PCS01_DW9_CH1		0x2624
314 #define _VLV_PCS23_DW9_CH1		0x2824
315 #define VLV_PCS01_DW9(ch) _PORT(ch, _VLV_PCS01_DW9_CH0, _VLV_PCS01_DW9_CH1)
316 #define VLV_PCS23_DW9(ch) _PORT(ch, _VLV_PCS23_DW9_CH0, _VLV_PCS23_DW9_CH1)
317 
318 #define _CHV_PCS_DW10_CH0		0x8228
319 #define _CHV_PCS_DW10_CH1		0x8428
320 #define   DPIO_PCS_SWING_CALC_TX0_TX2	(1 << 30)
321 #define   DPIO_PCS_SWING_CALC_TX1_TX3	(1 << 31)
322 #define   DPIO_PCS_TX2DEEMP_MASK	(0xf << 24)
323 #define   DPIO_PCS_TX2DEEMP_9P5		(0 << 24)
324 #define   DPIO_PCS_TX2DEEMP_6P0		(2 << 24)
325 #define   DPIO_PCS_TX1DEEMP_MASK	(0xf << 16)
326 #define   DPIO_PCS_TX1DEEMP_9P5		(0 << 16)
327 #define   DPIO_PCS_TX1DEEMP_6P0		(2 << 16)
328 #define CHV_PCS_DW10(ch) _PORT(ch, _CHV_PCS_DW10_CH0, _CHV_PCS_DW10_CH1)
329 
330 #define _VLV_PCS01_DW10_CH0		0x0228
331 #define _VLV_PCS23_DW10_CH0		0x0428
332 #define _VLV_PCS01_DW10_CH1		0x2628
333 #define _VLV_PCS23_DW10_CH1		0x2828
334 #define VLV_PCS01_DW10(port) _PORT(port, _VLV_PCS01_DW10_CH0, _VLV_PCS01_DW10_CH1)
335 #define VLV_PCS23_DW10(port) _PORT(port, _VLV_PCS23_DW10_CH0, _VLV_PCS23_DW10_CH1)
336 
337 #define _VLV_PCS_DW11_CH0		0x822c
338 #define _VLV_PCS_DW11_CH1		0x842c
339 #define   DPIO_TX2_STAGGER_MASK(x)	((x) << 24)
340 #define   DPIO_LANEDESKEW_STRAP_OVRD	(1 << 3)
341 #define   DPIO_LEFT_TXFIFO_RST_MASTER	(1 << 1)
342 #define   DPIO_RIGHT_TXFIFO_RST_MASTER	(1 << 0)
343 #define VLV_PCS_DW11(ch) _PORT(ch, _VLV_PCS_DW11_CH0, _VLV_PCS_DW11_CH1)
344 
345 #define _VLV_PCS01_DW11_CH0		0x022c
346 #define _VLV_PCS23_DW11_CH0		0x042c
347 #define _VLV_PCS01_DW11_CH1		0x262c
348 #define _VLV_PCS23_DW11_CH1		0x282c
349 #define VLV_PCS01_DW11(ch) _PORT(ch, _VLV_PCS01_DW11_CH0, _VLV_PCS01_DW11_CH1)
350 #define VLV_PCS23_DW11(ch) _PORT(ch, _VLV_PCS23_DW11_CH0, _VLV_PCS23_DW11_CH1)
351 
352 #define _VLV_PCS01_DW12_CH0		0x0230
353 #define _VLV_PCS23_DW12_CH0		0x0430
354 #define _VLV_PCS01_DW12_CH1		0x2630
355 #define _VLV_PCS23_DW12_CH1		0x2830
356 #define VLV_PCS01_DW12(ch) _PORT(ch, _VLV_PCS01_DW12_CH0, _VLV_PCS01_DW12_CH1)
357 #define VLV_PCS23_DW12(ch) _PORT(ch, _VLV_PCS23_DW12_CH0, _VLV_PCS23_DW12_CH1)
358 
359 #define _VLV_PCS_DW12_CH0		0x8230
360 #define _VLV_PCS_DW12_CH1		0x8430
361 #define   DPIO_TX2_STAGGER_MULT(x)	((x) << 20)
362 #define   DPIO_TX1_STAGGER_MULT(x)	((x) << 16)
363 #define   DPIO_TX1_STAGGER_MASK(x)	((x) << 8)
364 #define   DPIO_LANESTAGGER_STRAP_OVRD	(1 << 6)
365 #define   DPIO_LANESTAGGER_STRAP(x)	((x) << 0)
366 #define VLV_PCS_DW12(ch) _PORT(ch, _VLV_PCS_DW12_CH0, _VLV_PCS_DW12_CH1)
367 
368 #define _VLV_PCS_DW14_CH0		0x8238
369 #define _VLV_PCS_DW14_CH1		0x8438
370 #define	VLV_PCS_DW14(ch) _PORT(ch, _VLV_PCS_DW14_CH0, _VLV_PCS_DW14_CH1)
371 
372 #define _VLV_PCS_DW23_CH0		0x825c
373 #define _VLV_PCS_DW23_CH1		0x845c
374 #define VLV_PCS_DW23(ch) _PORT(ch, _VLV_PCS_DW23_CH0, _VLV_PCS_DW23_CH1)
375 
376 #define _VLV_TX_DW2_CH0			0x8288
377 #define _VLV_TX_DW2_CH1			0x8488
378 #define   DPIO_SWING_MARGIN000_SHIFT	16
379 #define   DPIO_SWING_MARGIN000_MASK	(0xff << DPIO_SWING_MARGIN000_SHIFT)
380 #define   DPIO_UNIQ_TRANS_SCALE_SHIFT	8
381 #define VLV_TX_DW2(ch) _PORT(ch, _VLV_TX_DW2_CH0, _VLV_TX_DW2_CH1)
382 
383 #define _VLV_TX_DW3_CH0			0x828c
384 #define _VLV_TX_DW3_CH1			0x848c
385 /* The following bit for CHV phy */
386 #define   DPIO_TX_UNIQ_TRANS_SCALE_EN	(1 << 27)
387 #define   DPIO_SWING_MARGIN101_SHIFT	16
388 #define   DPIO_SWING_MARGIN101_MASK	(0xff << DPIO_SWING_MARGIN101_SHIFT)
389 #define VLV_TX_DW3(ch) _PORT(ch, _VLV_TX_DW3_CH0, _VLV_TX_DW3_CH1)
390 
391 #define _VLV_TX_DW4_CH0			0x8290
392 #define _VLV_TX_DW4_CH1			0x8490
393 #define   DPIO_SWING_DEEMPH9P5_SHIFT	24
394 #define   DPIO_SWING_DEEMPH9P5_MASK	(0xff << DPIO_SWING_DEEMPH9P5_SHIFT)
395 #define   DPIO_SWING_DEEMPH6P0_SHIFT	16
396 #define   DPIO_SWING_DEEMPH6P0_MASK	(0xff << DPIO_SWING_DEEMPH6P0_SHIFT)
397 #define VLV_TX_DW4(ch) _PORT(ch, _VLV_TX_DW4_CH0, _VLV_TX_DW4_CH1)
398 
399 #define _VLV_TX3_DW4_CH0		0x690
400 #define _VLV_TX3_DW4_CH1		0x2a90
401 #define VLV_TX3_DW4(ch) _PORT(ch, _VLV_TX3_DW4_CH0, _VLV_TX3_DW4_CH1)
402 
403 #define _VLV_TX_DW5_CH0			0x8294
404 #define _VLV_TX_DW5_CH1			0x8494
405 #define   DPIO_TX_OCALINIT_EN		(1 << 31)
406 #define VLV_TX_DW5(ch) _PORT(ch, _VLV_TX_DW5_CH0, _VLV_TX_DW5_CH1)
407 
408 #define _VLV_TX_DW11_CH0		0x82ac
409 #define _VLV_TX_DW11_CH1		0x84ac
410 #define VLV_TX_DW11(ch) _PORT(ch, _VLV_TX_DW11_CH0, _VLV_TX_DW11_CH1)
411 
412 #define _VLV_TX_DW14_CH0		0x82b8
413 #define _VLV_TX_DW14_CH1		0x84b8
414 #define VLV_TX_DW14(ch) _PORT(ch, _VLV_TX_DW14_CH0, _VLV_TX_DW14_CH1)
415 
416 /* CHV dpPhy registers */
417 #define _CHV_PLL_DW0_CH0		0x8000
418 #define _CHV_PLL_DW0_CH1		0x8180
419 #define CHV_PLL_DW0(ch) _PIPE(ch, _CHV_PLL_DW0_CH0, _CHV_PLL_DW0_CH1)
420 
421 #define _CHV_PLL_DW1_CH0		0x8004
422 #define _CHV_PLL_DW1_CH1		0x8184
423 #define   DPIO_CHV_N_DIV_SHIFT		8
424 #define   DPIO_CHV_M1_DIV_BY_2		(0 << 0)
425 #define CHV_PLL_DW1(ch) _PIPE(ch, _CHV_PLL_DW1_CH0, _CHV_PLL_DW1_CH1)
426 
427 #define _CHV_PLL_DW2_CH0		0x8008
428 #define _CHV_PLL_DW2_CH1		0x8188
429 #define CHV_PLL_DW2(ch) _PIPE(ch, _CHV_PLL_DW2_CH0, _CHV_PLL_DW2_CH1)
430 
431 #define _CHV_PLL_DW3_CH0		0x800c
432 #define _CHV_PLL_DW3_CH1		0x818c
433 #define  DPIO_CHV_FRAC_DIV_EN		(1 << 16)
434 #define  DPIO_CHV_FIRST_MOD		(0 << 8)
435 #define  DPIO_CHV_SECOND_MOD		(1 << 8)
436 #define  DPIO_CHV_FEEDFWD_GAIN_SHIFT	0
437 #define  DPIO_CHV_FEEDFWD_GAIN_MASK		(0xF << 0)
438 #define CHV_PLL_DW3(ch) _PIPE(ch, _CHV_PLL_DW3_CH0, _CHV_PLL_DW3_CH1)
439 
440 #define _CHV_PLL_DW6_CH0		0x8018
441 #define _CHV_PLL_DW6_CH1		0x8198
442 #define   DPIO_CHV_GAIN_CTRL_SHIFT	16
443 #define	  DPIO_CHV_INT_COEFF_SHIFT	8
444 #define   DPIO_CHV_PROP_COEFF_SHIFT	0
445 #define CHV_PLL_DW6(ch) _PIPE(ch, _CHV_PLL_DW6_CH0, _CHV_PLL_DW6_CH1)
446 
447 #define _CHV_PLL_DW8_CH0		0x8020
448 #define _CHV_PLL_DW8_CH1		0x81A0
449 #define   DPIO_CHV_TDC_TARGET_CNT_SHIFT 0
450 #define   DPIO_CHV_TDC_TARGET_CNT_MASK  (0x3FF << 0)
451 #define CHV_PLL_DW8(ch) _PIPE(ch, _CHV_PLL_DW8_CH0, _CHV_PLL_DW8_CH1)
452 
453 #define _CHV_PLL_DW9_CH0		0x8024
454 #define _CHV_PLL_DW9_CH1		0x81A4
455 #define  DPIO_CHV_INT_LOCK_THRESHOLD_SHIFT		1 /* 3 bits */
456 #define  DPIO_CHV_INT_LOCK_THRESHOLD_MASK		(7 << 1)
457 #define  DPIO_CHV_INT_LOCK_THRESHOLD_SEL_COARSE	1 /* 1: coarse & 0 : fine  */
458 #define CHV_PLL_DW9(ch) _PIPE(ch, _CHV_PLL_DW9_CH0, _CHV_PLL_DW9_CH1)
459 
460 #define _CHV_CMN_DW0_CH0               0x8100
461 #define   DPIO_ALLDL_POWERDOWN_SHIFT_CH0	19
462 #define   DPIO_ANYDL_POWERDOWN_SHIFT_CH0	18
463 #define   DPIO_ALLDL_POWERDOWN			(1 << 1)
464 #define   DPIO_ANYDL_POWERDOWN			(1 << 0)
465 
466 #define _CHV_CMN_DW5_CH0               0x8114
467 #define   CHV_BUFRIGHTENA1_DISABLE	(0 << 20)
468 #define   CHV_BUFRIGHTENA1_NORMAL	(1 << 20)
469 #define   CHV_BUFRIGHTENA1_FORCE	(3 << 20)
470 #define   CHV_BUFRIGHTENA1_MASK		(3 << 20)
471 #define   CHV_BUFLEFTENA1_DISABLE	(0 << 22)
472 #define   CHV_BUFLEFTENA1_NORMAL	(1 << 22)
473 #define   CHV_BUFLEFTENA1_FORCE		(3 << 22)
474 #define   CHV_BUFLEFTENA1_MASK		(3 << 22)
475 
476 #define _CHV_CMN_DW13_CH0		0x8134
477 #define _CHV_CMN_DW0_CH1		0x8080
478 #define   DPIO_CHV_S1_DIV_SHIFT		21
479 #define   DPIO_CHV_P1_DIV_SHIFT		13 /* 3 bits */
480 #define   DPIO_CHV_P2_DIV_SHIFT		8  /* 5 bits */
481 #define   DPIO_CHV_K_DIV_SHIFT		4
482 #define   DPIO_PLL_FREQLOCK		(1 << 1)
483 #define   DPIO_PLL_LOCK			(1 << 0)
484 #define CHV_CMN_DW13(ch) _PIPE(ch, _CHV_CMN_DW13_CH0, _CHV_CMN_DW0_CH1)
485 
486 #define _CHV_CMN_DW14_CH0		0x8138
487 #define _CHV_CMN_DW1_CH1		0x8084
488 #define   DPIO_AFC_RECAL		(1 << 14)
489 #define   DPIO_DCLKP_EN			(1 << 13)
490 #define   CHV_BUFLEFTENA2_DISABLE	(0 << 17) /* CL2 DW1 only */
491 #define   CHV_BUFLEFTENA2_NORMAL	(1 << 17) /* CL2 DW1 only */
492 #define   CHV_BUFLEFTENA2_FORCE		(3 << 17) /* CL2 DW1 only */
493 #define   CHV_BUFLEFTENA2_MASK		(3 << 17) /* CL2 DW1 only */
494 #define   CHV_BUFRIGHTENA2_DISABLE	(0 << 19) /* CL2 DW1 only */
495 #define   CHV_BUFRIGHTENA2_NORMAL	(1 << 19) /* CL2 DW1 only */
496 #define   CHV_BUFRIGHTENA2_FORCE	(3 << 19) /* CL2 DW1 only */
497 #define   CHV_BUFRIGHTENA2_MASK		(3 << 19) /* CL2 DW1 only */
498 #define CHV_CMN_DW14(ch) _PIPE(ch, _CHV_CMN_DW14_CH0, _CHV_CMN_DW1_CH1)
499 
500 #define _CHV_CMN_DW19_CH0		0x814c
501 #define _CHV_CMN_DW6_CH1		0x8098
502 #define   DPIO_ALLDL_POWERDOWN_SHIFT_CH1	30 /* CL2 DW6 only */
503 #define   DPIO_ANYDL_POWERDOWN_SHIFT_CH1	29 /* CL2 DW6 only */
504 #define   DPIO_DYNPWRDOWNEN_CH1		(1 << 28) /* CL2 DW6 only */
505 #define   CHV_CMN_USEDCLKCHANNEL	(1 << 13)
506 
507 #define CHV_CMN_DW19(ch) _PIPE(ch, _CHV_CMN_DW19_CH0, _CHV_CMN_DW6_CH1)
508 
509 #define CHV_CMN_DW28			0x8170
510 #define   DPIO_CL1POWERDOWNEN		(1 << 23)
511 #define   DPIO_DYNPWRDOWNEN_CH0		(1 << 22)
512 #define   DPIO_SUS_CLK_CONFIG_ON		(0 << 0)
513 #define   DPIO_SUS_CLK_CONFIG_CLKREQ		(1 << 0)
514 #define   DPIO_SUS_CLK_CONFIG_GATE		(2 << 0)
515 #define   DPIO_SUS_CLK_CONFIG_GATE_CLKREQ	(3 << 0)
516 
517 #define CHV_CMN_DW30			0x8178
518 #define   DPIO_CL2_LDOFUSE_PWRENB	(1 << 6)
519 #define   DPIO_LRC_BYPASS		(1 << 3)
520 
521 #define _TXLANE(ch, lane, offset) ((ch ? 0x2400 : 0) + \
522 					(lane) * 0x200 + (offset))
523 
524 #define CHV_TX_DW0(ch, lane) _TXLANE(ch, lane, 0x80)
525 #define CHV_TX_DW1(ch, lane) _TXLANE(ch, lane, 0x84)
526 #define CHV_TX_DW2(ch, lane) _TXLANE(ch, lane, 0x88)
527 #define CHV_TX_DW3(ch, lane) _TXLANE(ch, lane, 0x8c)
528 #define CHV_TX_DW4(ch, lane) _TXLANE(ch, lane, 0x90)
529 #define CHV_TX_DW5(ch, lane) _TXLANE(ch, lane, 0x94)
530 #define CHV_TX_DW6(ch, lane) _TXLANE(ch, lane, 0x98)
531 #define CHV_TX_DW7(ch, lane) _TXLANE(ch, lane, 0x9c)
532 #define CHV_TX_DW8(ch, lane) _TXLANE(ch, lane, 0xa0)
533 #define CHV_TX_DW9(ch, lane) _TXLANE(ch, lane, 0xa4)
534 #define CHV_TX_DW10(ch, lane) _TXLANE(ch, lane, 0xa8)
535 #define CHV_TX_DW11(ch, lane) _TXLANE(ch, lane, 0xac)
536 #define   DPIO_FRC_LATENCY_SHFIT	8
537 #define CHV_TX_DW14(ch, lane) _TXLANE(ch, lane, 0xb8)
538 #define   DPIO_UPAR_SHIFT		30
539 
540 /* BXT PHY registers */
541 #define _BXT_PHY0_BASE			0x6C000
542 #define _BXT_PHY1_BASE			0x162000
543 #define _BXT_PHY2_BASE			0x163000
544 #define BXT_PHY_BASE(phy)		_PHY3((phy), _BXT_PHY0_BASE, \
545 						     _BXT_PHY1_BASE, \
546 						     _BXT_PHY2_BASE)
547 
548 #define _BXT_PHY(phy, reg)						\
549 	_MMIO(BXT_PHY_BASE(phy) - _BXT_PHY0_BASE + (reg))
550 
551 #define _BXT_PHY_CH(phy, ch, reg_ch0, reg_ch1)		\
552 	(BXT_PHY_BASE(phy) + _PIPE((ch), (reg_ch0) - _BXT_PHY0_BASE,	\
553 					 (reg_ch1) - _BXT_PHY0_BASE))
554 #define _MMIO_BXT_PHY_CH(phy, ch, reg_ch0, reg_ch1)		\
555 	_MMIO(_BXT_PHY_CH(phy, ch, reg_ch0, reg_ch1))
556 
557 #define BXT_P_CR_GT_DISP_PWRON		_MMIO(0x138090)
558 #define  MIPIO_RST_CTRL				(1 << 2)
559 
560 #define _BXT_PHY_CTL_DDI_A		0x64C00
561 #define _BXT_PHY_CTL_DDI_B		0x64C10
562 #define _BXT_PHY_CTL_DDI_C		0x64C20
563 #define   BXT_PHY_CMNLANE_POWERDOWN_ACK	(1 << 10)
564 #define   BXT_PHY_LANE_POWERDOWN_ACK	(1 << 9)
565 #define   BXT_PHY_LANE_ENABLED		(1 << 8)
566 #define BXT_PHY_CTL(port)		_MMIO_PORT(port, _BXT_PHY_CTL_DDI_A, \
567 							 _BXT_PHY_CTL_DDI_B)
568 
569 #define _PHY_CTL_FAMILY_EDP		0x64C80
570 #define _PHY_CTL_FAMILY_DDI		0x64C90
571 #define _PHY_CTL_FAMILY_DDI_C		0x64CA0
572 #define   COMMON_RESET_DIS		(1 << 31)
573 #define BXT_PHY_CTL_FAMILY(phy)		_MMIO_PHY3((phy), _PHY_CTL_FAMILY_DDI, \
574 							  _PHY_CTL_FAMILY_EDP, \
575 							  _PHY_CTL_FAMILY_DDI_C)
576 
577 /* BXT PHY PLL registers */
578 #define _PORT_PLL_A			0x46074
579 #define _PORT_PLL_B			0x46078
580 #define _PORT_PLL_C			0x4607c
581 #define   PORT_PLL_ENABLE		REG_BIT(31)
582 #define   PORT_PLL_LOCK			REG_BIT(30)
583 #define   PORT_PLL_REF_SEL		REG_BIT(27)
584 #define   PORT_PLL_POWER_ENABLE		REG_BIT(26)
585 #define   PORT_PLL_POWER_STATE		REG_BIT(25)
586 #define BXT_PORT_PLL_ENABLE(port)	_MMIO_PORT(port, _PORT_PLL_A, _PORT_PLL_B)
587 
588 #define _PORT_PLL_EBB_0_A		0x162034
589 #define _PORT_PLL_EBB_0_B		0x6C034
590 #define _PORT_PLL_EBB_0_C		0x6C340
591 #define   PORT_PLL_P1_MASK		REG_GENMASK(15, 13)
592 #define   PORT_PLL_P1(p1)		REG_FIELD_PREP(PORT_PLL_P1_MASK, (p1))
593 #define   PORT_PLL_P2_MASK		REG_GENMASK(12, 8)
594 #define   PORT_PLL_P2(p2)		REG_FIELD_PREP(PORT_PLL_P2_MASK, (p2))
595 #define BXT_PORT_PLL_EBB_0(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
596 							 _PORT_PLL_EBB_0_B, \
597 							 _PORT_PLL_EBB_0_C)
598 
599 #define _PORT_PLL_EBB_4_A		0x162038
600 #define _PORT_PLL_EBB_4_B		0x6C038
601 #define _PORT_PLL_EBB_4_C		0x6C344
602 #define   PORT_PLL_RECALIBRATE		REG_BIT(14)
603 #define   PORT_PLL_10BIT_CLK_ENABLE	REG_BIT(13)
604 #define BXT_PORT_PLL_EBB_4(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
605 							 _PORT_PLL_EBB_4_B, \
606 							 _PORT_PLL_EBB_4_C)
607 
608 #define _PORT_PLL_0_A			0x162100
609 #define _PORT_PLL_0_B			0x6C100
610 #define _PORT_PLL_0_C			0x6C380
611 /* PORT_PLL_0_A */
612 #define   PORT_PLL_M2_INT_MASK		REG_GENMASK(7, 0)
613 #define   PORT_PLL_M2_INT(m2_int)	REG_FIELD_PREP(PORT_PLL_M2_INT_MASK, (m2_int))
614 /* PORT_PLL_1_A */
615 #define   PORT_PLL_N_MASK		REG_GENMASK(11, 8)
616 #define   PORT_PLL_N(n)			REG_FIELD_PREP(PORT_PLL_N_MASK, (n))
617 /* PORT_PLL_2_A */
618 #define   PORT_PLL_M2_FRAC_MASK		REG_GENMASK(21, 0)
619 #define   PORT_PLL_M2_FRAC(m2_frac)	REG_FIELD_PREP(PORT_PLL_M2_FRAC_MASK, (m2_frac))
620 /* PORT_PLL_3_A */
621 #define   PORT_PLL_M2_FRAC_ENABLE	REG_BIT(16)
622 /* PORT_PLL_6_A */
623 #define   PORT_PLL_GAIN_CTL_MASK	REG_GENMASK(18, 16)
624 #define   PORT_PLL_GAIN_CTL(x)		REG_FIELD_PREP(PORT_PLL_GAIN_CTL_MASK, (x))
625 #define   PORT_PLL_INT_COEFF_MASK	REG_GENMASK(12, 8)
626 #define   PORT_PLL_INT_COEFF(x)		REG_FIELD_PREP(PORT_PLL_INT_COEFF_MASK, (x))
627 #define   PORT_PLL_PROP_COEFF_MASK	REG_GENMASK(3, 0)
628 #define   PORT_PLL_PROP_COEFF(x)	REG_FIELD_PREP(PORT_PLL_PROP_COEFF_MASK, (x))
629 /* PORT_PLL_8_A */
630 #define   PORT_PLL_TARGET_CNT_MASK	REG_GENMASK(9, 0)
631 #define   PORT_PLL_TARGET_CNT(x)	REG_FIELD_PREP(PORT_PLL_TARGET_CNT_MASK, (x))
632 /* PORT_PLL_9_A */
633 #define  PORT_PLL_LOCK_THRESHOLD_MASK	REG_GENMASK(3, 1)
634 #define  PORT_PLL_LOCK_THRESHOLD(x)	REG_FIELD_PREP(PORT_PLL_LOCK_THRESHOLD_MASK, (x))
635 /* PORT_PLL_10_A */
636 #define  PORT_PLL_DCO_AMP_OVR_EN_H	REG_BIT(27)
637 #define  PORT_PLL_DCO_AMP_MASK		REG_GENMASK(13, 10)
638 #define  PORT_PLL_DCO_AMP(x)		REG_FIELD_PREP(PORT_PLL_DCO_AMP_MASK, (x))
639 #define _PORT_PLL_BASE(phy, ch)		_BXT_PHY_CH(phy, ch, \
640 						    _PORT_PLL_0_B, \
641 						    _PORT_PLL_0_C)
642 #define BXT_PORT_PLL(phy, ch, idx)	_MMIO(_PORT_PLL_BASE(phy, ch) + \
643 					      (idx) * 4)
644 
645 /* BXT PHY common lane registers */
646 #define _PORT_CL1CM_DW0_A		0x162000
647 #define _PORT_CL1CM_DW0_BC		0x6C000
648 #define   PHY_POWER_GOOD		(1 << 16)
649 #define   PHY_RESERVED			(1 << 7)
650 #define BXT_PORT_CL1CM_DW0(phy)		_BXT_PHY((phy), _PORT_CL1CM_DW0_BC)
651 
652 #define _PORT_CL1CM_DW9_A		0x162024
653 #define _PORT_CL1CM_DW9_BC		0x6C024
654 #define   IREF0RC_OFFSET_SHIFT		8
655 #define   IREF0RC_OFFSET_MASK		(0xFF << IREF0RC_OFFSET_SHIFT)
656 #define BXT_PORT_CL1CM_DW9(phy)		_BXT_PHY((phy), _PORT_CL1CM_DW9_BC)
657 
658 #define _PORT_CL1CM_DW10_A		0x162028
659 #define _PORT_CL1CM_DW10_BC		0x6C028
660 #define   IREF1RC_OFFSET_SHIFT		8
661 #define   IREF1RC_OFFSET_MASK		(0xFF << IREF1RC_OFFSET_SHIFT)
662 #define BXT_PORT_CL1CM_DW10(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW10_BC)
663 
664 #define _PORT_CL1CM_DW28_A		0x162070
665 #define _PORT_CL1CM_DW28_BC		0x6C070
666 #define   OCL1_POWER_DOWN_EN		(1 << 23)
667 #define   DW28_OLDO_DYN_PWR_DOWN_EN	(1 << 22)
668 #define   SUS_CLK_CONFIG		0x3
669 #define BXT_PORT_CL1CM_DW28(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW28_BC)
670 
671 #define _PORT_CL1CM_DW30_A		0x162078
672 #define _PORT_CL1CM_DW30_BC		0x6C078
673 #define   OCL2_LDOFUSE_PWR_DIS		(1 << 6)
674 #define BXT_PORT_CL1CM_DW30(phy)	_BXT_PHY((phy), _PORT_CL1CM_DW30_BC)
675 
676 /* The spec defines this only for BXT PHY0, but lets assume that this
677  * would exist for PHY1 too if it had a second channel.
678  */
679 #define _PORT_CL2CM_DW6_A		0x162358
680 #define _PORT_CL2CM_DW6_BC		0x6C358
681 #define BXT_PORT_CL2CM_DW6(phy)		_BXT_PHY((phy), _PORT_CL2CM_DW6_BC)
682 #define   DW6_OLDO_DYN_PWR_DOWN_EN	(1 << 28)
683 
684 /* BXT PHY Ref registers */
685 #define _PORT_REF_DW3_A			0x16218C
686 #define _PORT_REF_DW3_BC		0x6C18C
687 #define   GRC_DONE			(1 << 22)
688 #define BXT_PORT_REF_DW3(phy)		_BXT_PHY((phy), _PORT_REF_DW3_BC)
689 
690 #define _PORT_REF_DW6_A			0x162198
691 #define _PORT_REF_DW6_BC		0x6C198
692 #define   GRC_CODE_SHIFT		24
693 #define   GRC_CODE_MASK			(0xFF << GRC_CODE_SHIFT)
694 #define   GRC_CODE_FAST_SHIFT		16
695 #define   GRC_CODE_FAST_MASK		(0xFF << GRC_CODE_FAST_SHIFT)
696 #define   GRC_CODE_SLOW_SHIFT		8
697 #define   GRC_CODE_SLOW_MASK		(0xFF << GRC_CODE_SLOW_SHIFT)
698 #define   GRC_CODE_NOM_MASK		0xFF
699 #define BXT_PORT_REF_DW6(phy)		_BXT_PHY((phy), _PORT_REF_DW6_BC)
700 
701 #define _PORT_REF_DW8_A			0x1621A0
702 #define _PORT_REF_DW8_BC		0x6C1A0
703 #define   GRC_DIS			(1 << 15)
704 #define   GRC_RDY_OVRD			(1 << 1)
705 #define BXT_PORT_REF_DW8(phy)		_BXT_PHY((phy), _PORT_REF_DW8_BC)
706 
707 /* BXT PHY PCS registers */
708 #define _PORT_PCS_DW10_LN01_A		0x162428
709 #define _PORT_PCS_DW10_LN01_B		0x6C428
710 #define _PORT_PCS_DW10_LN01_C		0x6C828
711 #define _PORT_PCS_DW10_GRP_A		0x162C28
712 #define _PORT_PCS_DW10_GRP_B		0x6CC28
713 #define _PORT_PCS_DW10_GRP_C		0x6CE28
714 #define BXT_PORT_PCS_DW10_LN01(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
715 							 _PORT_PCS_DW10_LN01_B, \
716 							 _PORT_PCS_DW10_LN01_C)
717 #define BXT_PORT_PCS_DW10_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
718 							 _PORT_PCS_DW10_GRP_B, \
719 							 _PORT_PCS_DW10_GRP_C)
720 
721 #define   TX2_SWING_CALC_INIT		(1 << 31)
722 #define   TX1_SWING_CALC_INIT		(1 << 30)
723 
724 #define _PORT_PCS_DW12_LN01_A		0x162430
725 #define _PORT_PCS_DW12_LN01_B		0x6C430
726 #define _PORT_PCS_DW12_LN01_C		0x6C830
727 #define _PORT_PCS_DW12_LN23_A		0x162630
728 #define _PORT_PCS_DW12_LN23_B		0x6C630
729 #define _PORT_PCS_DW12_LN23_C		0x6CA30
730 #define _PORT_PCS_DW12_GRP_A		0x162c30
731 #define _PORT_PCS_DW12_GRP_B		0x6CC30
732 #define _PORT_PCS_DW12_GRP_C		0x6CE30
733 #define   LANESTAGGER_STRAP_OVRD	(1 << 6)
734 #define   LANE_STAGGER_MASK		0x1F
735 #define BXT_PORT_PCS_DW12_LN01(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
736 							 _PORT_PCS_DW12_LN01_B, \
737 							 _PORT_PCS_DW12_LN01_C)
738 #define BXT_PORT_PCS_DW12_LN23(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
739 							 _PORT_PCS_DW12_LN23_B, \
740 							 _PORT_PCS_DW12_LN23_C)
741 #define BXT_PORT_PCS_DW12_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
742 							 _PORT_PCS_DW12_GRP_B, \
743 							 _PORT_PCS_DW12_GRP_C)
744 
745 /* BXT PHY TX registers */
746 #define _BXT_LANE_OFFSET(lane)           (((lane) >> 1) * 0x200 +	\
747 					  ((lane) & 1) * 0x80)
748 
749 #define _PORT_TX_DW2_LN0_A		0x162508
750 #define _PORT_TX_DW2_LN0_B		0x6C508
751 #define _PORT_TX_DW2_LN0_C		0x6C908
752 #define _PORT_TX_DW2_GRP_A		0x162D08
753 #define _PORT_TX_DW2_GRP_B		0x6CD08
754 #define _PORT_TX_DW2_GRP_C		0x6CF08
755 #define BXT_PORT_TX_DW2_LN0(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
756 							 _PORT_TX_DW2_LN0_B, \
757 							 _PORT_TX_DW2_LN0_C)
758 #define BXT_PORT_TX_DW2_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
759 							 _PORT_TX_DW2_GRP_B, \
760 							 _PORT_TX_DW2_GRP_C)
761 #define   MARGIN_000_SHIFT		16
762 #define   MARGIN_000			(0xFF << MARGIN_000_SHIFT)
763 #define   UNIQ_TRANS_SCALE_SHIFT	8
764 #define   UNIQ_TRANS_SCALE		(0xFF << UNIQ_TRANS_SCALE_SHIFT)
765 
766 #define _PORT_TX_DW3_LN0_A		0x16250C
767 #define _PORT_TX_DW3_LN0_B		0x6C50C
768 #define _PORT_TX_DW3_LN0_C		0x6C90C
769 #define _PORT_TX_DW3_GRP_A		0x162D0C
770 #define _PORT_TX_DW3_GRP_B		0x6CD0C
771 #define _PORT_TX_DW3_GRP_C		0x6CF0C
772 #define BXT_PORT_TX_DW3_LN0(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
773 							 _PORT_TX_DW3_LN0_B, \
774 							 _PORT_TX_DW3_LN0_C)
775 #define BXT_PORT_TX_DW3_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
776 							 _PORT_TX_DW3_GRP_B, \
777 							 _PORT_TX_DW3_GRP_C)
778 #define   SCALE_DCOMP_METHOD		(1 << 26)
779 #define   UNIQUE_TRANGE_EN_METHOD	(1 << 27)
780 
781 #define _PORT_TX_DW4_LN0_A		0x162510
782 #define _PORT_TX_DW4_LN0_B		0x6C510
783 #define _PORT_TX_DW4_LN0_C		0x6C910
784 #define _PORT_TX_DW4_GRP_A		0x162D10
785 #define _PORT_TX_DW4_GRP_B		0x6CD10
786 #define _PORT_TX_DW4_GRP_C		0x6CF10
787 #define BXT_PORT_TX_DW4_LN0(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
788 							 _PORT_TX_DW4_LN0_B, \
789 							 _PORT_TX_DW4_LN0_C)
790 #define BXT_PORT_TX_DW4_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
791 							 _PORT_TX_DW4_GRP_B, \
792 							 _PORT_TX_DW4_GRP_C)
793 #define   DEEMPH_SHIFT			24
794 #define   DE_EMPHASIS			(0xFF << DEEMPH_SHIFT)
795 
796 #define _PORT_TX_DW5_LN0_A		0x162514
797 #define _PORT_TX_DW5_LN0_B		0x6C514
798 #define _PORT_TX_DW5_LN0_C		0x6C914
799 #define _PORT_TX_DW5_GRP_A		0x162D14
800 #define _PORT_TX_DW5_GRP_B		0x6CD14
801 #define _PORT_TX_DW5_GRP_C		0x6CF14
802 #define BXT_PORT_TX_DW5_LN0(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
803 							 _PORT_TX_DW5_LN0_B, \
804 							 _PORT_TX_DW5_LN0_C)
805 #define BXT_PORT_TX_DW5_GRP(phy, ch)	_MMIO_BXT_PHY_CH(phy, ch, \
806 							 _PORT_TX_DW5_GRP_B, \
807 							 _PORT_TX_DW5_GRP_C)
808 #define   DCC_DELAY_RANGE_1		(1 << 9)
809 #define   DCC_DELAY_RANGE_2		(1 << 8)
810 
811 #define _PORT_TX_DW14_LN0_A		0x162538
812 #define _PORT_TX_DW14_LN0_B		0x6C538
813 #define _PORT_TX_DW14_LN0_C		0x6C938
814 #define   LATENCY_OPTIM_SHIFT		30
815 #define   LATENCY_OPTIM			(1 << LATENCY_OPTIM_SHIFT)
816 #define BXT_PORT_TX_DW14_LN(phy, ch, lane)				\
817 	_MMIO(_BXT_PHY_CH(phy, ch, _PORT_TX_DW14_LN0_B,			\
818 				   _PORT_TX_DW14_LN0_C) +		\
819 	      _BXT_LANE_OFFSET(lane))
820 
821 /* UAIMI scratch pad register 1 */
822 #define UAIMI_SPR1			_MMIO(0x4F074)
823 /* SKL VccIO mask */
824 #define SKL_VCCIO_MASK			0x1
825 /* SKL balance leg register */
826 #define DISPIO_CR_TX_BMU_CR0		_MMIO(0x6C00C)
827 /* I_boost values */
828 #define BALANCE_LEG_SHIFT(port)		(8 + 3 * (port))
829 #define BALANCE_LEG_MASK(port)		(7 << (8 + 3 * (port)))
830 /* Balance leg disable bits */
831 #define BALANCE_LEG_DISABLE_SHIFT	23
832 #define BALANCE_LEG_DISABLE(port)	(1 << (23 + (port)))
833 
834 /*
835  * Fence registers
836  * [0-7]  @ 0x2000 gen2,gen3
837  * [8-15] @ 0x3000 945,g33,pnv
838  *
839  * [0-15] @ 0x3000 gen4,gen5
840  *
841  * [0-15] @ 0x100000 gen6,vlv,chv
842  * [0-31] @ 0x100000 gen7+
843  */
844 #define FENCE_REG(i)			_MMIO(0x2000 + (((i) & 8) << 9) + ((i) & 7) * 4)
845 #define   I830_FENCE_START_MASK		0x07f80000
846 #define   I830_FENCE_TILING_Y_SHIFT	12
847 #define   I830_FENCE_SIZE_BITS(size)	((ffs((size) >> 19) - 1) << 8)
848 #define   I830_FENCE_PITCH_SHIFT	4
849 #define   I830_FENCE_REG_VALID		(1 << 0)
850 #define   I915_FENCE_MAX_PITCH_VAL	4
851 #define   I830_FENCE_MAX_PITCH_VAL	6
852 #define   I830_FENCE_MAX_SIZE_VAL	(1 << 8)
853 
854 #define   I915_FENCE_START_MASK		0x0ff00000
855 #define   I915_FENCE_SIZE_BITS(size)	((ffs((size) >> 20) - 1) << 8)
856 
857 #define FENCE_REG_965_LO(i)		_MMIO(0x03000 + (i) * 8)
858 #define FENCE_REG_965_HI(i)		_MMIO(0x03000 + (i) * 8 + 4)
859 #define   I965_FENCE_PITCH_SHIFT	2
860 #define   I965_FENCE_TILING_Y_SHIFT	1
861 #define   I965_FENCE_REG_VALID		(1 << 0)
862 #define   I965_FENCE_MAX_PITCH_VAL	0x0400
863 
864 #define FENCE_REG_GEN6_LO(i)		_MMIO(0x100000 + (i) * 8)
865 #define FENCE_REG_GEN6_HI(i)		_MMIO(0x100000 + (i) * 8 + 4)
866 #define   GEN6_FENCE_PITCH_SHIFT	32
867 #define   GEN7_FENCE_MAX_PITCH_VAL	0x0800
868 
869 
870 /* control register for cpu gtt access */
871 #define TILECTL				_MMIO(0x101000)
872 #define   TILECTL_SWZCTL			(1 << 0)
873 #define   TILECTL_TLBPF			(1 << 1)
874 #define   TILECTL_TLB_PREFETCH_DIS	(1 << 2)
875 #define   TILECTL_BACKSNOOP_DIS		(1 << 3)
876 
877 /*
878  * Instruction and interrupt control regs
879  */
880 #define PGTBL_CTL	_MMIO(0x02020)
881 #define   PGTBL_ADDRESS_LO_MASK	0xfffff000 /* bits [31:12] */
882 #define   PGTBL_ADDRESS_HI_MASK	0x000000f0 /* bits [35:32] (gen4) */
883 #define PGTBL_ER	_MMIO(0x02024)
884 #define PRB0_BASE	(0x2030 - 0x30)
885 #define PRB1_BASE	(0x2040 - 0x30) /* 830,gen3 */
886 #define PRB2_BASE	(0x2050 - 0x30) /* gen3 */
887 #define SRB0_BASE	(0x2100 - 0x30) /* gen2 */
888 #define SRB1_BASE	(0x2110 - 0x30) /* gen2 */
889 #define SRB2_BASE	(0x2120 - 0x30) /* 830 */
890 #define SRB3_BASE	(0x2130 - 0x30) /* 830 */
891 #define RENDER_RING_BASE	0x02000
892 #define BSD_RING_BASE		0x04000
893 #define GEN6_BSD_RING_BASE	0x12000
894 #define GEN8_BSD2_RING_BASE	0x1c000
895 #define GEN11_BSD_RING_BASE	0x1c0000
896 #define GEN11_BSD2_RING_BASE	0x1c4000
897 #define GEN11_BSD3_RING_BASE	0x1d0000
898 #define GEN11_BSD4_RING_BASE	0x1d4000
899 #define XEHP_BSD5_RING_BASE	0x1e0000
900 #define XEHP_BSD6_RING_BASE	0x1e4000
901 #define XEHP_BSD7_RING_BASE	0x1f0000
902 #define XEHP_BSD8_RING_BASE	0x1f4000
903 #define VEBOX_RING_BASE		0x1a000
904 #define GEN11_VEBOX_RING_BASE		0x1c8000
905 #define GEN11_VEBOX2_RING_BASE		0x1d8000
906 #define XEHP_VEBOX3_RING_BASE		0x1e8000
907 #define XEHP_VEBOX4_RING_BASE		0x1f8000
908 #define MTL_GSC_RING_BASE		0x11a000
909 #define GEN12_COMPUTE0_RING_BASE	0x1a000
910 #define GEN12_COMPUTE1_RING_BASE	0x1c000
911 #define GEN12_COMPUTE2_RING_BASE	0x1e000
912 #define GEN12_COMPUTE3_RING_BASE	0x26000
913 #define BLT_RING_BASE		0x22000
914 #define XEHPC_BCS1_RING_BASE	0x3e0000
915 #define XEHPC_BCS2_RING_BASE	0x3e2000
916 #define XEHPC_BCS3_RING_BASE	0x3e4000
917 #define XEHPC_BCS4_RING_BASE	0x3e6000
918 #define XEHPC_BCS5_RING_BASE	0x3e8000
919 #define XEHPC_BCS6_RING_BASE	0x3ea000
920 #define XEHPC_BCS7_RING_BASE	0x3ec000
921 #define XEHPC_BCS8_RING_BASE	0x3ee000
922 #define DG1_GSC_HECI1_BASE	0x00258000
923 #define DG1_GSC_HECI2_BASE	0x00259000
924 #define DG2_GSC_HECI1_BASE	0x00373000
925 #define DG2_GSC_HECI2_BASE	0x00374000
926 
927 
928 
929 #define HSW_GTT_CACHE_EN	_MMIO(0x4024)
930 #define   GTT_CACHE_EN_ALL	0xF0007FFF
931 #define GEN7_WR_WATERMARK	_MMIO(0x4028)
932 #define GEN7_GFX_PRIO_CTRL	_MMIO(0x402C)
933 #define ARB_MODE		_MMIO(0x4030)
934 #define   ARB_MODE_SWIZZLE_SNB	(1 << 4)
935 #define   ARB_MODE_SWIZZLE_IVB	(1 << 5)
936 #define GEN7_GFX_PEND_TLB0	_MMIO(0x4034)
937 #define GEN7_GFX_PEND_TLB1	_MMIO(0x4038)
938 /* L3, CVS, ZTLB, RCC, CASC LRA min, max values */
939 #define GEN7_LRA_LIMITS(i)	_MMIO(0x403C + (i) * 4)
940 #define GEN7_LRA_LIMITS_REG_NUM	13
941 #define GEN7_MEDIA_MAX_REQ_COUNT	_MMIO(0x4070)
942 #define GEN7_GFX_MAX_REQ_COUNT		_MMIO(0x4074)
943 
944 #define GEN7_ERR_INT	_MMIO(0x44040)
945 #define   ERR_INT_POISON		(1 << 31)
946 #define   ERR_INT_MMIO_UNCLAIMED	(1 << 13)
947 #define   ERR_INT_PIPE_CRC_DONE_C	(1 << 8)
948 #define   ERR_INT_FIFO_UNDERRUN_C	(1 << 6)
949 #define   ERR_INT_PIPE_CRC_DONE_B	(1 << 5)
950 #define   ERR_INT_FIFO_UNDERRUN_B	(1 << 3)
951 #define   ERR_INT_PIPE_CRC_DONE_A	(1 << 2)
952 #define   ERR_INT_PIPE_CRC_DONE(pipe)	(1 << (2 + (pipe) * 3))
953 #define   ERR_INT_FIFO_UNDERRUN_A	(1 << 0)
954 #define   ERR_INT_FIFO_UNDERRUN(pipe)	(1 << ((pipe) * 3))
955 
956 #define FPGA_DBG		_MMIO(0x42300)
957 #define   FPGA_DBG_RM_NOCLAIM	REG_BIT(31)
958 
959 #define CLAIM_ER		_MMIO(VLV_DISPLAY_BASE + 0x2028)
960 #define   CLAIM_ER_CLR		REG_BIT(31)
961 #define   CLAIM_ER_OVERFLOW	REG_BIT(16)
962 #define   CLAIM_ER_CTR_MASK	REG_GENMASK(15, 0)
963 
964 #define DERRMR		_MMIO(0x44050)
965 /* Note that HBLANK events are reserved on bdw+ */
966 #define   DERRMR_PIPEA_SCANLINE		(1 << 0)
967 #define   DERRMR_PIPEA_PRI_FLIP_DONE	(1 << 1)
968 #define   DERRMR_PIPEA_SPR_FLIP_DONE	(1 << 2)
969 #define   DERRMR_PIPEA_VBLANK		(1 << 3)
970 #define   DERRMR_PIPEA_HBLANK		(1 << 5)
971 #define   DERRMR_PIPEB_SCANLINE		(1 << 8)
972 #define   DERRMR_PIPEB_PRI_FLIP_DONE	(1 << 9)
973 #define   DERRMR_PIPEB_SPR_FLIP_DONE	(1 << 10)
974 #define   DERRMR_PIPEB_VBLANK		(1 << 11)
975 #define   DERRMR_PIPEB_HBLANK		(1 << 13)
976 /* Note that PIPEC is not a simple translation of PIPEA/PIPEB */
977 #define   DERRMR_PIPEC_SCANLINE		(1 << 14)
978 #define   DERRMR_PIPEC_PRI_FLIP_DONE	(1 << 15)
979 #define   DERRMR_PIPEC_SPR_FLIP_DONE	(1 << 20)
980 #define   DERRMR_PIPEC_VBLANK		(1 << 21)
981 #define   DERRMR_PIPEC_HBLANK		(1 << 22)
982 
983 #define VLV_GU_CTL0	_MMIO(VLV_DISPLAY_BASE + 0x2030)
984 #define VLV_GU_CTL1	_MMIO(VLV_DISPLAY_BASE + 0x2034)
985 #define SCPD0		_MMIO(0x209c) /* 915+ only */
986 #define  SCPD_FBC_IGNORE_3D			(1 << 6)
987 #define  CSTATE_RENDER_CLOCK_GATE_DISABLE	(1 << 5)
988 #define GEN2_IER	_MMIO(0x20a0)
989 #define GEN2_IIR	_MMIO(0x20a4)
990 #define GEN2_IMR	_MMIO(0x20a8)
991 #define GEN2_ISR	_MMIO(0x20ac)
992 #define VLV_GUNIT_CLOCK_GATE	_MMIO(VLV_DISPLAY_BASE + 0x2060)
993 #define   GINT_DIS		(1 << 22)
994 #define   GCFG_DIS		(1 << 8)
995 #define VLV_GUNIT_CLOCK_GATE2	_MMIO(VLV_DISPLAY_BASE + 0x2064)
996 #define VLV_IIR_RW	_MMIO(VLV_DISPLAY_BASE + 0x2084)
997 #define VLV_IER		_MMIO(VLV_DISPLAY_BASE + 0x20a0)
998 #define VLV_IIR		_MMIO(VLV_DISPLAY_BASE + 0x20a4)
999 #define VLV_IMR		_MMIO(VLV_DISPLAY_BASE + 0x20a8)
1000 #define VLV_ISR		_MMIO(VLV_DISPLAY_BASE + 0x20ac)
1001 #define VLV_PCBR	_MMIO(VLV_DISPLAY_BASE + 0x2120)
1002 #define VLV_PCBR_ADDR_SHIFT	12
1003 
1004 #define   DISPLAY_PLANE_FLIP_PENDING(plane) (1 << (11 - (plane))) /* A and B only */
1005 #define EIR		_MMIO(0x20b0)
1006 #define EMR		_MMIO(0x20b4)
1007 #define ESR		_MMIO(0x20b8)
1008 #define   GM45_ERROR_PAGE_TABLE				(1 << 5)
1009 #define   GM45_ERROR_MEM_PRIV				(1 << 4)
1010 #define   I915_ERROR_PAGE_TABLE				(1 << 4)
1011 #define   GM45_ERROR_CP_PRIV				(1 << 3)
1012 #define   I915_ERROR_MEMORY_REFRESH			(1 << 1)
1013 #define   I915_ERROR_INSTRUCTION			(1 << 0)
1014 #define INSTPM	        _MMIO(0x20c0)
1015 #define   INSTPM_SELF_EN (1 << 12) /* 915GM only */
1016 #define   INSTPM_AGPBUSY_INT_EN (1 << 11) /* gen3: when disabled, pending interrupts
1017 					will not assert AGPBUSY# and will only
1018 					be delivered when out of C3. */
1019 #define   INSTPM_FORCE_ORDERING				(1 << 7) /* GEN6+ */
1020 #define   INSTPM_TLB_INVALIDATE	(1 << 9)
1021 #define   INSTPM_SYNC_FLUSH	(1 << 5)
1022 #define MEM_MODE	_MMIO(0x20cc)
1023 #define   MEM_DISPLAY_B_TRICKLE_FEED_DISABLE (1 << 3) /* 830 only */
1024 #define   MEM_DISPLAY_A_TRICKLE_FEED_DISABLE (1 << 2) /* 830/845 only */
1025 #define   MEM_DISPLAY_TRICKLE_FEED_DISABLE (1 << 2) /* 85x only */
1026 #define FW_BLC		_MMIO(0x20d8)
1027 #define FW_BLC2		_MMIO(0x20dc)
1028 #define FW_BLC_SELF	_MMIO(0x20e0) /* 915+ only */
1029 #define   FW_BLC_SELF_EN_MASK      (1 << 31)
1030 #define   FW_BLC_SELF_FIFO_MASK    (1 << 16) /* 945 only */
1031 #define   FW_BLC_SELF_EN           (1 << 15) /* 945 only */
1032 #define MM_BURST_LENGTH     0x00700000
1033 #define MM_FIFO_WATERMARK   0x0001F000
1034 #define LM_BURST_LENGTH     0x00000700
1035 #define LM_FIFO_WATERMARK   0x0000001F
1036 #define MI_ARB_STATE	_MMIO(0x20e4) /* 915+ only */
1037 
1038 #define _MBUS_ABOX0_CTL			0x45038
1039 #define _MBUS_ABOX1_CTL			0x45048
1040 #define _MBUS_ABOX2_CTL			0x4504C
1041 #define MBUS_ABOX_CTL(x)		_MMIO(_PICK(x, _MBUS_ABOX0_CTL, \
1042 						    _MBUS_ABOX1_CTL, \
1043 						    _MBUS_ABOX2_CTL))
1044 #define MBUS_ABOX_BW_CREDIT_MASK	(3 << 20)
1045 #define MBUS_ABOX_BW_CREDIT(x)		((x) << 20)
1046 #define MBUS_ABOX_B_CREDIT_MASK		(0xF << 16)
1047 #define MBUS_ABOX_B_CREDIT(x)		((x) << 16)
1048 #define MBUS_ABOX_BT_CREDIT_POOL2_MASK	(0x1F << 8)
1049 #define MBUS_ABOX_BT_CREDIT_POOL2(x)	((x) << 8)
1050 #define MBUS_ABOX_BT_CREDIT_POOL1_MASK	(0x1F << 0)
1051 #define MBUS_ABOX_BT_CREDIT_POOL1(x)	((x) << 0)
1052 
1053 #define _PIPEA_MBUS_DBOX_CTL			0x7003C
1054 #define _PIPEB_MBUS_DBOX_CTL			0x7103C
1055 #define PIPE_MBUS_DBOX_CTL(pipe)		_MMIO_PIPE(pipe, _PIPEA_MBUS_DBOX_CTL, \
1056 							   _PIPEB_MBUS_DBOX_CTL)
1057 #define MBUS_DBOX_B2B_TRANSACTIONS_MAX_MASK	REG_GENMASK(24, 20) /* tgl+ */
1058 #define MBUS_DBOX_B2B_TRANSACTIONS_MAX(x)	REG_FIELD_PREP(MBUS_DBOX_B2B_TRANSACTIONS_MAX_MASK, x)
1059 #define MBUS_DBOX_B2B_TRANSACTIONS_DELAY_MASK	REG_GENMASK(19, 17) /* tgl+ */
1060 #define MBUS_DBOX_B2B_TRANSACTIONS_DELAY(x)	REG_FIELD_PREP(MBUS_DBOX_B2B_TRANSACTIONS_DELAY_MASK, x)
1061 #define MBUS_DBOX_REGULATE_B2B_TRANSACTIONS_EN	REG_BIT(16) /* tgl+ */
1062 #define MBUS_DBOX_BW_CREDIT_MASK		REG_GENMASK(15, 14)
1063 #define MBUS_DBOX_BW_CREDIT(x)			REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, x)
1064 #define MBUS_DBOX_BW_4CREDITS_MTL		REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, 0x2)
1065 #define MBUS_DBOX_BW_8CREDITS_MTL		REG_FIELD_PREP(MBUS_DBOX_BW_CREDIT_MASK, 0x3)
1066 #define MBUS_DBOX_B_CREDIT_MASK			REG_GENMASK(12, 8)
1067 #define MBUS_DBOX_B_CREDIT(x)			REG_FIELD_PREP(MBUS_DBOX_B_CREDIT_MASK, x)
1068 #define MBUS_DBOX_I_CREDIT_MASK			REG_GENMASK(7, 5)
1069 #define MBUS_DBOX_I_CREDIT(x)			REG_FIELD_PREP(MBUS_DBOX_I_CREDIT_MASK, x)
1070 #define MBUS_DBOX_A_CREDIT_MASK			REG_GENMASK(3, 0)
1071 #define MBUS_DBOX_A_CREDIT(x)			REG_FIELD_PREP(MBUS_DBOX_A_CREDIT_MASK, x)
1072 
1073 #define MBUS_UBOX_CTL			_MMIO(0x4503C)
1074 #define MBUS_BBOX_CTL_S1		_MMIO(0x45040)
1075 #define MBUS_BBOX_CTL_S2		_MMIO(0x45044)
1076 
1077 #define MBUS_CTL			_MMIO(0x4438C)
1078 #define MBUS_JOIN			REG_BIT(31)
1079 #define MBUS_HASHING_MODE_MASK		REG_BIT(30)
1080 #define MBUS_HASHING_MODE_2x2		REG_FIELD_PREP(MBUS_HASHING_MODE_MASK, 0)
1081 #define MBUS_HASHING_MODE_1x4		REG_FIELD_PREP(MBUS_HASHING_MODE_MASK, 1)
1082 #define MBUS_JOIN_PIPE_SELECT_MASK	REG_GENMASK(28, 26)
1083 #define MBUS_JOIN_PIPE_SELECT(pipe)	REG_FIELD_PREP(MBUS_JOIN_PIPE_SELECT_MASK, pipe)
1084 #define MBUS_JOIN_PIPE_SELECT_NONE	MBUS_JOIN_PIPE_SELECT(7)
1085 
1086 /* Make render/texture TLB fetches lower priorty than associated data
1087  *   fetches. This is not turned on by default
1088  */
1089 #define   MI_ARB_RENDER_TLB_LOW_PRIORITY	(1 << 15)
1090 
1091 /* Isoch request wait on GTT enable (Display A/B/C streams).
1092  * Make isoch requests stall on the TLB update. May cause
1093  * display underruns (test mode only)
1094  */
1095 #define   MI_ARB_ISOCH_WAIT_GTT			(1 << 14)
1096 
1097 /* Block grant count for isoch requests when block count is
1098  * set to a finite value.
1099  */
1100 #define   MI_ARB_BLOCK_GRANT_MASK		(3 << 12)
1101 #define   MI_ARB_BLOCK_GRANT_8			(0 << 12)	/* for 3 display planes */
1102 #define   MI_ARB_BLOCK_GRANT_4			(1 << 12)	/* for 2 display planes */
1103 #define   MI_ARB_BLOCK_GRANT_2			(2 << 12)	/* for 1 display plane */
1104 #define   MI_ARB_BLOCK_GRANT_0			(3 << 12)	/* don't use */
1105 
1106 /* Enable render writes to complete in C2/C3/C4 power states.
1107  * If this isn't enabled, render writes are prevented in low
1108  * power states. That seems bad to me.
1109  */
1110 #define   MI_ARB_C3_LP_WRITE_ENABLE		(1 << 11)
1111 
1112 /* This acknowledges an async flip immediately instead
1113  * of waiting for 2TLB fetches.
1114  */
1115 #define   MI_ARB_ASYNC_FLIP_ACK_IMMEDIATE	(1 << 10)
1116 
1117 /* Enables non-sequential data reads through arbiter
1118  */
1119 #define   MI_ARB_DUAL_DATA_PHASE_DISABLE	(1 << 9)
1120 
1121 /* Disable FSB snooping of cacheable write cycles from binner/render
1122  * command stream
1123  */
1124 #define   MI_ARB_CACHE_SNOOP_DISABLE		(1 << 8)
1125 
1126 /* Arbiter time slice for non-isoch streams */
1127 #define   MI_ARB_TIME_SLICE_MASK		(7 << 5)
1128 #define   MI_ARB_TIME_SLICE_1			(0 << 5)
1129 #define   MI_ARB_TIME_SLICE_2			(1 << 5)
1130 #define   MI_ARB_TIME_SLICE_4			(2 << 5)
1131 #define   MI_ARB_TIME_SLICE_6			(3 << 5)
1132 #define   MI_ARB_TIME_SLICE_8			(4 << 5)
1133 #define   MI_ARB_TIME_SLICE_10			(5 << 5)
1134 #define   MI_ARB_TIME_SLICE_14			(6 << 5)
1135 #define   MI_ARB_TIME_SLICE_16			(7 << 5)
1136 
1137 /* Low priority grace period page size */
1138 #define   MI_ARB_LOW_PRIORITY_GRACE_4KB		(0 << 4)	/* default */
1139 #define   MI_ARB_LOW_PRIORITY_GRACE_8KB		(1 << 4)
1140 
1141 /* Disable display A/B trickle feed */
1142 #define   MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE	(1 << 2)
1143 
1144 /* Set display plane priority */
1145 #define   MI_ARB_DISPLAY_PRIORITY_A_B		(0 << 0)	/* display A > display B */
1146 #define   MI_ARB_DISPLAY_PRIORITY_B_A		(1 << 0)	/* display B > display A */
1147 
1148 #define MI_STATE	_MMIO(0x20e4) /* gen2 only */
1149 #define   MI_AGPBUSY_INT_EN			(1 << 1) /* 85x only */
1150 #define   MI_AGPBUSY_830_MODE			(1 << 0) /* 85x only */
1151 
1152 /* On modern GEN architectures interrupt control consists of two sets
1153  * of registers. The first set pertains to the ring generating the
1154  * interrupt. The second control is for the functional block generating the
1155  * interrupt. These are PM, GT, DE, etc.
1156  *
1157  * Luckily *knocks on wood* all the ring interrupt bits match up with the
1158  * GT interrupt bits, so we don't need to duplicate the defines.
1159  *
1160  * These defines should cover us well from SNB->HSW with minor exceptions
1161  * it can also work on ILK.
1162  */
1163 #define GT_BLT_FLUSHDW_NOTIFY_INTERRUPT		(1 << 26)
1164 #define GT_BLT_CS_ERROR_INTERRUPT		(1 << 25)
1165 #define GT_BLT_USER_INTERRUPT			(1 << 22)
1166 #define GT_BSD_CS_ERROR_INTERRUPT		(1 << 15)
1167 #define GT_BSD_USER_INTERRUPT			(1 << 12)
1168 #define GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1	(1 << 11) /* hsw+; rsvd on snb, ivb, vlv */
1169 #define GT_WAIT_SEMAPHORE_INTERRUPT		REG_BIT(11) /* bdw+ */
1170 #define GT_CONTEXT_SWITCH_INTERRUPT		(1 <<  8)
1171 #define GT_RENDER_L3_PARITY_ERROR_INTERRUPT	(1 <<  5) /* !snb */
1172 #define GT_RENDER_PIPECTL_NOTIFY_INTERRUPT	(1 <<  4)
1173 #define GT_CS_MASTER_ERROR_INTERRUPT		REG_BIT(3)
1174 #define GT_RENDER_SYNC_STATUS_INTERRUPT		(1 <<  2)
1175 #define GT_RENDER_DEBUG_INTERRUPT		(1 <<  1)
1176 #define GT_RENDER_USER_INTERRUPT		(1 <<  0)
1177 
1178 #define PM_VEBOX_CS_ERROR_INTERRUPT		(1 << 12) /* hsw+ */
1179 #define PM_VEBOX_USER_INTERRUPT			(1 << 10) /* hsw+ */
1180 
1181 #define GT_PARITY_ERROR(dev_priv) \
1182 	(GT_RENDER_L3_PARITY_ERROR_INTERRUPT | \
1183 	 (IS_HASWELL(dev_priv) ? GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1 : 0))
1184 
1185 /* These are all the "old" interrupts */
1186 #define ILK_BSD_USER_INTERRUPT				(1 << 5)
1187 
1188 #define I915_PM_INTERRUPT				(1 << 31)
1189 #define I915_ISP_INTERRUPT				(1 << 22)
1190 #define I915_LPE_PIPE_B_INTERRUPT			(1 << 21)
1191 #define I915_LPE_PIPE_A_INTERRUPT			(1 << 20)
1192 #define I915_MIPIC_INTERRUPT				(1 << 19)
1193 #define I915_MIPIA_INTERRUPT				(1 << 18)
1194 #define I915_PIPE_CONTROL_NOTIFY_INTERRUPT		(1 << 18)
1195 #define I915_DISPLAY_PORT_INTERRUPT			(1 << 17)
1196 #define I915_DISPLAY_PIPE_C_HBLANK_INTERRUPT		(1 << 16)
1197 #define I915_MASTER_ERROR_INTERRUPT			(1 << 15)
1198 #define I915_DISPLAY_PIPE_B_HBLANK_INTERRUPT		(1 << 14)
1199 #define I915_GMCH_THERMAL_SENSOR_EVENT_INTERRUPT	(1 << 14) /* p-state */
1200 #define I915_DISPLAY_PIPE_A_HBLANK_INTERRUPT		(1 << 13)
1201 #define I915_HWB_OOM_INTERRUPT				(1 << 13)
1202 #define I915_LPE_PIPE_C_INTERRUPT			(1 << 12)
1203 #define I915_SYNC_STATUS_INTERRUPT			(1 << 12)
1204 #define I915_MISC_INTERRUPT				(1 << 11)
1205 #define I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT	(1 << 11)
1206 #define I915_DISPLAY_PIPE_C_VBLANK_INTERRUPT		(1 << 10)
1207 #define I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT	(1 << 10)
1208 #define I915_DISPLAY_PIPE_C_EVENT_INTERRUPT		(1 << 9)
1209 #define I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT	(1 << 9)
1210 #define I915_DISPLAY_PIPE_C_DPBM_INTERRUPT		(1 << 8)
1211 #define I915_DISPLAY_PLANE_C_FLIP_PENDING_INTERRUPT	(1 << 8)
1212 #define I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT		(1 << 7)
1213 #define I915_DISPLAY_PIPE_A_EVENT_INTERRUPT		(1 << 6)
1214 #define I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT		(1 << 5)
1215 #define I915_DISPLAY_PIPE_B_EVENT_INTERRUPT		(1 << 4)
1216 #define I915_DISPLAY_PIPE_A_DPBM_INTERRUPT		(1 << 3)
1217 #define I915_DISPLAY_PIPE_B_DPBM_INTERRUPT		(1 << 2)
1218 #define I915_DEBUG_INTERRUPT				(1 << 2)
1219 #define I915_WINVALID_INTERRUPT				(1 << 1)
1220 #define I915_USER_INTERRUPT				(1 << 1)
1221 #define I915_ASLE_INTERRUPT				(1 << 0)
1222 #define I915_BSD_USER_INTERRUPT				(1 << 25)
1223 
1224 #define I915_HDMI_LPE_AUDIO_BASE	(VLV_DISPLAY_BASE + 0x65000)
1225 #define I915_HDMI_LPE_AUDIO_SIZE	0x1000
1226 
1227 /* DisplayPort Audio w/ LPE */
1228 #define VLV_AUD_CHICKEN_BIT_REG		_MMIO(VLV_DISPLAY_BASE + 0x62F38)
1229 #define VLV_CHICKEN_BIT_DBG_ENABLE	(1 << 0)
1230 
1231 #define _VLV_AUD_PORT_EN_B_DBG		(VLV_DISPLAY_BASE + 0x62F20)
1232 #define _VLV_AUD_PORT_EN_C_DBG		(VLV_DISPLAY_BASE + 0x62F30)
1233 #define _VLV_AUD_PORT_EN_D_DBG		(VLV_DISPLAY_BASE + 0x62F34)
1234 #define VLV_AUD_PORT_EN_DBG(port)	_MMIO_PORT3((port) - PORT_B,	   \
1235 						    _VLV_AUD_PORT_EN_B_DBG, \
1236 						    _VLV_AUD_PORT_EN_C_DBG, \
1237 						    _VLV_AUD_PORT_EN_D_DBG)
1238 #define VLV_AMP_MUTE		        (1 << 1)
1239 
1240 #define GEN6_BSD_RNCID			_MMIO(0x12198)
1241 
1242 #define GEN7_FF_THREAD_MODE		_MMIO(0x20a0)
1243 #define   GEN7_FF_SCHED_MASK		0x0077070
1244 #define   GEN8_FF_DS_REF_CNT_FFME	(1 << 19)
1245 #define   GEN12_FF_TESSELATION_DOP_GATE_DISABLE BIT(19)
1246 #define   GEN7_FF_TS_SCHED_HS1		(0x5 << 16)
1247 #define   GEN7_FF_TS_SCHED_HS0		(0x3 << 16)
1248 #define   GEN7_FF_TS_SCHED_LOAD_BALANCE	(0x1 << 16)
1249 #define   GEN7_FF_TS_SCHED_HW		(0x0 << 16) /* Default */
1250 #define   GEN7_FF_VS_REF_CNT_FFME	(1 << 15)
1251 #define   GEN7_FF_VS_SCHED_HS1		(0x5 << 12)
1252 #define   GEN7_FF_VS_SCHED_HS0		(0x3 << 12)
1253 #define   GEN7_FF_VS_SCHED_LOAD_BALANCE	(0x1 << 12) /* Default */
1254 #define   GEN7_FF_VS_SCHED_HW		(0x0 << 12)
1255 #define   GEN7_FF_DS_SCHED_HS1		(0x5 << 4)
1256 #define   GEN7_FF_DS_SCHED_HS0		(0x3 << 4)
1257 #define   GEN7_FF_DS_SCHED_LOAD_BALANCE	(0x1 << 4)  /* Default */
1258 #define   GEN7_FF_DS_SCHED_HW		(0x0 << 4)
1259 
1260 /*
1261  * Framebuffer compression (915+ only)
1262  */
1263 
1264 #define FBC_CFB_BASE		_MMIO(0x3200) /* 4k page aligned */
1265 #define FBC_LL_BASE		_MMIO(0x3204) /* 4k page aligned */
1266 #define FBC_CONTROL		_MMIO(0x3208)
1267 #define   FBC_CTL_EN			REG_BIT(31)
1268 #define   FBC_CTL_PERIODIC		REG_BIT(30)
1269 #define   FBC_CTL_INTERVAL_MASK		REG_GENMASK(29, 16)
1270 #define   FBC_CTL_INTERVAL(x)		REG_FIELD_PREP(FBC_CTL_INTERVAL_MASK, (x))
1271 #define   FBC_CTL_STOP_ON_MOD		REG_BIT(15)
1272 #define   FBC_CTL_UNCOMPRESSIBLE	REG_BIT(14) /* i915+ */
1273 #define   FBC_CTL_C3_IDLE		REG_BIT(13) /* i945gm only */
1274 #define   FBC_CTL_STRIDE_MASK		REG_GENMASK(12, 5)
1275 #define   FBC_CTL_STRIDE(x)		REG_FIELD_PREP(FBC_CTL_STRIDE_MASK, (x))
1276 #define   FBC_CTL_FENCENO_MASK		REG_GENMASK(3, 0)
1277 #define   FBC_CTL_FENCENO(x)		REG_FIELD_PREP(FBC_CTL_FENCENO_MASK, (x))
1278 #define FBC_COMMAND		_MMIO(0x320c)
1279 #define   FBC_CMD_COMPRESS		REG_BIT(0)
1280 #define FBC_STATUS		_MMIO(0x3210)
1281 #define   FBC_STAT_COMPRESSING		REG_BIT(31)
1282 #define   FBC_STAT_COMPRESSED		REG_BIT(30)
1283 #define   FBC_STAT_MODIFIED		REG_BIT(29)
1284 #define   FBC_STAT_CURRENT_LINE_MASK	REG_GENMASK(10, 0)
1285 #define FBC_CONTROL2		_MMIO(0x3214) /* i965gm only */
1286 #define   FBC_CTL_FENCE_DBL		REG_BIT(4)
1287 #define   FBC_CTL_IDLE_MASK		REG_GENMASK(3, 2)
1288 #define   FBC_CTL_IDLE_IMM		REG_FIELD_PREP(FBC_CTL_IDLE_MASK, 0)
1289 #define   FBC_CTL_IDLE_FULL		REG_FIELD_PREP(FBC_CTL_IDLE_MASK, 1)
1290 #define   FBC_CTL_IDLE_LINE		REG_FIELD_PREP(FBC_CTL_IDLE_MASK, 2)
1291 #define   FBC_CTL_IDLE_DEBUG		REG_FIELD_PREP(FBC_CTL_IDLE_MASK, 3)
1292 #define   FBC_CTL_CPU_FENCE_EN		REG_BIT(1)
1293 #define   FBC_CTL_PLANE_MASK		REG_GENMASK(1, 0)
1294 #define   FBC_CTL_PLANE(i9xx_plane)	REG_FIELD_PREP(FBC_CTL_PLANE_MASK, (i9xx_plane))
1295 #define FBC_FENCE_OFF		_MMIO(0x3218)  /* i965gm only, BSpec typo has 321Bh */
1296 #define FBC_MOD_NUM		_MMIO(0x3220)  /* i965gm only */
1297 #define   FBC_MOD_NUM_MASK		REG_GENMASK(31, 1)
1298 #define   FBC_MOD_NUM_VALID		REG_BIT(0)
1299 #define FBC_TAG(i)		_MMIO(0x3300 + (i) * 4) /* 49 reisters */
1300 #define   FBC_TAG_MASK			REG_GENMASK(1, 0) /* 16 tags per register */
1301 #define   FBC_TAG_MODIFIED		REG_FIELD_PREP(FBC_TAG_MASK, 0)
1302 #define   FBC_TAG_UNCOMPRESSED		REG_FIELD_PREP(FBC_TAG_MASK, 1)
1303 #define   FBC_TAG_UNCOMPRESSIBLE	REG_FIELD_PREP(FBC_TAG_MASK, 2)
1304 #define   FBC_TAG_COMPRESSED		REG_FIELD_PREP(FBC_TAG_MASK, 3)
1305 
1306 #define FBC_LL_SIZE		(1536)
1307 
1308 /* Framebuffer compression for GM45+ */
1309 #define DPFC_CB_BASE			_MMIO(0x3200)
1310 #define ILK_DPFC_CB_BASE(fbc_id)	_MMIO_PIPE((fbc_id), 0x43200, 0x43240)
1311 #define DPFC_CONTROL			_MMIO(0x3208)
1312 #define ILK_DPFC_CONTROL(fbc_id)	_MMIO_PIPE((fbc_id), 0x43208, 0x43248)
1313 #define   DPFC_CTL_EN				REG_BIT(31)
1314 #define   DPFC_CTL_PLANE_MASK_G4X		REG_BIT(30) /* g4x-snb */
1315 #define   DPFC_CTL_PLANE_G4X(i9xx_plane)	REG_FIELD_PREP(DPFC_CTL_PLANE_MASK_G4X, (i9xx_plane))
1316 #define   DPFC_CTL_FENCE_EN_G4X			REG_BIT(29) /* g4x-snb */
1317 #define   DPFC_CTL_PLANE_MASK_IVB		REG_GENMASK(30, 29) /* ivb only */
1318 #define   DPFC_CTL_PLANE_IVB(i9xx_plane)	REG_FIELD_PREP(DPFC_CTL_PLANE_MASK_IVB, (i9xx_plane))
1319 #define   DPFC_CTL_FENCE_EN_IVB			REG_BIT(28) /* ivb+ */
1320 #define   DPFC_CTL_PERSISTENT_MODE		REG_BIT(25) /* g4x-snb */
1321 #define   DPFC_CTL_FALSE_COLOR			REG_BIT(10) /* ivb+ */
1322 #define   DPFC_CTL_SR_EN			REG_BIT(10) /* g4x only */
1323 #define   DPFC_CTL_SR_EXIT_DIS			REG_BIT(9) /* g4x only */
1324 #define   DPFC_CTL_LIMIT_MASK			REG_GENMASK(7, 6)
1325 #define   DPFC_CTL_LIMIT_1X			REG_FIELD_PREP(DPFC_CTL_LIMIT_MASK, 0)
1326 #define   DPFC_CTL_LIMIT_2X			REG_FIELD_PREP(DPFC_CTL_LIMIT_MASK, 1)
1327 #define   DPFC_CTL_LIMIT_4X			REG_FIELD_PREP(DPFC_CTL_LIMIT_MASK, 2)
1328 #define   DPFC_CTL_FENCENO_MASK			REG_GENMASK(3, 0)
1329 #define   DPFC_CTL_FENCENO(fence)		REG_FIELD_PREP(DPFC_CTL_FENCENO_MASK, (fence))
1330 #define DPFC_RECOMP_CTL			_MMIO(0x320c)
1331 #define ILK_DPFC_RECOMP_CTL(fbc_id)	_MMIO_PIPE((fbc_id), 0x4320c, 0x4324c)
1332 #define   DPFC_RECOMP_STALL_EN			REG_BIT(27)
1333 #define   DPFC_RECOMP_STALL_WM_MASK		REG_GENMASK(26, 16)
1334 #define   DPFC_RECOMP_TIMER_COUNT_MASK		REG_GENMASK(5, 0)
1335 #define DPFC_STATUS			_MMIO(0x3210)
1336 #define ILK_DPFC_STATUS(fbc_id)		_MMIO_PIPE((fbc_id), 0x43210, 0x43250)
1337 #define   DPFC_INVAL_SEG_MASK			REG_GENMASK(26, 16)
1338 #define   DPFC_COMP_SEG_MASK			REG_GENMASK(10, 0)
1339 #define DPFC_STATUS2			_MMIO(0x3214)
1340 #define ILK_DPFC_STATUS2(fbc_id)	_MMIO_PIPE((fbc_id), 0x43214, 0x43254)
1341 #define   DPFC_COMP_SEG_MASK_IVB		REG_GENMASK(11, 0)
1342 #define DPFC_FENCE_YOFF			_MMIO(0x3218)
1343 #define ILK_DPFC_FENCE_YOFF(fbc_id)	_MMIO_PIPE((fbc_id), 0x43218, 0x43258)
1344 #define DPFC_CHICKEN			_MMIO(0x3224)
1345 #define ILK_DPFC_CHICKEN(fbc_id)	_MMIO_PIPE((fbc_id), 0x43224, 0x43264)
1346 #define   DPFC_HT_MODIFY			REG_BIT(31) /* pre-ivb */
1347 #define   DPFC_NUKE_ON_ANY_MODIFICATION		REG_BIT(23) /* bdw+ */
1348 #define   DPFC_CHICKEN_COMP_DUMMY_PIXEL		REG_BIT(14) /* glk+ */
1349 #define   DPFC_CHICKEN_FORCE_SLB_INVALIDATION	REG_BIT(13) /* icl+ */
1350 #define   DPFC_DISABLE_DUMMY0			REG_BIT(8) /* ivb+ */
1351 
1352 #define GLK_FBC_STRIDE(fbc_id)	_MMIO_PIPE((fbc_id), 0x43228, 0x43268)
1353 #define   FBC_STRIDE_OVERRIDE	REG_BIT(15)
1354 #define   FBC_STRIDE_MASK	REG_GENMASK(14, 0)
1355 #define   FBC_STRIDE(x)		REG_FIELD_PREP(FBC_STRIDE_MASK, (x))
1356 
1357 #define ILK_FBC_RT_BASE		_MMIO(0x2128)
1358 #define   ILK_FBC_RT_VALID	REG_BIT(0)
1359 #define   SNB_FBC_FRONT_BUFFER	REG_BIT(1)
1360 
1361 #define ILK_DISPLAY_CHICKEN1	_MMIO(0x42000)
1362 #define   ILK_FBCQ_DIS		(1 << 22)
1363 #define   ILK_PABSTRETCH_DIS	REG_BIT(21)
1364 #define   ILK_SABSTRETCH_DIS	REG_BIT(20)
1365 #define   IVB_PRI_STRETCH_MAX_MASK	REG_GENMASK(21, 20)
1366 #define   IVB_PRI_STRETCH_MAX_X8	REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 0)
1367 #define   IVB_PRI_STRETCH_MAX_X4	REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 1)
1368 #define   IVB_PRI_STRETCH_MAX_X2	REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 2)
1369 #define   IVB_PRI_STRETCH_MAX_X1	REG_FIELD_PREP(IVB_PRI_STRETCH_MAX_MASK, 3)
1370 #define   IVB_SPR_STRETCH_MAX_MASK	REG_GENMASK(19, 18)
1371 #define   IVB_SPR_STRETCH_MAX_X8	REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 0)
1372 #define   IVB_SPR_STRETCH_MAX_X4	REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 1)
1373 #define   IVB_SPR_STRETCH_MAX_X2	REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 2)
1374 #define   IVB_SPR_STRETCH_MAX_X1	REG_FIELD_PREP(IVB_SPR_STRETCH_MAX_MASK, 3)
1375 
1376 
1377 /*
1378  * Framebuffer compression for Sandybridge
1379  *
1380  * The following two registers are of type GTTMMADR
1381  */
1382 #define SNB_DPFC_CTL_SA		_MMIO(0x100100)
1383 #define   SNB_DPFC_FENCE_EN		REG_BIT(29)
1384 #define   SNB_DPFC_FENCENO_MASK		REG_GENMASK(4, 0)
1385 #define   SNB_DPFC_FENCENO(fence)	REG_FIELD_PREP(SNB_DPFC_FENCENO_MASK, (fence))
1386 #define SNB_DPFC_CPU_FENCE_OFFSET	_MMIO(0x100104)
1387 
1388 /* Framebuffer compression for Ivybridge */
1389 #define IVB_FBC_RT_BASE			_MMIO(0x7020)
1390 #define IVB_FBC_RT_BASE_UPPER		_MMIO(0x7024)
1391 
1392 #define IPS_CTL		_MMIO(0x43408)
1393 #define   IPS_ENABLE	(1 << 31)
1394 
1395 #define MSG_FBC_REND_STATE(fbc_id)	_MMIO_PIPE((fbc_id), 0x50380, 0x50384)
1396 #define   FBC_REND_NUKE			REG_BIT(2)
1397 #define   FBC_REND_CACHE_CLEAN		REG_BIT(1)
1398 
1399 /*
1400  * Clock control & power management
1401  */
1402 #define _DPLL_A (DISPLAY_MMIO_BASE(dev_priv) + 0x6014)
1403 #define _DPLL_B (DISPLAY_MMIO_BASE(dev_priv) + 0x6018)
1404 #define _CHV_DPLL_C (DISPLAY_MMIO_BASE(dev_priv) + 0x6030)
1405 #define DPLL(pipe) _MMIO_PIPE3((pipe), _DPLL_A, _DPLL_B, _CHV_DPLL_C)
1406 
1407 #define VGA0	_MMIO(0x6000)
1408 #define VGA1	_MMIO(0x6004)
1409 #define VGA_PD	_MMIO(0x6010)
1410 #define   VGA0_PD_P2_DIV_4	(1 << 7)
1411 #define   VGA0_PD_P1_DIV_2	(1 << 5)
1412 #define   VGA0_PD_P1_SHIFT	0
1413 #define   VGA0_PD_P1_MASK	(0x1f << 0)
1414 #define   VGA1_PD_P2_DIV_4	(1 << 15)
1415 #define   VGA1_PD_P1_DIV_2	(1 << 13)
1416 #define   VGA1_PD_P1_SHIFT	8
1417 #define   VGA1_PD_P1_MASK	(0x1f << 8)
1418 #define   DPLL_VCO_ENABLE		(1 << 31)
1419 #define   DPLL_SDVO_HIGH_SPEED		(1 << 30)
1420 #define   DPLL_DVO_2X_MODE		(1 << 30)
1421 #define   DPLL_EXT_BUFFER_ENABLE_VLV	(1 << 30)
1422 #define   DPLL_SYNCLOCK_ENABLE		(1 << 29)
1423 #define   DPLL_REF_CLK_ENABLE_VLV	(1 << 29)
1424 #define   DPLL_VGA_MODE_DIS		(1 << 28)
1425 #define   DPLLB_MODE_DAC_SERIAL		(1 << 26) /* i915 */
1426 #define   DPLLB_MODE_LVDS		(2 << 26) /* i915 */
1427 #define   DPLL_MODE_MASK		(3 << 26)
1428 #define   DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 (0 << 24) /* i915 */
1429 #define   DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 (1 << 24) /* i915 */
1430 #define   DPLLB_LVDS_P2_CLOCK_DIV_14	(0 << 24) /* i915 */
1431 #define   DPLLB_LVDS_P2_CLOCK_DIV_7	(1 << 24) /* i915 */
1432 #define   DPLL_P2_CLOCK_DIV_MASK	0x03000000 /* i915 */
1433 #define   DPLL_FPA01_P1_POST_DIV_MASK	0x00ff0000 /* i915 */
1434 #define   DPLL_FPA01_P1_POST_DIV_MASK_PINEVIEW	0x00ff8000 /* Pineview */
1435 #define   DPLL_LOCK_VLV			(1 << 15)
1436 #define   DPLL_INTEGRATED_CRI_CLK_VLV	(1 << 14)
1437 #define   DPLL_INTEGRATED_REF_CLK_VLV	(1 << 13)
1438 #define   DPLL_SSC_REF_CLK_CHV		(1 << 13)
1439 #define   DPLL_PORTC_READY_MASK		(0xf << 4)
1440 #define   DPLL_PORTB_READY_MASK		(0xf)
1441 
1442 #define   DPLL_FPA01_P1_POST_DIV_MASK_I830	0x001f0000
1443 
1444 /* Additional CHV pll/phy registers */
1445 #define DPIO_PHY_STATUS			_MMIO(VLV_DISPLAY_BASE + 0x6240)
1446 #define   DPLL_PORTD_READY_MASK		(0xf)
1447 #define DISPLAY_PHY_CONTROL _MMIO(VLV_DISPLAY_BASE + 0x60100)
1448 #define   PHY_CH_POWER_DOWN_OVRD_EN(phy, ch)	(1 << (2 * (phy) + (ch) + 27))
1449 #define   PHY_LDO_DELAY_0NS			0x0
1450 #define   PHY_LDO_DELAY_200NS			0x1
1451 #define   PHY_LDO_DELAY_600NS			0x2
1452 #define   PHY_LDO_SEQ_DELAY(delay, phy)		((delay) << (2 * (phy) + 23))
1453 #define   PHY_CH_POWER_DOWN_OVRD(mask, phy, ch)	((mask) << (8 * (phy) + 4 * (ch) + 11))
1454 #define   PHY_CH_SU_PSR				0x1
1455 #define   PHY_CH_DEEP_PSR			0x7
1456 #define   PHY_CH_POWER_MODE(mode, phy, ch)	((mode) << (6 * (phy) + 3 * (ch) + 2))
1457 #define   PHY_COM_LANE_RESET_DEASSERT(phy)	(1 << (phy))
1458 #define DISPLAY_PHY_STATUS _MMIO(VLV_DISPLAY_BASE + 0x60104)
1459 #define   PHY_POWERGOOD(phy)	(((phy) == DPIO_PHY0) ? (1 << 31) : (1 << 30))
1460 #define   PHY_STATUS_CMN_LDO(phy, ch)                   (1 << (6 - (6 * (phy) + 3 * (ch))))
1461 #define   PHY_STATUS_SPLINE_LDO(phy, ch, spline)        (1 << (8 - (6 * (phy) + 3 * (ch) + (spline))))
1462 
1463 /*
1464  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
1465  * this field (only one bit may be set).
1466  */
1467 #define   DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS	0x003f0000
1468 #define   DPLL_FPA01_P1_POST_DIV_SHIFT	16
1469 #define   DPLL_FPA01_P1_POST_DIV_SHIFT_PINEVIEW 15
1470 /* i830, required in DVO non-gang */
1471 #define   PLL_P2_DIVIDE_BY_4		(1 << 23)
1472 #define   PLL_P1_DIVIDE_BY_TWO		(1 << 21) /* i830 */
1473 #define   PLL_REF_INPUT_DREFCLK		(0 << 13)
1474 #define   PLL_REF_INPUT_TVCLKINA	(1 << 13) /* i830 */
1475 #define   PLL_REF_INPUT_TVCLKINBC	(2 << 13) /* SDVO TVCLKIN */
1476 #define   PLLB_REF_INPUT_SPREADSPECTRUMIN (3 << 13)
1477 #define   PLL_REF_INPUT_MASK		(3 << 13)
1478 #define   PLL_LOAD_PULSE_PHASE_SHIFT		9
1479 /* Ironlake */
1480 # define PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT     9
1481 # define PLL_REF_SDVO_HDMI_MULTIPLIER_MASK      (7 << 9)
1482 # define PLL_REF_SDVO_HDMI_MULTIPLIER(x)	(((x) - 1) << 9)
1483 # define DPLL_FPA1_P1_POST_DIV_SHIFT            0
1484 # define DPLL_FPA1_P1_POST_DIV_MASK             0xff
1485 
1486 /*
1487  * Parallel to Serial Load Pulse phase selection.
1488  * Selects the phase for the 10X DPLL clock for the PCIe
1489  * digital display port. The range is 4 to 13; 10 or more
1490  * is just a flip delay. The default is 6
1491  */
1492 #define   PLL_LOAD_PULSE_PHASE_MASK		(0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
1493 #define   DISPLAY_RATE_SELECT_FPA1		(1 << 8)
1494 /*
1495  * SDVO multiplier for 945G/GM. Not used on 965.
1496  */
1497 #define   SDVO_MULTIPLIER_MASK			0x000000ff
1498 #define   SDVO_MULTIPLIER_SHIFT_HIRES		4
1499 #define   SDVO_MULTIPLIER_SHIFT_VGA		0
1500 
1501 #define _DPLL_A_MD (DISPLAY_MMIO_BASE(dev_priv) + 0x601c)
1502 #define _DPLL_B_MD (DISPLAY_MMIO_BASE(dev_priv) + 0x6020)
1503 #define _CHV_DPLL_C_MD (DISPLAY_MMIO_BASE(dev_priv) + 0x603c)
1504 #define DPLL_MD(pipe) _MMIO_PIPE3((pipe), _DPLL_A_MD, _DPLL_B_MD, _CHV_DPLL_C_MD)
1505 
1506 /*
1507  * UDI pixel divider, controlling how many pixels are stuffed into a packet.
1508  *
1509  * Value is pixels minus 1.  Must be set to 1 pixel for SDVO.
1510  */
1511 #define   DPLL_MD_UDI_DIVIDER_MASK		0x3f000000
1512 #define   DPLL_MD_UDI_DIVIDER_SHIFT		24
1513 /* UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
1514 #define   DPLL_MD_VGA_UDI_DIVIDER_MASK		0x003f0000
1515 #define   DPLL_MD_VGA_UDI_DIVIDER_SHIFT		16
1516 /*
1517  * SDVO/UDI pixel multiplier.
1518  *
1519  * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
1520  * clock rate is 10 times the DPLL clock.  At low resolution/refresh rate
1521  * modes, the bus rate would be below the limits, so SDVO allows for stuffing
1522  * dummy bytes in the datastream at an increased clock rate, with both sides of
1523  * the link knowing how many bytes are fill.
1524  *
1525  * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
1526  * rate to 130Mhz to get a bus rate of 1.30Ghz.  The DPLL clock rate would be
1527  * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
1528  * through an SDVO command.
1529  *
1530  * This register field has values of multiplication factor minus 1, with
1531  * a maximum multiplier of 5 for SDVO.
1532  */
1533 #define   DPLL_MD_UDI_MULTIPLIER_MASK		0x00003f00
1534 #define   DPLL_MD_UDI_MULTIPLIER_SHIFT		8
1535 /*
1536  * SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
1537  * This best be set to the default value (3) or the CRT won't work. No,
1538  * I don't entirely understand what this does...
1539  */
1540 #define   DPLL_MD_VGA_UDI_MULTIPLIER_MASK	0x0000003f
1541 #define   DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT	0
1542 
1543 #define RAWCLK_FREQ_VLV		_MMIO(VLV_DISPLAY_BASE + 0x6024)
1544 
1545 #define _FPA0	0x6040
1546 #define _FPA1	0x6044
1547 #define _FPB0	0x6048
1548 #define _FPB1	0x604c
1549 #define FP0(pipe) _MMIO_PIPE(pipe, _FPA0, _FPB0)
1550 #define FP1(pipe) _MMIO_PIPE(pipe, _FPA1, _FPB1)
1551 #define   FP_N_DIV_MASK		0x003f0000
1552 #define   FP_N_PINEVIEW_DIV_MASK	0x00ff0000
1553 #define   FP_N_DIV_SHIFT		16
1554 #define   FP_M1_DIV_MASK	0x00003f00
1555 #define   FP_M1_DIV_SHIFT		 8
1556 #define   FP_M2_DIV_MASK	0x0000003f
1557 #define   FP_M2_PINEVIEW_DIV_MASK	0x000000ff
1558 #define   FP_M2_DIV_SHIFT		 0
1559 #define DPLL_TEST	_MMIO(0x606c)
1560 #define   DPLLB_TEST_SDVO_DIV_1		(0 << 22)
1561 #define   DPLLB_TEST_SDVO_DIV_2		(1 << 22)
1562 #define   DPLLB_TEST_SDVO_DIV_4		(2 << 22)
1563 #define   DPLLB_TEST_SDVO_DIV_MASK	(3 << 22)
1564 #define   DPLLB_TEST_N_BYPASS		(1 << 19)
1565 #define   DPLLB_TEST_M_BYPASS		(1 << 18)
1566 #define   DPLLB_INPUT_BUFFER_ENABLE	(1 << 16)
1567 #define   DPLLA_TEST_N_BYPASS		(1 << 3)
1568 #define   DPLLA_TEST_M_BYPASS		(1 << 2)
1569 #define   DPLLA_INPUT_BUFFER_ENABLE	(1 << 0)
1570 #define D_STATE		_MMIO(0x6104)
1571 #define  DSTATE_GFX_RESET_I830			(1 << 6)
1572 #define  DSTATE_PLL_D3_OFF			(1 << 3)
1573 #define  DSTATE_GFX_CLOCK_GATING		(1 << 1)
1574 #define  DSTATE_DOT_CLOCK_GATING		(1 << 0)
1575 #define DSPCLK_GATE_D(__i915)		_MMIO(DISPLAY_MMIO_BASE(__i915) + 0x6200)
1576 # define DPUNIT_B_CLOCK_GATE_DISABLE		(1 << 30) /* 965 */
1577 # define VSUNIT_CLOCK_GATE_DISABLE		(1 << 29) /* 965 */
1578 # define VRHUNIT_CLOCK_GATE_DISABLE		(1 << 28) /* 965 */
1579 # define VRDUNIT_CLOCK_GATE_DISABLE		(1 << 27) /* 965 */
1580 # define AUDUNIT_CLOCK_GATE_DISABLE		(1 << 26) /* 965 */
1581 # define DPUNIT_A_CLOCK_GATE_DISABLE		(1 << 25) /* 965 */
1582 # define DPCUNIT_CLOCK_GATE_DISABLE		(1 << 24) /* 965 */
1583 # define PNV_GMBUSUNIT_CLOCK_GATE_DISABLE	(1 << 24) /* pnv */
1584 # define TVRUNIT_CLOCK_GATE_DISABLE		(1 << 23) /* 915-945 */
1585 # define TVCUNIT_CLOCK_GATE_DISABLE		(1 << 22) /* 915-945 */
1586 # define TVFUNIT_CLOCK_GATE_DISABLE		(1 << 21) /* 915-945 */
1587 # define TVEUNIT_CLOCK_GATE_DISABLE		(1 << 20) /* 915-945 */
1588 # define DVSUNIT_CLOCK_GATE_DISABLE		(1 << 19) /* 915-945 */
1589 # define DSSUNIT_CLOCK_GATE_DISABLE		(1 << 18) /* 915-945 */
1590 # define DDBUNIT_CLOCK_GATE_DISABLE		(1 << 17) /* 915-945 */
1591 # define DPRUNIT_CLOCK_GATE_DISABLE		(1 << 16) /* 915-945 */
1592 # define DPFUNIT_CLOCK_GATE_DISABLE		(1 << 15) /* 915-945 */
1593 # define DPBMUNIT_CLOCK_GATE_DISABLE		(1 << 14) /* 915-945 */
1594 # define DPLSUNIT_CLOCK_GATE_DISABLE		(1 << 13) /* 915-945 */
1595 # define DPLUNIT_CLOCK_GATE_DISABLE		(1 << 12) /* 915-945 */
1596 # define DPOUNIT_CLOCK_GATE_DISABLE		(1 << 11)
1597 # define DPBUNIT_CLOCK_GATE_DISABLE		(1 << 10)
1598 # define DCUNIT_CLOCK_GATE_DISABLE		(1 << 9)
1599 # define DPUNIT_CLOCK_GATE_DISABLE		(1 << 8)
1600 # define VRUNIT_CLOCK_GATE_DISABLE		(1 << 7) /* 915+: reserved */
1601 # define OVHUNIT_CLOCK_GATE_DISABLE		(1 << 6) /* 830-865 */
1602 # define DPIOUNIT_CLOCK_GATE_DISABLE		(1 << 6) /* 915-945 */
1603 # define OVFUNIT_CLOCK_GATE_DISABLE		(1 << 5)
1604 # define OVBUNIT_CLOCK_GATE_DISABLE		(1 << 4)
1605 /*
1606  * This bit must be set on the 830 to prevent hangs when turning off the
1607  * overlay scaler.
1608  */
1609 # define OVRUNIT_CLOCK_GATE_DISABLE		(1 << 3)
1610 # define OVCUNIT_CLOCK_GATE_DISABLE		(1 << 2)
1611 # define OVUUNIT_CLOCK_GATE_DISABLE		(1 << 1)
1612 # define ZVUNIT_CLOCK_GATE_DISABLE		(1 << 0) /* 830 */
1613 # define OVLUNIT_CLOCK_GATE_DISABLE		(1 << 0) /* 845,865 */
1614 
1615 #define RENCLK_GATE_D1		_MMIO(0x6204)
1616 # define BLITTER_CLOCK_GATE_DISABLE		(1 << 13) /* 945GM only */
1617 # define MPEG_CLOCK_GATE_DISABLE		(1 << 12) /* 945GM only */
1618 # define PC_FE_CLOCK_GATE_DISABLE		(1 << 11)
1619 # define PC_BE_CLOCK_GATE_DISABLE		(1 << 10)
1620 # define WINDOWER_CLOCK_GATE_DISABLE		(1 << 9)
1621 # define INTERPOLATOR_CLOCK_GATE_DISABLE	(1 << 8)
1622 # define COLOR_CALCULATOR_CLOCK_GATE_DISABLE	(1 << 7)
1623 # define MOTION_COMP_CLOCK_GATE_DISABLE		(1 << 6)
1624 # define MAG_CLOCK_GATE_DISABLE			(1 << 5)
1625 /* This bit must be unset on 855,865 */
1626 # define MECI_CLOCK_GATE_DISABLE		(1 << 4)
1627 # define DCMP_CLOCK_GATE_DISABLE		(1 << 3)
1628 # define MEC_CLOCK_GATE_DISABLE			(1 << 2)
1629 # define MECO_CLOCK_GATE_DISABLE		(1 << 1)
1630 /* This bit must be set on 855,865. */
1631 # define SV_CLOCK_GATE_DISABLE			(1 << 0)
1632 # define I915_MPEG_CLOCK_GATE_DISABLE		(1 << 16)
1633 # define I915_VLD_IP_PR_CLOCK_GATE_DISABLE	(1 << 15)
1634 # define I915_MOTION_COMP_CLOCK_GATE_DISABLE	(1 << 14)
1635 # define I915_BD_BF_CLOCK_GATE_DISABLE		(1 << 13)
1636 # define I915_SF_SE_CLOCK_GATE_DISABLE		(1 << 12)
1637 # define I915_WM_CLOCK_GATE_DISABLE		(1 << 11)
1638 # define I915_IZ_CLOCK_GATE_DISABLE		(1 << 10)
1639 # define I915_PI_CLOCK_GATE_DISABLE		(1 << 9)
1640 # define I915_DI_CLOCK_GATE_DISABLE		(1 << 8)
1641 # define I915_SH_SV_CLOCK_GATE_DISABLE		(1 << 7)
1642 # define I915_PL_DG_QC_FT_CLOCK_GATE_DISABLE	(1 << 6)
1643 # define I915_SC_CLOCK_GATE_DISABLE		(1 << 5)
1644 # define I915_FL_CLOCK_GATE_DISABLE		(1 << 4)
1645 # define I915_DM_CLOCK_GATE_DISABLE		(1 << 3)
1646 # define I915_PS_CLOCK_GATE_DISABLE		(1 << 2)
1647 # define I915_CC_CLOCK_GATE_DISABLE		(1 << 1)
1648 # define I915_BY_CLOCK_GATE_DISABLE		(1 << 0)
1649 
1650 # define I965_RCZ_CLOCK_GATE_DISABLE		(1 << 30)
1651 /* This bit must always be set on 965G/965GM */
1652 # define I965_RCC_CLOCK_GATE_DISABLE		(1 << 29)
1653 # define I965_RCPB_CLOCK_GATE_DISABLE		(1 << 28)
1654 # define I965_DAP_CLOCK_GATE_DISABLE		(1 << 27)
1655 # define I965_ROC_CLOCK_GATE_DISABLE		(1 << 26)
1656 # define I965_GW_CLOCK_GATE_DISABLE		(1 << 25)
1657 # define I965_TD_CLOCK_GATE_DISABLE		(1 << 24)
1658 /* This bit must always be set on 965G */
1659 # define I965_ISC_CLOCK_GATE_DISABLE		(1 << 23)
1660 # define I965_IC_CLOCK_GATE_DISABLE		(1 << 22)
1661 # define I965_EU_CLOCK_GATE_DISABLE		(1 << 21)
1662 # define I965_IF_CLOCK_GATE_DISABLE		(1 << 20)
1663 # define I965_TC_CLOCK_GATE_DISABLE		(1 << 19)
1664 # define I965_SO_CLOCK_GATE_DISABLE		(1 << 17)
1665 # define I965_FBC_CLOCK_GATE_DISABLE		(1 << 16)
1666 # define I965_MARI_CLOCK_GATE_DISABLE		(1 << 15)
1667 # define I965_MASF_CLOCK_GATE_DISABLE		(1 << 14)
1668 # define I965_MAWB_CLOCK_GATE_DISABLE		(1 << 13)
1669 # define I965_EM_CLOCK_GATE_DISABLE		(1 << 12)
1670 # define I965_UC_CLOCK_GATE_DISABLE		(1 << 11)
1671 # define I965_SI_CLOCK_GATE_DISABLE		(1 << 6)
1672 # define I965_MT_CLOCK_GATE_DISABLE		(1 << 5)
1673 # define I965_PL_CLOCK_GATE_DISABLE		(1 << 4)
1674 # define I965_DG_CLOCK_GATE_DISABLE		(1 << 3)
1675 # define I965_QC_CLOCK_GATE_DISABLE		(1 << 2)
1676 # define I965_FT_CLOCK_GATE_DISABLE		(1 << 1)
1677 # define I965_DM_CLOCK_GATE_DISABLE		(1 << 0)
1678 
1679 #define RENCLK_GATE_D2		_MMIO(0x6208)
1680 #define VF_UNIT_CLOCK_GATE_DISABLE		(1 << 9)
1681 #define GS_UNIT_CLOCK_GATE_DISABLE		(1 << 7)
1682 #define CL_UNIT_CLOCK_GATE_DISABLE		(1 << 6)
1683 
1684 #define VDECCLK_GATE_D		_MMIO(0x620C)		/* g4x only */
1685 #define  VCP_UNIT_CLOCK_GATE_DISABLE		(1 << 4)
1686 
1687 #define RAMCLK_GATE_D		_MMIO(0x6210)		/* CRL only */
1688 #define DEUC			_MMIO(0x6214)          /* CRL only */
1689 
1690 #define FW_BLC_SELF_VLV		_MMIO(VLV_DISPLAY_BASE + 0x6500)
1691 #define  FW_CSPWRDWNEN		(1 << 15)
1692 
1693 #define MI_ARB_VLV		_MMIO(VLV_DISPLAY_BASE + 0x6504)
1694 
1695 #define CZCLK_CDCLK_FREQ_RATIO	_MMIO(VLV_DISPLAY_BASE + 0x6508)
1696 #define   CDCLK_FREQ_SHIFT	4
1697 #define   CDCLK_FREQ_MASK	(0x1f << CDCLK_FREQ_SHIFT)
1698 #define   CZCLK_FREQ_MASK	0xf
1699 
1700 #define GCI_CONTROL		_MMIO(VLV_DISPLAY_BASE + 0x650C)
1701 #define   PFI_CREDIT_63		(9 << 28)		/* chv only */
1702 #define   PFI_CREDIT_31		(8 << 28)		/* chv only */
1703 #define   PFI_CREDIT(x)		(((x) - 8) << 28)	/* 8-15 */
1704 #define   PFI_CREDIT_RESEND	(1 << 27)
1705 #define   VGA_FAST_MODE_DISABLE	(1 << 14)
1706 
1707 #define GMBUSFREQ_VLV		_MMIO(VLV_DISPLAY_BASE + 0x6510)
1708 
1709 /*
1710  * Palette regs
1711  */
1712 #define _PALETTE_A		0xa000
1713 #define _PALETTE_B		0xa800
1714 #define _CHV_PALETTE_C		0xc000
1715 /* 8bit mode / i965+ 10.6 interpolated mode ldw/udw */
1716 #define   PALETTE_RED_MASK		REG_GENMASK(23, 16)
1717 #define   PALETTE_GREEN_MASK		REG_GENMASK(15, 8)
1718 #define   PALETTE_BLUE_MASK		REG_GENMASK(7, 0)
1719 /* pre-i965 10bit interpolated mode ldw */
1720 #define   PALETTE_10BIT_RED_LDW_MASK	REG_GENMASK(23, 16)
1721 #define   PALETTE_10BIT_GREEN_LDW_MASK	REG_GENMASK(15, 8)
1722 #define   PALETTE_10BIT_BLUE_LDW_MASK	REG_GENMASK(7, 0)
1723 /* pre-i965 10bit interpolated mode udw */
1724 #define   PALETTE_10BIT_RED_EXP_MASK	REG_GENMASK(23, 22)
1725 #define   PALETTE_10BIT_RED_MANT_MASK	REG_GENMASK(21, 18)
1726 #define   PALETTE_10BIT_RED_UDW_MASK	REG_GENMASK(17, 16)
1727 #define   PALETTE_10BIT_GREEN_EXP_MASK	REG_GENMASK(15, 14)
1728 #define   PALETTE_10BIT_GREEN_MANT_MASK	REG_GENMASK(13, 10)
1729 #define   PALETTE_10BIT_GREEN_UDW_MASK	REG_GENMASK(9, 8)
1730 #define   PALETTE_10BIT_BLUE_EXP_MASK	REG_GENMASK(7, 6)
1731 #define   PALETTE_10BIT_BLUE_MANT_MASK	REG_GENMASK(5, 2)
1732 #define   PALETTE_10BIT_BLUE_UDW_MASK	REG_GENMASK(1, 0)
1733 #define PALETTE(pipe, i)	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + \
1734 				      _PICK((pipe), _PALETTE_A,		\
1735 					    _PALETTE_B, _CHV_PALETTE_C) + \
1736 				      (i) * 4)
1737 
1738 #define PEG_BAND_GAP_DATA	_MMIO(0x14d68)
1739 
1740 #define BXT_RP_STATE_CAP        _MMIO(0x138170)
1741 #define GEN9_RP_STATE_LIMITS	_MMIO(0x138148)
1742 #define XEHPSDV_RP_STATE_CAP	_MMIO(0x250014)
1743 #define PVC_RP_STATE_CAP	_MMIO(0x281014)
1744 
1745 #define MTL_RP_STATE_CAP	_MMIO(0x138000)
1746 #define MTL_MEDIAP_STATE_CAP	_MMIO(0x138020)
1747 #define   MTL_RP0_CAP_MASK	REG_GENMASK(8, 0)
1748 #define   MTL_RPN_CAP_MASK	REG_GENMASK(24, 16)
1749 
1750 #define MTL_GT_RPE_FREQUENCY	_MMIO(0x13800c)
1751 #define MTL_MPE_FREQUENCY	_MMIO(0x13802c)
1752 #define   MTL_RPE_MASK		REG_GENMASK(8, 0)
1753 
1754 #define GT0_PERF_LIMIT_REASONS		_MMIO(0x1381a8)
1755 #define   GT0_PERF_LIMIT_REASONS_MASK	0xde3
1756 #define   PROCHOT_MASK			REG_BIT(0)
1757 #define   THERMAL_LIMIT_MASK		REG_BIT(1)
1758 #define   RATL_MASK			REG_BIT(5)
1759 #define   VR_THERMALERT_MASK		REG_BIT(6)
1760 #define   VR_TDC_MASK			REG_BIT(7)
1761 #define   POWER_LIMIT_4_MASK		REG_BIT(8)
1762 #define   POWER_LIMIT_1_MASK		REG_BIT(10)
1763 #define   POWER_LIMIT_2_MASK		REG_BIT(11)
1764 #define   GT0_PERF_LIMIT_REASONS_LOG_MASK REG_GENMASK(31, 16)
1765 #define MTL_MEDIA_PERF_LIMIT_REASONS	_MMIO(0x138030)
1766 
1767 #define CHV_CLK_CTL1			_MMIO(0x101100)
1768 #define VLV_CLK_CTL2			_MMIO(0x101104)
1769 #define   CLK_CTL2_CZCOUNT_30NS_SHIFT	28
1770 
1771 /*
1772  * Overlay regs
1773  */
1774 
1775 #define OVADD			_MMIO(0x30000)
1776 #define DOVSTA			_MMIO(0x30008)
1777 #define OC_BUF			(0x3 << 20)
1778 #define OGAMC5			_MMIO(0x30010)
1779 #define OGAMC4			_MMIO(0x30014)
1780 #define OGAMC3			_MMIO(0x30018)
1781 #define OGAMC2			_MMIO(0x3001c)
1782 #define OGAMC1			_MMIO(0x30020)
1783 #define OGAMC0			_MMIO(0x30024)
1784 
1785 /*
1786  * GEN9 clock gating regs
1787  */
1788 #define GEN9_CLKGATE_DIS_0		_MMIO(0x46530)
1789 #define   DARBF_GATING_DIS		(1 << 27)
1790 #define   PWM2_GATING_DIS		(1 << 14)
1791 #define   PWM1_GATING_DIS		(1 << 13)
1792 
1793 #define GEN9_CLKGATE_DIS_3		_MMIO(0x46538)
1794 #define   TGL_VRH_GATING_DIS		REG_BIT(31)
1795 #define   DPT_GATING_DIS		REG_BIT(22)
1796 
1797 #define GEN9_CLKGATE_DIS_4		_MMIO(0x4653C)
1798 #define   BXT_GMBUS_GATING_DIS		(1 << 14)
1799 
1800 #define GEN9_CLKGATE_DIS_5		_MMIO(0x46540)
1801 #define   DPCE_GATING_DIS		REG_BIT(17)
1802 
1803 #define _CLKGATE_DIS_PSL_A		0x46520
1804 #define _CLKGATE_DIS_PSL_B		0x46524
1805 #define _CLKGATE_DIS_PSL_C		0x46528
1806 #define   DUPS1_GATING_DIS		(1 << 15)
1807 #define   DUPS2_GATING_DIS		(1 << 19)
1808 #define   DUPS3_GATING_DIS		(1 << 23)
1809 #define   CURSOR_GATING_DIS		REG_BIT(28)
1810 #define   DPF_GATING_DIS		(1 << 10)
1811 #define   DPF_RAM_GATING_DIS		(1 << 9)
1812 #define   DPFR_GATING_DIS		(1 << 8)
1813 
1814 #define CLKGATE_DIS_PSL(pipe) \
1815 	_MMIO_PIPE(pipe, _CLKGATE_DIS_PSL_A, _CLKGATE_DIS_PSL_B)
1816 
1817 #define _CLKGATE_DIS_PSL_EXT_A		0x4654C
1818 #define _CLKGATE_DIS_PSL_EXT_B		0x46550
1819 #define   PIPEDMC_GATING_DIS		REG_BIT(12)
1820 
1821 #define CLKGATE_DIS_PSL_EXT(pipe) \
1822 	_MMIO_PIPE(pipe, _CLKGATE_DIS_PSL_EXT_A, _CLKGATE_DIS_PSL_EXT_B)
1823 
1824 /*
1825  * Display engine regs
1826  */
1827 
1828 /* Pipe A CRC regs */
1829 #define _PIPE_CRC_CTL_A			0x60050
1830 #define   PIPE_CRC_ENABLE		REG_BIT(31)
1831 /* skl+ source selection */
1832 #define   PIPE_CRC_SOURCE_MASK_SKL	REG_GENMASK(30, 28)
1833 #define   PIPE_CRC_SOURCE_PLANE_1_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 0)
1834 #define   PIPE_CRC_SOURCE_PLANE_2_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 2)
1835 #define   PIPE_CRC_SOURCE_DMUX_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 4)
1836 #define   PIPE_CRC_SOURCE_PLANE_3_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 6)
1837 #define   PIPE_CRC_SOURCE_PLANE_4_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 7)
1838 #define   PIPE_CRC_SOURCE_PLANE_5_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 5)
1839 #define   PIPE_CRC_SOURCE_PLANE_6_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 3)
1840 #define   PIPE_CRC_SOURCE_PLANE_7_SKL	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 1)
1841 /* ivb+ source selection */
1842 #define   PIPE_CRC_SOURCE_MASK_IVB	REG_GENMASK(30, 29)
1843 #define   PIPE_CRC_SOURCE_PRIMARY_IVB	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 0)
1844 #define   PIPE_CRC_SOURCE_SPRITE_IVB	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 1)
1845 #define   PIPE_CRC_SOURCE_PF_IVB	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 2)
1846 /* ilk+ source selection */
1847 #define   PIPE_CRC_SOURCE_MASK_ILK	REG_GENMASK(30, 28)
1848 #define   PIPE_CRC_SOURCE_PRIMARY_ILK	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 0)
1849 #define   PIPE_CRC_SOURCE_SPRITE_ILK	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 1)
1850 #define   PIPE_CRC_SOURCE_PIPE_ILK	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 2)
1851 /* embedded DP port on the north display block */
1852 #define   PIPE_CRC_SOURCE_PORT_A_ILK	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 4)
1853 #define   PIPE_CRC_SOURCE_FDI_ILK	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 5)
1854 /* vlv source selection */
1855 #define   PIPE_CRC_SOURCE_MASK_VLV	REG_GENMASK(30, 27)
1856 #define   PIPE_CRC_SOURCE_PIPE_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 0)
1857 #define   PIPE_CRC_SOURCE_HDMIB_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 1)
1858 #define   PIPE_CRC_SOURCE_HDMIC_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 2)
1859 /* with DP port the pipe source is invalid */
1860 #define   PIPE_CRC_SOURCE_DP_D_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 3)
1861 #define   PIPE_CRC_SOURCE_DP_B_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 6)
1862 #define   PIPE_CRC_SOURCE_DP_C_VLV	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 7)
1863 /* gen3+ source selection */
1864 #define   PIPE_CRC_SOURCE_MASK_I9XX	REG_GENMASK(30, 28)
1865 #define   PIPE_CRC_SOURCE_PIPE_I9XX	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 0)
1866 #define   PIPE_CRC_SOURCE_SDVOB_I9XX	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 1)
1867 #define   PIPE_CRC_SOURCE_SDVOC_I9XX	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 2)
1868 /* with DP/TV port the pipe source is invalid */
1869 #define   PIPE_CRC_SOURCE_DP_D_G4X	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 3)
1870 #define   PIPE_CRC_SOURCE_TV_PRE	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 4)
1871 #define   PIPE_CRC_SOURCE_TV_POST	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 5)
1872 #define   PIPE_CRC_SOURCE_DP_B_G4X	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 6)
1873 #define   PIPE_CRC_SOURCE_DP_C_G4X	REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 7)
1874 /* gen2 doesn't have source selection bits */
1875 #define   PIPE_CRC_INCLUDE_BORDER_I8XX	REG_BIT(30)
1876 
1877 #define _PIPE_CRC_RES_1_A_IVB		0x60064
1878 #define _PIPE_CRC_RES_2_A_IVB		0x60068
1879 #define _PIPE_CRC_RES_3_A_IVB		0x6006c
1880 #define _PIPE_CRC_RES_4_A_IVB		0x60070
1881 #define _PIPE_CRC_RES_5_A_IVB		0x60074
1882 
1883 #define _PIPE_CRC_RES_RED_A		0x60060
1884 #define _PIPE_CRC_RES_GREEN_A		0x60064
1885 #define _PIPE_CRC_RES_BLUE_A		0x60068
1886 #define _PIPE_CRC_RES_RES1_A_I915	0x6006c
1887 #define _PIPE_CRC_RES_RES2_A_G4X	0x60080
1888 
1889 /* Pipe B CRC regs */
1890 #define _PIPE_CRC_RES_1_B_IVB		0x61064
1891 #define _PIPE_CRC_RES_2_B_IVB		0x61068
1892 #define _PIPE_CRC_RES_3_B_IVB		0x6106c
1893 #define _PIPE_CRC_RES_4_B_IVB		0x61070
1894 #define _PIPE_CRC_RES_5_B_IVB		0x61074
1895 
1896 #define PIPE_CRC_CTL(pipe)		_MMIO_TRANS2(pipe, _PIPE_CRC_CTL_A)
1897 #define PIPE_CRC_RES_1_IVB(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_1_A_IVB)
1898 #define PIPE_CRC_RES_2_IVB(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_2_A_IVB)
1899 #define PIPE_CRC_RES_3_IVB(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_3_A_IVB)
1900 #define PIPE_CRC_RES_4_IVB(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_4_A_IVB)
1901 #define PIPE_CRC_RES_5_IVB(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_5_A_IVB)
1902 
1903 #define PIPE_CRC_RES_RED(pipe)		_MMIO_TRANS2(pipe, _PIPE_CRC_RES_RED_A)
1904 #define PIPE_CRC_RES_GREEN(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_GREEN_A)
1905 #define PIPE_CRC_RES_BLUE(pipe)		_MMIO_TRANS2(pipe, _PIPE_CRC_RES_BLUE_A)
1906 #define PIPE_CRC_RES_RES1_I915(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_RES1_A_I915)
1907 #define PIPE_CRC_RES_RES2_G4X(pipe)	_MMIO_TRANS2(pipe, _PIPE_CRC_RES_RES2_A_G4X)
1908 
1909 /* Pipe A timing regs */
1910 #define _HTOTAL_A	0x60000
1911 #define _HBLANK_A	0x60004
1912 #define _HSYNC_A	0x60008
1913 #define _VTOTAL_A	0x6000c
1914 #define _VBLANK_A	0x60010
1915 #define _VSYNC_A	0x60014
1916 #define _EXITLINE_A	0x60018
1917 #define _PIPEASRC	0x6001c
1918 #define   PIPESRC_WIDTH_MASK	REG_GENMASK(31, 16)
1919 #define   PIPESRC_WIDTH(w)	REG_FIELD_PREP(PIPESRC_WIDTH_MASK, (w))
1920 #define   PIPESRC_HEIGHT_MASK	REG_GENMASK(15, 0)
1921 #define   PIPESRC_HEIGHT(h)	REG_FIELD_PREP(PIPESRC_HEIGHT_MASK, (h))
1922 #define _BCLRPAT_A	0x60020
1923 #define _VSYNCSHIFT_A	0x60028
1924 #define _PIPE_MULT_A	0x6002c
1925 
1926 /* Pipe B timing regs */
1927 #define _HTOTAL_B	0x61000
1928 #define _HBLANK_B	0x61004
1929 #define _HSYNC_B	0x61008
1930 #define _VTOTAL_B	0x6100c
1931 #define _VBLANK_B	0x61010
1932 #define _VSYNC_B	0x61014
1933 #define _PIPEBSRC	0x6101c
1934 #define _BCLRPAT_B	0x61020
1935 #define _VSYNCSHIFT_B	0x61028
1936 #define _PIPE_MULT_B	0x6102c
1937 
1938 /* DSI 0 timing regs */
1939 #define _HTOTAL_DSI0		0x6b000
1940 #define _HSYNC_DSI0		0x6b008
1941 #define _VTOTAL_DSI0		0x6b00c
1942 #define _VSYNC_DSI0		0x6b014
1943 #define _VSYNCSHIFT_DSI0	0x6b028
1944 
1945 /* DSI 1 timing regs */
1946 #define _HTOTAL_DSI1		0x6b800
1947 #define _HSYNC_DSI1		0x6b808
1948 #define _VTOTAL_DSI1		0x6b80c
1949 #define _VSYNC_DSI1		0x6b814
1950 #define _VSYNCSHIFT_DSI1	0x6b828
1951 
1952 #define TRANSCODER_A_OFFSET 0x60000
1953 #define TRANSCODER_B_OFFSET 0x61000
1954 #define TRANSCODER_C_OFFSET 0x62000
1955 #define CHV_TRANSCODER_C_OFFSET 0x63000
1956 #define TRANSCODER_D_OFFSET 0x63000
1957 #define TRANSCODER_EDP_OFFSET 0x6f000
1958 #define TRANSCODER_DSI0_OFFSET	0x6b000
1959 #define TRANSCODER_DSI1_OFFSET	0x6b800
1960 
1961 #define HTOTAL(trans)		_MMIO_TRANS2(trans, _HTOTAL_A)
1962 #define HBLANK(trans)		_MMIO_TRANS2(trans, _HBLANK_A)
1963 #define HSYNC(trans)		_MMIO_TRANS2(trans, _HSYNC_A)
1964 #define VTOTAL(trans)		_MMIO_TRANS2(trans, _VTOTAL_A)
1965 #define VBLANK(trans)		_MMIO_TRANS2(trans, _VBLANK_A)
1966 #define VSYNC(trans)		_MMIO_TRANS2(trans, _VSYNC_A)
1967 #define BCLRPAT(trans)		_MMIO_TRANS2(trans, _BCLRPAT_A)
1968 #define VSYNCSHIFT(trans)	_MMIO_TRANS2(trans, _VSYNCSHIFT_A)
1969 #define PIPESRC(trans)		_MMIO_TRANS2(trans, _PIPEASRC)
1970 #define PIPE_MULT(trans)	_MMIO_TRANS2(trans, _PIPE_MULT_A)
1971 
1972 #define EXITLINE(trans)		_MMIO_TRANS2(trans, _EXITLINE_A)
1973 #define   EXITLINE_ENABLE	REG_BIT(31)
1974 #define   EXITLINE_MASK		REG_GENMASK(12, 0)
1975 #define   EXITLINE_SHIFT	0
1976 
1977 /* VRR registers */
1978 #define _TRANS_VRR_CTL_A		0x60420
1979 #define _TRANS_VRR_CTL_B		0x61420
1980 #define _TRANS_VRR_CTL_C		0x62420
1981 #define _TRANS_VRR_CTL_D		0x63420
1982 #define TRANS_VRR_CTL(trans)			_MMIO_TRANS2(trans, _TRANS_VRR_CTL_A)
1983 #define   VRR_CTL_VRR_ENABLE			REG_BIT(31)
1984 #define   VRR_CTL_IGN_MAX_SHIFT			REG_BIT(30)
1985 #define   VRR_CTL_FLIP_LINE_EN			REG_BIT(29)
1986 #define   VRR_CTL_PIPELINE_FULL_MASK		REG_GENMASK(10, 3)
1987 #define   VRR_CTL_PIPELINE_FULL(x)		REG_FIELD_PREP(VRR_CTL_PIPELINE_FULL_MASK, (x))
1988 #define   VRR_CTL_PIPELINE_FULL_OVERRIDE	REG_BIT(0)
1989 #define	  XELPD_VRR_CTL_VRR_GUARDBAND_MASK	REG_GENMASK(15, 0)
1990 #define	  XELPD_VRR_CTL_VRR_GUARDBAND(x)	REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, (x))
1991 
1992 #define _TRANS_VRR_VMAX_A		0x60424
1993 #define _TRANS_VRR_VMAX_B		0x61424
1994 #define _TRANS_VRR_VMAX_C		0x62424
1995 #define _TRANS_VRR_VMAX_D		0x63424
1996 #define TRANS_VRR_VMAX(trans)		_MMIO_TRANS2(trans, _TRANS_VRR_VMAX_A)
1997 #define   VRR_VMAX_MASK			REG_GENMASK(19, 0)
1998 
1999 #define _TRANS_VRR_VMIN_A		0x60434
2000 #define _TRANS_VRR_VMIN_B		0x61434
2001 #define _TRANS_VRR_VMIN_C		0x62434
2002 #define _TRANS_VRR_VMIN_D		0x63434
2003 #define TRANS_VRR_VMIN(trans)		_MMIO_TRANS2(trans, _TRANS_VRR_VMIN_A)
2004 #define   VRR_VMIN_MASK			REG_GENMASK(15, 0)
2005 
2006 #define _TRANS_VRR_VMAXSHIFT_A		0x60428
2007 #define _TRANS_VRR_VMAXSHIFT_B		0x61428
2008 #define _TRANS_VRR_VMAXSHIFT_C		0x62428
2009 #define _TRANS_VRR_VMAXSHIFT_D		0x63428
2010 #define TRANS_VRR_VMAXSHIFT(trans)	_MMIO_TRANS2(trans, \
2011 					_TRANS_VRR_VMAXSHIFT_A)
2012 #define   VRR_VMAXSHIFT_DEC_MASK	REG_GENMASK(29, 16)
2013 #define   VRR_VMAXSHIFT_DEC		REG_BIT(16)
2014 #define   VRR_VMAXSHIFT_INC_MASK	REG_GENMASK(12, 0)
2015 
2016 #define _TRANS_VRR_STATUS_A		0x6042C
2017 #define _TRANS_VRR_STATUS_B		0x6142C
2018 #define _TRANS_VRR_STATUS_C		0x6242C
2019 #define _TRANS_VRR_STATUS_D		0x6342C
2020 #define TRANS_VRR_STATUS(trans)		_MMIO_TRANS2(trans, _TRANS_VRR_STATUS_A)
2021 #define   VRR_STATUS_VMAX_REACHED	REG_BIT(31)
2022 #define   VRR_STATUS_NOFLIP_TILL_BNDR	REG_BIT(30)
2023 #define   VRR_STATUS_FLIP_BEF_BNDR	REG_BIT(29)
2024 #define   VRR_STATUS_NO_FLIP_FRAME	REG_BIT(28)
2025 #define   VRR_STATUS_VRR_EN_LIVE	REG_BIT(27)
2026 #define   VRR_STATUS_FLIPS_SERVICED	REG_BIT(26)
2027 #define   VRR_STATUS_VBLANK_MASK	REG_GENMASK(22, 20)
2028 #define   STATUS_FSM_IDLE		REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 0)
2029 #define   STATUS_FSM_WAIT_TILL_FDB	REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 1)
2030 #define   STATUS_FSM_WAIT_TILL_FS	REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 2)
2031 #define   STATUS_FSM_WAIT_TILL_FLIP	REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 3)
2032 #define   STATUS_FSM_PIPELINE_FILL	REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 4)
2033 #define   STATUS_FSM_ACTIVE		REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 5)
2034 #define   STATUS_FSM_LEGACY_VBLANK	REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 6)
2035 
2036 #define _TRANS_VRR_VTOTAL_PREV_A	0x60480
2037 #define _TRANS_VRR_VTOTAL_PREV_B	0x61480
2038 #define _TRANS_VRR_VTOTAL_PREV_C	0x62480
2039 #define _TRANS_VRR_VTOTAL_PREV_D	0x63480
2040 #define TRANS_VRR_VTOTAL_PREV(trans)	_MMIO_TRANS2(trans, \
2041 					_TRANS_VRR_VTOTAL_PREV_A)
2042 #define   VRR_VTOTAL_FLIP_BEFR_BNDR	REG_BIT(31)
2043 #define   VRR_VTOTAL_FLIP_AFTER_BNDR	REG_BIT(30)
2044 #define   VRR_VTOTAL_FLIP_AFTER_DBLBUF	REG_BIT(29)
2045 #define   VRR_VTOTAL_PREV_FRAME_MASK	REG_GENMASK(19, 0)
2046 
2047 #define _TRANS_VRR_FLIPLINE_A		0x60438
2048 #define _TRANS_VRR_FLIPLINE_B		0x61438
2049 #define _TRANS_VRR_FLIPLINE_C		0x62438
2050 #define _TRANS_VRR_FLIPLINE_D		0x63438
2051 #define TRANS_VRR_FLIPLINE(trans)	_MMIO_TRANS2(trans, \
2052 					_TRANS_VRR_FLIPLINE_A)
2053 #define   VRR_FLIPLINE_MASK		REG_GENMASK(19, 0)
2054 
2055 #define _TRANS_VRR_STATUS2_A		0x6043C
2056 #define _TRANS_VRR_STATUS2_B		0x6143C
2057 #define _TRANS_VRR_STATUS2_C		0x6243C
2058 #define _TRANS_VRR_STATUS2_D		0x6343C
2059 #define TRANS_VRR_STATUS2(trans)	_MMIO_TRANS2(trans, _TRANS_VRR_STATUS2_A)
2060 #define   VRR_STATUS2_VERT_LN_CNT_MASK	REG_GENMASK(19, 0)
2061 
2062 #define _TRANS_PUSH_A			0x60A70
2063 #define _TRANS_PUSH_B			0x61A70
2064 #define _TRANS_PUSH_C			0x62A70
2065 #define _TRANS_PUSH_D			0x63A70
2066 #define TRANS_PUSH(trans)		_MMIO_TRANS2(trans, _TRANS_PUSH_A)
2067 #define   TRANS_PUSH_EN			REG_BIT(31)
2068 #define   TRANS_PUSH_SEND		REG_BIT(30)
2069 
2070 /*
2071  * HSW+ eDP PSR registers
2072  *
2073  * HSW PSR registers are relative to DDIA(_DDI_BUF_CTL_A + 0x800) with just one
2074  * instance of it
2075  */
2076 #define _SRD_CTL_A				0x60800
2077 #define _SRD_CTL_EDP				0x6f800
2078 #define EDP_PSR_CTL(tran)			_MMIO_TRANS2(tran, _SRD_CTL_A)
2079 #define   EDP_PSR_ENABLE			(1 << 31)
2080 #define   BDW_PSR_SINGLE_FRAME			(1 << 30)
2081 #define   EDP_PSR_RESTORE_PSR_ACTIVE_CTX_MASK	(1 << 29) /* SW can't modify */
2082 #define   EDP_PSR_LINK_STANDBY			(1 << 27)
2083 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_MASK	(3 << 25)
2084 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_8_LINES	(0 << 25)
2085 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_4_LINES	(1 << 25)
2086 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_2_LINES	(2 << 25)
2087 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_0_LINES	(3 << 25)
2088 #define   EDP_PSR_MAX_SLEEP_TIME_SHIFT		20
2089 #define   EDP_PSR_SKIP_AUX_EXIT			(1 << 12)
2090 #define   EDP_PSR_TP1_TP2_SEL			(0 << 11)
2091 #define   EDP_PSR_TP1_TP3_SEL			(1 << 11)
2092 #define   EDP_PSR_CRC_ENABLE			(1 << 10) /* BDW+ */
2093 #define   EDP_PSR_TP2_TP3_TIME_500us		(0 << 8)
2094 #define   EDP_PSR_TP2_TP3_TIME_100us		(1 << 8)
2095 #define   EDP_PSR_TP2_TP3_TIME_2500us		(2 << 8)
2096 #define   EDP_PSR_TP2_TP3_TIME_0us		(3 << 8)
2097 #define   EDP_PSR_TP4_TIME_0US			(3 << 6) /* ICL+ */
2098 #define   EDP_PSR_TP1_TIME_500us		(0 << 4)
2099 #define   EDP_PSR_TP1_TIME_100us		(1 << 4)
2100 #define   EDP_PSR_TP1_TIME_2500us		(2 << 4)
2101 #define   EDP_PSR_TP1_TIME_0us			(3 << 4)
2102 #define   EDP_PSR_IDLE_FRAME_SHIFT		0
2103 
2104 /*
2105  * Until TGL, IMR/IIR are fixed at 0x648xx. On TGL+ those registers are relative
2106  * to transcoder and bits defined for each one as if using no shift (i.e. as if
2107  * it was for TRANSCODER_EDP)
2108  */
2109 #define EDP_PSR_IMR				_MMIO(0x64834)
2110 #define EDP_PSR_IIR				_MMIO(0x64838)
2111 #define _PSR_IMR_A				0x60814
2112 #define _PSR_IIR_A				0x60818
2113 #define TRANS_PSR_IMR(tran)			_MMIO_TRANS2(tran, _PSR_IMR_A)
2114 #define TRANS_PSR_IIR(tran)			_MMIO_TRANS2(tran, _PSR_IIR_A)
2115 #define   _EDP_PSR_TRANS_SHIFT(trans)		((trans) == TRANSCODER_EDP ? \
2116 						 0 : ((trans) - TRANSCODER_A + 1) * 8)
2117 #define   TGL_PSR_MASK			REG_GENMASK(2, 0)
2118 #define   TGL_PSR_ERROR			REG_BIT(2)
2119 #define   TGL_PSR_POST_EXIT		REG_BIT(1)
2120 #define   TGL_PSR_PRE_ENTRY		REG_BIT(0)
2121 #define   EDP_PSR_MASK(trans)		(TGL_PSR_MASK <<		\
2122 					 _EDP_PSR_TRANS_SHIFT(trans))
2123 #define   EDP_PSR_ERROR(trans)		(TGL_PSR_ERROR <<		\
2124 					 _EDP_PSR_TRANS_SHIFT(trans))
2125 #define   EDP_PSR_POST_EXIT(trans)	(TGL_PSR_POST_EXIT <<		\
2126 					 _EDP_PSR_TRANS_SHIFT(trans))
2127 #define   EDP_PSR_PRE_ENTRY(trans)	(TGL_PSR_PRE_ENTRY <<		\
2128 					 _EDP_PSR_TRANS_SHIFT(trans))
2129 
2130 #define _SRD_AUX_DATA_A				0x60814
2131 #define _SRD_AUX_DATA_EDP			0x6f814
2132 #define EDP_PSR_AUX_DATA(tran, i)		_MMIO_TRANS2(tran, _SRD_AUX_DATA_A + (i) + 4) /* 5 registers */
2133 
2134 #define _SRD_STATUS_A				0x60840
2135 #define _SRD_STATUS_EDP				0x6f840
2136 #define EDP_PSR_STATUS(tran)			_MMIO_TRANS2(tran, _SRD_STATUS_A)
2137 #define   EDP_PSR_STATUS_STATE_MASK		(7 << 29)
2138 #define   EDP_PSR_STATUS_STATE_SHIFT		29
2139 #define   EDP_PSR_STATUS_STATE_IDLE		(0 << 29)
2140 #define   EDP_PSR_STATUS_STATE_SRDONACK		(1 << 29)
2141 #define   EDP_PSR_STATUS_STATE_SRDENT		(2 << 29)
2142 #define   EDP_PSR_STATUS_STATE_BUFOFF		(3 << 29)
2143 #define   EDP_PSR_STATUS_STATE_BUFON		(4 << 29)
2144 #define   EDP_PSR_STATUS_STATE_AUXACK		(5 << 29)
2145 #define   EDP_PSR_STATUS_STATE_SRDOFFACK	(6 << 29)
2146 #define   EDP_PSR_STATUS_LINK_MASK		(3 << 26)
2147 #define   EDP_PSR_STATUS_LINK_FULL_OFF		(0 << 26)
2148 #define   EDP_PSR_STATUS_LINK_FULL_ON		(1 << 26)
2149 #define   EDP_PSR_STATUS_LINK_STANDBY		(2 << 26)
2150 #define   EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT	20
2151 #define   EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK	0x1f
2152 #define   EDP_PSR_STATUS_COUNT_SHIFT		16
2153 #define   EDP_PSR_STATUS_COUNT_MASK		0xf
2154 #define   EDP_PSR_STATUS_AUX_ERROR		(1 << 15)
2155 #define   EDP_PSR_STATUS_AUX_SENDING		(1 << 12)
2156 #define   EDP_PSR_STATUS_SENDING_IDLE		(1 << 9)
2157 #define   EDP_PSR_STATUS_SENDING_TP2_TP3	(1 << 8)
2158 #define   EDP_PSR_STATUS_SENDING_TP1		(1 << 4)
2159 #define   EDP_PSR_STATUS_IDLE_MASK		0xf
2160 
2161 #define _SRD_PERF_CNT_A			0x60844
2162 #define _SRD_PERF_CNT_EDP		0x6f844
2163 #define EDP_PSR_PERF_CNT(tran)		_MMIO_TRANS2(tran, _SRD_PERF_CNT_A)
2164 #define   EDP_PSR_PERF_CNT_MASK		0xffffff
2165 
2166 /* PSR_MASK on SKL+ */
2167 #define _SRD_DEBUG_A				0x60860
2168 #define _SRD_DEBUG_EDP				0x6f860
2169 #define EDP_PSR_DEBUG(tran)			_MMIO_TRANS2(tran, _SRD_DEBUG_A)
2170 #define   EDP_PSR_DEBUG_MASK_MAX_SLEEP         (1 << 28)
2171 #define   EDP_PSR_DEBUG_MASK_LPSP              (1 << 27)
2172 #define   EDP_PSR_DEBUG_MASK_MEMUP             (1 << 26)
2173 #define   EDP_PSR_DEBUG_MASK_HPD               (1 << 25)
2174 #define   EDP_PSR_DEBUG_MASK_DISP_REG_WRITE    (1 << 16) /* Reserved in ICL+ */
2175 #define   EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1 << 15) /* SKL+ */
2176 
2177 #define _PSR2_CTL_A				0x60900
2178 #define _PSR2_CTL_EDP				0x6f900
2179 #define EDP_PSR2_CTL(tran)			_MMIO_TRANS2(tran, _PSR2_CTL_A)
2180 #define   EDP_PSR2_ENABLE			(1 << 31)
2181 #define   EDP_SU_TRACK_ENABLE			(1 << 30) /* up to adl-p */
2182 #define   TGL_EDP_PSR2_BLOCK_COUNT_NUM_2	(0 << 28)
2183 #define   TGL_EDP_PSR2_BLOCK_COUNT_NUM_3	(1 << 28)
2184 #define   EDP_Y_COORDINATE_ENABLE		REG_BIT(25) /* display 10, 11 and 12 */
2185 #define   EDP_PSR2_SU_SDP_SCANLINE		REG_BIT(25) /* display 13+ */
2186 #define   EDP_MAX_SU_DISABLE_TIME(t)		((t) << 20)
2187 #define   EDP_MAX_SU_DISABLE_TIME_MASK		(0x1f << 20)
2188 #define   EDP_PSR2_IO_BUFFER_WAKE_MAX_LINES	8
2189 #define   EDP_PSR2_IO_BUFFER_WAKE(lines)	((EDP_PSR2_IO_BUFFER_WAKE_MAX_LINES - (lines)) << 13)
2190 #define   EDP_PSR2_IO_BUFFER_WAKE_MASK		(3 << 13)
2191 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_MIN_LINES	5
2192 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_SHIFT	13
2193 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE(lines)	(((lines) - TGL_EDP_PSR2_IO_BUFFER_WAKE_MIN_LINES) << TGL_EDP_PSR2_IO_BUFFER_WAKE_SHIFT)
2194 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_MASK	(7 << 13)
2195 #define   EDP_PSR2_FAST_WAKE_MAX_LINES		8
2196 #define   EDP_PSR2_FAST_WAKE(lines)		((EDP_PSR2_FAST_WAKE_MAX_LINES - (lines)) << 11)
2197 #define   EDP_PSR2_FAST_WAKE_MASK		(3 << 11)
2198 #define   TGL_EDP_PSR2_FAST_WAKE_MIN_LINES	5
2199 #define   TGL_EDP_PSR2_FAST_WAKE_MIN_SHIFT	10
2200 #define   TGL_EDP_PSR2_FAST_WAKE(lines)		(((lines) - TGL_EDP_PSR2_FAST_WAKE_MIN_LINES) << TGL_EDP_PSR2_FAST_WAKE_MIN_SHIFT)
2201 #define   TGL_EDP_PSR2_FAST_WAKE_MASK		(7 << 10)
2202 #define   EDP_PSR2_TP2_TIME_500us		(0 << 8)
2203 #define   EDP_PSR2_TP2_TIME_100us		(1 << 8)
2204 #define   EDP_PSR2_TP2_TIME_2500us		(2 << 8)
2205 #define   EDP_PSR2_TP2_TIME_50us		(3 << 8)
2206 #define   EDP_PSR2_TP2_TIME_MASK		(3 << 8)
2207 #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT	4
2208 #define   EDP_PSR2_FRAME_BEFORE_SU_MASK		(0xf << 4)
2209 #define   EDP_PSR2_FRAME_BEFORE_SU(a)		((a) << 4)
2210 #define   EDP_PSR2_IDLE_FRAME_MASK		0xf
2211 #define   EDP_PSR2_IDLE_FRAME_SHIFT		0
2212 
2213 #define _PSR_EVENT_TRANS_A			0x60848
2214 #define _PSR_EVENT_TRANS_B			0x61848
2215 #define _PSR_EVENT_TRANS_C			0x62848
2216 #define _PSR_EVENT_TRANS_D			0x63848
2217 #define _PSR_EVENT_TRANS_EDP			0x6f848
2218 #define PSR_EVENT(tran)				_MMIO_TRANS2(tran, _PSR_EVENT_TRANS_A)
2219 #define  PSR_EVENT_PSR2_WD_TIMER_EXPIRE		(1 << 17)
2220 #define  PSR_EVENT_PSR2_DISABLED		(1 << 16)
2221 #define  PSR_EVENT_SU_DIRTY_FIFO_UNDERRUN	(1 << 15)
2222 #define  PSR_EVENT_SU_CRC_FIFO_UNDERRUN		(1 << 14)
2223 #define  PSR_EVENT_GRAPHICS_RESET		(1 << 12)
2224 #define  PSR_EVENT_PCH_INTERRUPT		(1 << 11)
2225 #define  PSR_EVENT_MEMORY_UP			(1 << 10)
2226 #define  PSR_EVENT_FRONT_BUFFER_MODIFY		(1 << 9)
2227 #define  PSR_EVENT_WD_TIMER_EXPIRE		(1 << 8)
2228 #define  PSR_EVENT_PIPE_REGISTERS_UPDATE	(1 << 6)
2229 #define  PSR_EVENT_REGISTER_UPDATE		(1 << 5) /* Reserved in ICL+ */
2230 #define  PSR_EVENT_HDCP_ENABLE			(1 << 4)
2231 #define  PSR_EVENT_KVMR_SESSION_ENABLE		(1 << 3)
2232 #define  PSR_EVENT_VBI_ENABLE			(1 << 2)
2233 #define  PSR_EVENT_LPSP_MODE_EXIT		(1 << 1)
2234 #define  PSR_EVENT_PSR_DISABLE			(1 << 0)
2235 
2236 #define _PSR2_STATUS_A				0x60940
2237 #define _PSR2_STATUS_EDP			0x6f940
2238 #define EDP_PSR2_STATUS(tran)			_MMIO_TRANS2(tran, _PSR2_STATUS_A)
2239 #define EDP_PSR2_STATUS_STATE_MASK		REG_GENMASK(31, 28)
2240 #define EDP_PSR2_STATUS_STATE_DEEP_SLEEP	REG_FIELD_PREP(EDP_PSR2_STATUS_STATE_MASK, 0x8)
2241 
2242 #define _PSR2_SU_STATUS_A		0x60914
2243 #define _PSR2_SU_STATUS_EDP		0x6f914
2244 #define _PSR2_SU_STATUS(tran, index)	_MMIO_TRANS2(tran, _PSR2_SU_STATUS_A + (index) * 4)
2245 #define PSR2_SU_STATUS(tran, frame)	(_PSR2_SU_STATUS(tran, (frame) / 3))
2246 #define PSR2_SU_STATUS_SHIFT(frame)	(((frame) % 3) * 10)
2247 #define PSR2_SU_STATUS_MASK(frame)	(0x3ff << PSR2_SU_STATUS_SHIFT(frame))
2248 #define PSR2_SU_STATUS_FRAMES		8
2249 
2250 #define _PSR2_MAN_TRK_CTL_A					0x60910
2251 #define _PSR2_MAN_TRK_CTL_EDP					0x6f910
2252 #define PSR2_MAN_TRK_CTL(tran)					_MMIO_TRANS2(tran, _PSR2_MAN_TRK_CTL_A)
2253 #define  PSR2_MAN_TRK_CTL_ENABLE				REG_BIT(31)
2254 #define  PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK		REG_GENMASK(30, 21)
2255 #define  PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR(val)		REG_FIELD_PREP(PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK, val)
2256 #define  PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK		REG_GENMASK(20, 11)
2257 #define  PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR(val)		REG_FIELD_PREP(PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK, val)
2258 #define  PSR2_MAN_TRK_CTL_SF_SINGLE_FULL_FRAME			REG_BIT(3)
2259 #define  PSR2_MAN_TRK_CTL_SF_CONTINUOS_FULL_FRAME		REG_BIT(2)
2260 #define  PSR2_MAN_TRK_CTL_SF_PARTIAL_FRAME_UPDATE		REG_BIT(1)
2261 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK	REG_GENMASK(28, 16)
2262 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR(val)	REG_FIELD_PREP(ADLP_PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK, val)
2263 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK		REG_GENMASK(12, 0)
2264 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR(val)		REG_FIELD_PREP(ADLP_PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK, val)
2265 #define  ADLP_PSR2_MAN_TRK_CTL_SF_PARTIAL_FRAME_UPDATE		REG_BIT(31)
2266 #define  ADLP_PSR2_MAN_TRK_CTL_SF_SINGLE_FULL_FRAME		REG_BIT(14)
2267 #define  ADLP_PSR2_MAN_TRK_CTL_SF_CONTINUOS_FULL_FRAME		REG_BIT(13)
2268 
2269 /* Icelake DSC Rate Control Range Parameter Registers */
2270 #define DSCA_RC_RANGE_PARAMETERS_0		_MMIO(0x6B240)
2271 #define DSCA_RC_RANGE_PARAMETERS_0_UDW		_MMIO(0x6B240 + 4)
2272 #define DSCC_RC_RANGE_PARAMETERS_0		_MMIO(0x6BA40)
2273 #define DSCC_RC_RANGE_PARAMETERS_0_UDW		_MMIO(0x6BA40 + 4)
2274 #define _ICL_DSC0_RC_RANGE_PARAMETERS_0_PB	(0x78208)
2275 #define _ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW_PB	(0x78208 + 4)
2276 #define _ICL_DSC1_RC_RANGE_PARAMETERS_0_PB	(0x78308)
2277 #define _ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW_PB	(0x78308 + 4)
2278 #define _ICL_DSC0_RC_RANGE_PARAMETERS_0_PC	(0x78408)
2279 #define _ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW_PC	(0x78408 + 4)
2280 #define _ICL_DSC1_RC_RANGE_PARAMETERS_0_PC	(0x78508)
2281 #define _ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW_PC	(0x78508 + 4)
2282 #define ICL_DSC0_RC_RANGE_PARAMETERS_0(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2283 							_ICL_DSC0_RC_RANGE_PARAMETERS_0_PB, \
2284 							_ICL_DSC0_RC_RANGE_PARAMETERS_0_PC)
2285 #define ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2286 							_ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW_PB, \
2287 							_ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW_PC)
2288 #define ICL_DSC1_RC_RANGE_PARAMETERS_0(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2289 							_ICL_DSC1_RC_RANGE_PARAMETERS_0_PB, \
2290 							_ICL_DSC1_RC_RANGE_PARAMETERS_0_PC)
2291 #define ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2292 							_ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW_PB, \
2293 							_ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW_PC)
2294 #define RC_BPG_OFFSET_SHIFT			10
2295 #define RC_MAX_QP_SHIFT				5
2296 #define RC_MIN_QP_SHIFT				0
2297 
2298 #define DSCA_RC_RANGE_PARAMETERS_1		_MMIO(0x6B248)
2299 #define DSCA_RC_RANGE_PARAMETERS_1_UDW		_MMIO(0x6B248 + 4)
2300 #define DSCC_RC_RANGE_PARAMETERS_1		_MMIO(0x6BA48)
2301 #define DSCC_RC_RANGE_PARAMETERS_1_UDW		_MMIO(0x6BA48 + 4)
2302 #define _ICL_DSC0_RC_RANGE_PARAMETERS_1_PB	(0x78210)
2303 #define _ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW_PB	(0x78210 + 4)
2304 #define _ICL_DSC1_RC_RANGE_PARAMETERS_1_PB	(0x78310)
2305 #define _ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW_PB	(0x78310 + 4)
2306 #define _ICL_DSC0_RC_RANGE_PARAMETERS_1_PC	(0x78410)
2307 #define _ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW_PC	(0x78410 + 4)
2308 #define _ICL_DSC1_RC_RANGE_PARAMETERS_1_PC	(0x78510)
2309 #define _ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW_PC	(0x78510 + 4)
2310 #define ICL_DSC0_RC_RANGE_PARAMETERS_1(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2311 							_ICL_DSC0_RC_RANGE_PARAMETERS_1_PB, \
2312 							_ICL_DSC0_RC_RANGE_PARAMETERS_1_PC)
2313 #define ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2314 							_ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW_PB, \
2315 							_ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW_PC)
2316 #define ICL_DSC1_RC_RANGE_PARAMETERS_1(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2317 							_ICL_DSC1_RC_RANGE_PARAMETERS_1_PB, \
2318 							_ICL_DSC1_RC_RANGE_PARAMETERS_1_PC)
2319 #define ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2320 							_ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW_PB, \
2321 							_ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW_PC)
2322 
2323 #define DSCA_RC_RANGE_PARAMETERS_2		_MMIO(0x6B250)
2324 #define DSCA_RC_RANGE_PARAMETERS_2_UDW		_MMIO(0x6B250 + 4)
2325 #define DSCC_RC_RANGE_PARAMETERS_2		_MMIO(0x6BA50)
2326 #define DSCC_RC_RANGE_PARAMETERS_2_UDW		_MMIO(0x6BA50 + 4)
2327 #define _ICL_DSC0_RC_RANGE_PARAMETERS_2_PB	(0x78218)
2328 #define _ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW_PB	(0x78218 + 4)
2329 #define _ICL_DSC1_RC_RANGE_PARAMETERS_2_PB	(0x78318)
2330 #define _ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW_PB	(0x78318 + 4)
2331 #define _ICL_DSC0_RC_RANGE_PARAMETERS_2_PC	(0x78418)
2332 #define _ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW_PC	(0x78418 + 4)
2333 #define _ICL_DSC1_RC_RANGE_PARAMETERS_2_PC	(0x78518)
2334 #define _ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW_PC	(0x78518 + 4)
2335 #define ICL_DSC0_RC_RANGE_PARAMETERS_2(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2336 							_ICL_DSC0_RC_RANGE_PARAMETERS_2_PB, \
2337 							_ICL_DSC0_RC_RANGE_PARAMETERS_2_PC)
2338 #define ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2339 							_ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW_PB, \
2340 							_ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW_PC)
2341 #define ICL_DSC1_RC_RANGE_PARAMETERS_2(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2342 							_ICL_DSC1_RC_RANGE_PARAMETERS_2_PB, \
2343 							_ICL_DSC1_RC_RANGE_PARAMETERS_2_PC)
2344 #define ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2345 							_ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW_PB, \
2346 							_ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW_PC)
2347 
2348 #define DSCA_RC_RANGE_PARAMETERS_3		_MMIO(0x6B258)
2349 #define DSCA_RC_RANGE_PARAMETERS_3_UDW		_MMIO(0x6B258 + 4)
2350 #define DSCC_RC_RANGE_PARAMETERS_3		_MMIO(0x6BA58)
2351 #define DSCC_RC_RANGE_PARAMETERS_3_UDW		_MMIO(0x6BA58 + 4)
2352 #define _ICL_DSC0_RC_RANGE_PARAMETERS_3_PB	(0x78220)
2353 #define _ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW_PB	(0x78220 + 4)
2354 #define _ICL_DSC1_RC_RANGE_PARAMETERS_3_PB	(0x78320)
2355 #define _ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW_PB	(0x78320 + 4)
2356 #define _ICL_DSC0_RC_RANGE_PARAMETERS_3_PC	(0x78420)
2357 #define _ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW_PC	(0x78420 + 4)
2358 #define _ICL_DSC1_RC_RANGE_PARAMETERS_3_PC	(0x78520)
2359 #define _ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW_PC	(0x78520 + 4)
2360 #define ICL_DSC0_RC_RANGE_PARAMETERS_3(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2361 							_ICL_DSC0_RC_RANGE_PARAMETERS_3_PB, \
2362 							_ICL_DSC0_RC_RANGE_PARAMETERS_3_PC)
2363 #define ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2364 							_ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW_PB, \
2365 							_ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW_PC)
2366 #define ICL_DSC1_RC_RANGE_PARAMETERS_3(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
2367 							_ICL_DSC1_RC_RANGE_PARAMETERS_3_PB, \
2368 							_ICL_DSC1_RC_RANGE_PARAMETERS_3_PC)
2369 #define ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
2370 							_ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW_PB, \
2371 							_ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW_PC)
2372 
2373 /* VGA port control */
2374 #define ADPA			_MMIO(0x61100)
2375 #define PCH_ADPA                _MMIO(0xe1100)
2376 #define VLV_ADPA		_MMIO(VLV_DISPLAY_BASE + 0x61100)
2377 
2378 #define   ADPA_DAC_ENABLE	(1 << 31)
2379 #define   ADPA_DAC_DISABLE	0
2380 #define   ADPA_PIPE_SEL_SHIFT		30
2381 #define   ADPA_PIPE_SEL_MASK		(1 << 30)
2382 #define   ADPA_PIPE_SEL(pipe)		((pipe) << 30)
2383 #define   ADPA_PIPE_SEL_SHIFT_CPT	29
2384 #define   ADPA_PIPE_SEL_MASK_CPT	(3 << 29)
2385 #define   ADPA_PIPE_SEL_CPT(pipe)	((pipe) << 29)
2386 #define   ADPA_CRT_HOTPLUG_MASK  0x03ff0000 /* bit 25-16 */
2387 #define   ADPA_CRT_HOTPLUG_MONITOR_NONE  (0 << 24)
2388 #define   ADPA_CRT_HOTPLUG_MONITOR_MASK  (3 << 24)
2389 #define   ADPA_CRT_HOTPLUG_MONITOR_COLOR (3 << 24)
2390 #define   ADPA_CRT_HOTPLUG_MONITOR_MONO  (2 << 24)
2391 #define   ADPA_CRT_HOTPLUG_ENABLE        (1 << 23)
2392 #define   ADPA_CRT_HOTPLUG_PERIOD_64     (0 << 22)
2393 #define   ADPA_CRT_HOTPLUG_PERIOD_128    (1 << 22)
2394 #define   ADPA_CRT_HOTPLUG_WARMUP_5MS    (0 << 21)
2395 #define   ADPA_CRT_HOTPLUG_WARMUP_10MS   (1 << 21)
2396 #define   ADPA_CRT_HOTPLUG_SAMPLE_2S     (0 << 20)
2397 #define   ADPA_CRT_HOTPLUG_SAMPLE_4S     (1 << 20)
2398 #define   ADPA_CRT_HOTPLUG_VOLTAGE_40    (0 << 18)
2399 #define   ADPA_CRT_HOTPLUG_VOLTAGE_50    (1 << 18)
2400 #define   ADPA_CRT_HOTPLUG_VOLTAGE_60    (2 << 18)
2401 #define   ADPA_CRT_HOTPLUG_VOLTAGE_70    (3 << 18)
2402 #define   ADPA_CRT_HOTPLUG_VOLREF_325MV  (0 << 17)
2403 #define   ADPA_CRT_HOTPLUG_VOLREF_475MV  (1 << 17)
2404 #define   ADPA_CRT_HOTPLUG_FORCE_TRIGGER (1 << 16)
2405 #define   ADPA_USE_VGA_HVPOLARITY (1 << 15)
2406 #define   ADPA_SETS_HVPOLARITY	0
2407 #define   ADPA_VSYNC_CNTL_DISABLE (1 << 10)
2408 #define   ADPA_VSYNC_CNTL_ENABLE 0
2409 #define   ADPA_HSYNC_CNTL_DISABLE (1 << 11)
2410 #define   ADPA_HSYNC_CNTL_ENABLE 0
2411 #define   ADPA_VSYNC_ACTIVE_HIGH (1 << 4)
2412 #define   ADPA_VSYNC_ACTIVE_LOW	0
2413 #define   ADPA_HSYNC_ACTIVE_HIGH (1 << 3)
2414 #define   ADPA_HSYNC_ACTIVE_LOW	0
2415 #define   ADPA_DPMS_MASK	(~(3 << 10))
2416 #define   ADPA_DPMS_ON		(0 << 10)
2417 #define   ADPA_DPMS_SUSPEND	(1 << 10)
2418 #define   ADPA_DPMS_STANDBY	(2 << 10)
2419 #define   ADPA_DPMS_OFF		(3 << 10)
2420 
2421 
2422 /* Hotplug control (945+ only) */
2423 #define PORT_HOTPLUG_EN		_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61110)
2424 #define   PORTB_HOTPLUG_INT_EN			(1 << 29)
2425 #define   PORTC_HOTPLUG_INT_EN			(1 << 28)
2426 #define   PORTD_HOTPLUG_INT_EN			(1 << 27)
2427 #define   SDVOB_HOTPLUG_INT_EN			(1 << 26)
2428 #define   SDVOC_HOTPLUG_INT_EN			(1 << 25)
2429 #define   TV_HOTPLUG_INT_EN			(1 << 18)
2430 #define   CRT_HOTPLUG_INT_EN			(1 << 9)
2431 #define HOTPLUG_INT_EN_MASK			(PORTB_HOTPLUG_INT_EN | \
2432 						 PORTC_HOTPLUG_INT_EN | \
2433 						 PORTD_HOTPLUG_INT_EN | \
2434 						 SDVOC_HOTPLUG_INT_EN | \
2435 						 SDVOB_HOTPLUG_INT_EN | \
2436 						 CRT_HOTPLUG_INT_EN)
2437 #define   CRT_HOTPLUG_FORCE_DETECT		(1 << 3)
2438 #define CRT_HOTPLUG_ACTIVATION_PERIOD_32	(0 << 8)
2439 /* must use period 64 on GM45 according to docs */
2440 #define CRT_HOTPLUG_ACTIVATION_PERIOD_64	(1 << 8)
2441 #define CRT_HOTPLUG_DAC_ON_TIME_2M		(0 << 7)
2442 #define CRT_HOTPLUG_DAC_ON_TIME_4M		(1 << 7)
2443 #define CRT_HOTPLUG_VOLTAGE_COMPARE_40		(0 << 5)
2444 #define CRT_HOTPLUG_VOLTAGE_COMPARE_50		(1 << 5)
2445 #define CRT_HOTPLUG_VOLTAGE_COMPARE_60		(2 << 5)
2446 #define CRT_HOTPLUG_VOLTAGE_COMPARE_70		(3 << 5)
2447 #define CRT_HOTPLUG_VOLTAGE_COMPARE_MASK	(3 << 5)
2448 #define CRT_HOTPLUG_DETECT_DELAY_1G		(0 << 4)
2449 #define CRT_HOTPLUG_DETECT_DELAY_2G		(1 << 4)
2450 #define CRT_HOTPLUG_DETECT_VOLTAGE_325MV	(0 << 2)
2451 #define CRT_HOTPLUG_DETECT_VOLTAGE_475MV	(1 << 2)
2452 
2453 #define PORT_HOTPLUG_STAT	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61114)
2454 /*
2455  * HDMI/DP bits are g4x+
2456  *
2457  * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
2458  * Please check the detailed lore in the commit message for for experimental
2459  * evidence.
2460  */
2461 /* Bspec says GM45 should match G4X/VLV/CHV, but reality disagrees */
2462 #define   PORTD_HOTPLUG_LIVE_STATUS_GM45	(1 << 29)
2463 #define   PORTC_HOTPLUG_LIVE_STATUS_GM45	(1 << 28)
2464 #define   PORTB_HOTPLUG_LIVE_STATUS_GM45	(1 << 27)
2465 /* G4X/VLV/CHV DP/HDMI bits again match Bspec */
2466 #define   PORTD_HOTPLUG_LIVE_STATUS_G4X		(1 << 27)
2467 #define   PORTC_HOTPLUG_LIVE_STATUS_G4X		(1 << 28)
2468 #define   PORTB_HOTPLUG_LIVE_STATUS_G4X		(1 << 29)
2469 #define   PORTD_HOTPLUG_INT_STATUS		(3 << 21)
2470 #define   PORTD_HOTPLUG_INT_LONG_PULSE		(2 << 21)
2471 #define   PORTD_HOTPLUG_INT_SHORT_PULSE		(1 << 21)
2472 #define   PORTC_HOTPLUG_INT_STATUS		(3 << 19)
2473 #define   PORTC_HOTPLUG_INT_LONG_PULSE		(2 << 19)
2474 #define   PORTC_HOTPLUG_INT_SHORT_PULSE		(1 << 19)
2475 #define   PORTB_HOTPLUG_INT_STATUS		(3 << 17)
2476 #define   PORTB_HOTPLUG_INT_LONG_PULSE		(2 << 17)
2477 #define   PORTB_HOTPLUG_INT_SHORT_PLUSE		(1 << 17)
2478 /* CRT/TV common between gen3+ */
2479 #define   CRT_HOTPLUG_INT_STATUS		(1 << 11)
2480 #define   TV_HOTPLUG_INT_STATUS			(1 << 10)
2481 #define   CRT_HOTPLUG_MONITOR_MASK		(3 << 8)
2482 #define   CRT_HOTPLUG_MONITOR_COLOR		(3 << 8)
2483 #define   CRT_HOTPLUG_MONITOR_MONO		(2 << 8)
2484 #define   CRT_HOTPLUG_MONITOR_NONE		(0 << 8)
2485 #define   DP_AUX_CHANNEL_D_INT_STATUS_G4X	(1 << 6)
2486 #define   DP_AUX_CHANNEL_C_INT_STATUS_G4X	(1 << 5)
2487 #define   DP_AUX_CHANNEL_B_INT_STATUS_G4X	(1 << 4)
2488 #define   DP_AUX_CHANNEL_MASK_INT_STATUS_G4X	(7 << 4)
2489 
2490 /* SDVO is different across gen3/4 */
2491 #define   SDVOC_HOTPLUG_INT_STATUS_G4X		(1 << 3)
2492 #define   SDVOB_HOTPLUG_INT_STATUS_G4X		(1 << 2)
2493 /*
2494  * Bspec seems to be seriously misleaded about the SDVO hpd bits on i965g/gm,
2495  * since reality corrobates that they're the same as on gen3. But keep these
2496  * bits here (and the comment!) to help any other lost wanderers back onto the
2497  * right tracks.
2498  */
2499 #define   SDVOC_HOTPLUG_INT_STATUS_I965		(3 << 4)
2500 #define   SDVOB_HOTPLUG_INT_STATUS_I965		(3 << 2)
2501 #define   SDVOC_HOTPLUG_INT_STATUS_I915		(1 << 7)
2502 #define   SDVOB_HOTPLUG_INT_STATUS_I915		(1 << 6)
2503 #define   HOTPLUG_INT_STATUS_G4X		(CRT_HOTPLUG_INT_STATUS | \
2504 						 SDVOB_HOTPLUG_INT_STATUS_G4X | \
2505 						 SDVOC_HOTPLUG_INT_STATUS_G4X | \
2506 						 PORTB_HOTPLUG_INT_STATUS | \
2507 						 PORTC_HOTPLUG_INT_STATUS | \
2508 						 PORTD_HOTPLUG_INT_STATUS)
2509 
2510 #define HOTPLUG_INT_STATUS_I915			(CRT_HOTPLUG_INT_STATUS | \
2511 						 SDVOB_HOTPLUG_INT_STATUS_I915 | \
2512 						 SDVOC_HOTPLUG_INT_STATUS_I915 | \
2513 						 PORTB_HOTPLUG_INT_STATUS | \
2514 						 PORTC_HOTPLUG_INT_STATUS | \
2515 						 PORTD_HOTPLUG_INT_STATUS)
2516 
2517 /* SDVO and HDMI port control.
2518  * The same register may be used for SDVO or HDMI */
2519 #define _GEN3_SDVOB	0x61140
2520 #define _GEN3_SDVOC	0x61160
2521 #define GEN3_SDVOB	_MMIO(_GEN3_SDVOB)
2522 #define GEN3_SDVOC	_MMIO(_GEN3_SDVOC)
2523 #define GEN4_HDMIB	GEN3_SDVOB
2524 #define GEN4_HDMIC	GEN3_SDVOC
2525 #define VLV_HDMIB	_MMIO(VLV_DISPLAY_BASE + 0x61140)
2526 #define VLV_HDMIC	_MMIO(VLV_DISPLAY_BASE + 0x61160)
2527 #define CHV_HDMID	_MMIO(VLV_DISPLAY_BASE + 0x6116C)
2528 #define PCH_SDVOB	_MMIO(0xe1140)
2529 #define PCH_HDMIB	PCH_SDVOB
2530 #define PCH_HDMIC	_MMIO(0xe1150)
2531 #define PCH_HDMID	_MMIO(0xe1160)
2532 
2533 #define PORT_DFT_I9XX				_MMIO(0x61150)
2534 #define   DC_BALANCE_RESET			(1 << 25)
2535 #define PORT_DFT2_G4X		_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61154)
2536 #define   DC_BALANCE_RESET_VLV			(1 << 31)
2537 #define   PIPE_SCRAMBLE_RESET_MASK		((1 << 14) | (0x3 << 0))
2538 #define   PIPE_C_SCRAMBLE_RESET			REG_BIT(14) /* chv */
2539 #define   PIPE_B_SCRAMBLE_RESET			REG_BIT(1)
2540 #define   PIPE_A_SCRAMBLE_RESET			REG_BIT(0)
2541 
2542 /* Gen 3 SDVO bits: */
2543 #define   SDVO_ENABLE				(1 << 31)
2544 #define   SDVO_PIPE_SEL_SHIFT			30
2545 #define   SDVO_PIPE_SEL_MASK			(1 << 30)
2546 #define   SDVO_PIPE_SEL(pipe)			((pipe) << 30)
2547 #define   SDVO_STALL_SELECT			(1 << 29)
2548 #define   SDVO_INTERRUPT_ENABLE			(1 << 26)
2549 /*
2550  * 915G/GM SDVO pixel multiplier.
2551  * Programmed value is multiplier - 1, up to 5x.
2552  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
2553  */
2554 #define   SDVO_PORT_MULTIPLY_MASK		(7 << 23)
2555 #define   SDVO_PORT_MULTIPLY_SHIFT		23
2556 #define   SDVO_PHASE_SELECT_MASK		(15 << 19)
2557 #define   SDVO_PHASE_SELECT_DEFAULT		(6 << 19)
2558 #define   SDVO_CLOCK_OUTPUT_INVERT		(1 << 18)
2559 #define   SDVOC_GANG_MODE			(1 << 16) /* Port C only */
2560 #define   SDVO_BORDER_ENABLE			(1 << 7) /* SDVO only */
2561 #define   SDVOB_PCIE_CONCURRENCY		(1 << 3) /* Port B only */
2562 #define   SDVO_DETECTED				(1 << 2)
2563 /* Bits to be preserved when writing */
2564 #define   SDVOB_PRESERVE_MASK ((1 << 17) | (1 << 16) | (1 << 14) | \
2565 			       SDVO_INTERRUPT_ENABLE)
2566 #define   SDVOC_PRESERVE_MASK ((1 << 17) | SDVO_INTERRUPT_ENABLE)
2567 
2568 /* Gen 4 SDVO/HDMI bits: */
2569 #define   SDVO_COLOR_FORMAT_8bpc		(0 << 26)
2570 #define   SDVO_COLOR_FORMAT_MASK		(7 << 26)
2571 #define   SDVO_ENCODING_SDVO			(0 << 10)
2572 #define   SDVO_ENCODING_HDMI			(2 << 10)
2573 #define   HDMI_MODE_SELECT_HDMI			(1 << 9) /* HDMI only */
2574 #define   HDMI_MODE_SELECT_DVI			(0 << 9) /* HDMI only */
2575 #define   HDMI_COLOR_RANGE_16_235		(1 << 8) /* HDMI only */
2576 #define   HDMI_AUDIO_ENABLE			(1 << 6) /* HDMI only */
2577 /* VSYNC/HSYNC bits new with 965, default is to be set */
2578 #define   SDVO_VSYNC_ACTIVE_HIGH		(1 << 4)
2579 #define   SDVO_HSYNC_ACTIVE_HIGH		(1 << 3)
2580 
2581 /* Gen 5 (IBX) SDVO/HDMI bits: */
2582 #define   HDMI_COLOR_FORMAT_12bpc		(3 << 26) /* HDMI only */
2583 #define   SDVOB_HOTPLUG_ENABLE			(1 << 23) /* SDVO only */
2584 
2585 /* Gen 6 (CPT) SDVO/HDMI bits: */
2586 #define   SDVO_PIPE_SEL_SHIFT_CPT		29
2587 #define   SDVO_PIPE_SEL_MASK_CPT		(3 << 29)
2588 #define   SDVO_PIPE_SEL_CPT(pipe)		((pipe) << 29)
2589 
2590 /* CHV SDVO/HDMI bits: */
2591 #define   SDVO_PIPE_SEL_SHIFT_CHV		24
2592 #define   SDVO_PIPE_SEL_MASK_CHV		(3 << 24)
2593 #define   SDVO_PIPE_SEL_CHV(pipe)		((pipe) << 24)
2594 
2595 /* LVDS port control */
2596 #define LVDS			_MMIO(0x61180)
2597 /*
2598  * Enables the LVDS port.  This bit must be set before DPLLs are enabled, as
2599  * the DPLL semantics change when the LVDS is assigned to that pipe.
2600  */
2601 #define   LVDS_PORT_EN			(1 << 31)
2602 /* Selects pipe B for LVDS data.  Must be set on pre-965. */
2603 #define   LVDS_PIPE_SEL_SHIFT		30
2604 #define   LVDS_PIPE_SEL_MASK		(1 << 30)
2605 #define   LVDS_PIPE_SEL(pipe)		((pipe) << 30)
2606 #define   LVDS_PIPE_SEL_SHIFT_CPT	29
2607 #define   LVDS_PIPE_SEL_MASK_CPT	(3 << 29)
2608 #define   LVDS_PIPE_SEL_CPT(pipe)	((pipe) << 29)
2609 /* LVDS dithering flag on 965/g4x platform */
2610 #define   LVDS_ENABLE_DITHER		(1 << 25)
2611 /* LVDS sync polarity flags. Set to invert (i.e. negative) */
2612 #define   LVDS_VSYNC_POLARITY		(1 << 21)
2613 #define   LVDS_HSYNC_POLARITY		(1 << 20)
2614 
2615 /* Enable border for unscaled (or aspect-scaled) display */
2616 #define   LVDS_BORDER_ENABLE		(1 << 15)
2617 /*
2618  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
2619  * pixel.
2620  */
2621 #define   LVDS_A0A2_CLKA_POWER_MASK	(3 << 8)
2622 #define   LVDS_A0A2_CLKA_POWER_DOWN	(0 << 8)
2623 #define   LVDS_A0A2_CLKA_POWER_UP	(3 << 8)
2624 /*
2625  * Controls the A3 data pair, which contains the additional LSBs for 24 bit
2626  * mode.  Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
2627  * on.
2628  */
2629 #define   LVDS_A3_POWER_MASK		(3 << 6)
2630 #define   LVDS_A3_POWER_DOWN		(0 << 6)
2631 #define   LVDS_A3_POWER_UP		(3 << 6)
2632 /*
2633  * Controls the CLKB pair.  This should only be set when LVDS_B0B3_POWER_UP
2634  * is set.
2635  */
2636 #define   LVDS_CLKB_POWER_MASK		(3 << 4)
2637 #define   LVDS_CLKB_POWER_DOWN		(0 << 4)
2638 #define   LVDS_CLKB_POWER_UP		(3 << 4)
2639 /*
2640  * Controls the B0-B3 data pairs.  This must be set to match the DPLL p2
2641  * setting for whether we are in dual-channel mode.  The B3 pair will
2642  * additionally only be powered up when LVDS_A3_POWER_UP is set.
2643  */
2644 #define   LVDS_B0B3_POWER_MASK		(3 << 2)
2645 #define   LVDS_B0B3_POWER_DOWN		(0 << 2)
2646 #define   LVDS_B0B3_POWER_UP		(3 << 2)
2647 
2648 /* Video Data Island Packet control */
2649 #define VIDEO_DIP_DATA		_MMIO(0x61178)
2650 /* Read the description of VIDEO_DIP_DATA (before Haswell) or VIDEO_DIP_ECC
2651  * (Haswell and newer) to see which VIDEO_DIP_DATA byte corresponds to each byte
2652  * of the infoframe structure specified by CEA-861. */
2653 #define   VIDEO_DIP_DATA_SIZE	32
2654 #define   VIDEO_DIP_GMP_DATA_SIZE	36
2655 #define   VIDEO_DIP_VSC_DATA_SIZE	36
2656 #define   VIDEO_DIP_PPS_DATA_SIZE	132
2657 #define VIDEO_DIP_CTL		_MMIO(0x61170)
2658 /* Pre HSW: */
2659 #define   VIDEO_DIP_ENABLE		(1 << 31)
2660 #define   VIDEO_DIP_PORT(port)		((port) << 29)
2661 #define   VIDEO_DIP_PORT_MASK		(3 << 29)
2662 #define   VIDEO_DIP_ENABLE_GCP		(1 << 25) /* ilk+ */
2663 #define   VIDEO_DIP_ENABLE_AVI		(1 << 21)
2664 #define   VIDEO_DIP_ENABLE_VENDOR	(2 << 21)
2665 #define   VIDEO_DIP_ENABLE_GAMUT	(4 << 21) /* ilk+ */
2666 #define   VIDEO_DIP_ENABLE_SPD		(8 << 21)
2667 #define   VIDEO_DIP_SELECT_AVI		(0 << 19)
2668 #define   VIDEO_DIP_SELECT_VENDOR	(1 << 19)
2669 #define   VIDEO_DIP_SELECT_GAMUT	(2 << 19)
2670 #define   VIDEO_DIP_SELECT_SPD		(3 << 19)
2671 #define   VIDEO_DIP_SELECT_MASK		(3 << 19)
2672 #define   VIDEO_DIP_FREQ_ONCE		(0 << 16)
2673 #define   VIDEO_DIP_FREQ_VSYNC		(1 << 16)
2674 #define   VIDEO_DIP_FREQ_2VSYNC		(2 << 16)
2675 #define   VIDEO_DIP_FREQ_MASK		(3 << 16)
2676 /* HSW and later: */
2677 #define   VIDEO_DIP_ENABLE_DRM_GLK	(1 << 28)
2678 #define   PSR_VSC_BIT_7_SET		(1 << 27)
2679 #define   VSC_SELECT_MASK		(0x3 << 25)
2680 #define   VSC_SELECT_SHIFT		25
2681 #define   VSC_DIP_HW_HEA_DATA		(0 << 25)
2682 #define   VSC_DIP_HW_HEA_SW_DATA	(1 << 25)
2683 #define   VSC_DIP_HW_DATA_SW_HEA	(2 << 25)
2684 #define   VSC_DIP_SW_HEA_DATA		(3 << 25)
2685 #define   VDIP_ENABLE_PPS		(1 << 24)
2686 #define   VIDEO_DIP_ENABLE_VSC_HSW	(1 << 20)
2687 #define   VIDEO_DIP_ENABLE_GCP_HSW	(1 << 16)
2688 #define   VIDEO_DIP_ENABLE_AVI_HSW	(1 << 12)
2689 #define   VIDEO_DIP_ENABLE_VS_HSW	(1 << 8)
2690 #define   VIDEO_DIP_ENABLE_GMP_HSW	(1 << 4)
2691 #define   VIDEO_DIP_ENABLE_SPD_HSW	(1 << 0)
2692 
2693 /* Panel power sequencing */
2694 #define PPS_BASE			0x61200
2695 #define VLV_PPS_BASE			(VLV_DISPLAY_BASE + PPS_BASE)
2696 #define PCH_PPS_BASE			0xC7200
2697 
2698 #define _MMIO_PPS(pps_idx, reg)		_MMIO(dev_priv->display.pps.mmio_base -	\
2699 					      PPS_BASE + (reg) +	\
2700 					      (pps_idx) * 0x100)
2701 
2702 #define _PP_STATUS			0x61200
2703 #define PP_STATUS(pps_idx)		_MMIO_PPS(pps_idx, _PP_STATUS)
2704 #define   PP_ON				REG_BIT(31)
2705 /*
2706  * Indicates that all dependencies of the panel are on:
2707  *
2708  * - PLL enabled
2709  * - pipe enabled
2710  * - LVDS/DVOB/DVOC on
2711  */
2712 #define   PP_READY			REG_BIT(30)
2713 #define   PP_SEQUENCE_MASK		REG_GENMASK(29, 28)
2714 #define   PP_SEQUENCE_NONE		REG_FIELD_PREP(PP_SEQUENCE_MASK, 0)
2715 #define   PP_SEQUENCE_POWER_UP		REG_FIELD_PREP(PP_SEQUENCE_MASK, 1)
2716 #define   PP_SEQUENCE_POWER_DOWN	REG_FIELD_PREP(PP_SEQUENCE_MASK, 2)
2717 #define   PP_CYCLE_DELAY_ACTIVE		REG_BIT(27)
2718 #define   PP_SEQUENCE_STATE_MASK	REG_GENMASK(3, 0)
2719 #define   PP_SEQUENCE_STATE_OFF_IDLE	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x0)
2720 #define   PP_SEQUENCE_STATE_OFF_S0_1	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x1)
2721 #define   PP_SEQUENCE_STATE_OFF_S0_2	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x2)
2722 #define   PP_SEQUENCE_STATE_OFF_S0_3	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x3)
2723 #define   PP_SEQUENCE_STATE_ON_IDLE	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x8)
2724 #define   PP_SEQUENCE_STATE_ON_S1_1	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x9)
2725 #define   PP_SEQUENCE_STATE_ON_S1_2	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xa)
2726 #define   PP_SEQUENCE_STATE_ON_S1_3	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xb)
2727 #define   PP_SEQUENCE_STATE_RESET	REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xf)
2728 
2729 #define _PP_CONTROL			0x61204
2730 #define PP_CONTROL(pps_idx)		_MMIO_PPS(pps_idx, _PP_CONTROL)
2731 #define  PANEL_UNLOCK_MASK		REG_GENMASK(31, 16)
2732 #define  PANEL_UNLOCK_REGS		REG_FIELD_PREP(PANEL_UNLOCK_MASK, 0xabcd)
2733 #define  BXT_POWER_CYCLE_DELAY_MASK	REG_GENMASK(8, 4)
2734 #define  EDP_FORCE_VDD			REG_BIT(3)
2735 #define  EDP_BLC_ENABLE			REG_BIT(2)
2736 #define  PANEL_POWER_RESET		REG_BIT(1)
2737 #define  PANEL_POWER_ON			REG_BIT(0)
2738 
2739 #define _PP_ON_DELAYS			0x61208
2740 #define PP_ON_DELAYS(pps_idx)		_MMIO_PPS(pps_idx, _PP_ON_DELAYS)
2741 #define  PANEL_PORT_SELECT_MASK		REG_GENMASK(31, 30)
2742 #define  PANEL_PORT_SELECT_LVDS		REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 0)
2743 #define  PANEL_PORT_SELECT_DPA		REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 1)
2744 #define  PANEL_PORT_SELECT_DPC		REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 2)
2745 #define  PANEL_PORT_SELECT_DPD		REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 3)
2746 #define  PANEL_PORT_SELECT_VLV(port)	REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, port)
2747 #define  PANEL_POWER_UP_DELAY_MASK	REG_GENMASK(28, 16)
2748 #define  PANEL_LIGHT_ON_DELAY_MASK	REG_GENMASK(12, 0)
2749 
2750 #define _PP_OFF_DELAYS			0x6120C
2751 #define PP_OFF_DELAYS(pps_idx)		_MMIO_PPS(pps_idx, _PP_OFF_DELAYS)
2752 #define  PANEL_POWER_DOWN_DELAY_MASK	REG_GENMASK(28, 16)
2753 #define  PANEL_LIGHT_OFF_DELAY_MASK	REG_GENMASK(12, 0)
2754 
2755 #define _PP_DIVISOR			0x61210
2756 #define PP_DIVISOR(pps_idx)		_MMIO_PPS(pps_idx, _PP_DIVISOR)
2757 #define  PP_REFERENCE_DIVIDER_MASK	REG_GENMASK(31, 8)
2758 #define  PANEL_POWER_CYCLE_DELAY_MASK	REG_GENMASK(4, 0)
2759 
2760 /* Panel fitting */
2761 #define PFIT_CONTROL	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61230)
2762 #define   PFIT_ENABLE		(1 << 31)
2763 #define   PFIT_PIPE_MASK	(3 << 29)
2764 #define   PFIT_PIPE_SHIFT	29
2765 #define   PFIT_PIPE(pipe)	((pipe) << 29)
2766 #define   VERT_INTERP_DISABLE	(0 << 10)
2767 #define   VERT_INTERP_BILINEAR	(1 << 10)
2768 #define   VERT_INTERP_MASK	(3 << 10)
2769 #define   VERT_AUTO_SCALE	(1 << 9)
2770 #define   HORIZ_INTERP_DISABLE	(0 << 6)
2771 #define   HORIZ_INTERP_BILINEAR	(1 << 6)
2772 #define   HORIZ_INTERP_MASK	(3 << 6)
2773 #define   HORIZ_AUTO_SCALE	(1 << 5)
2774 #define   PANEL_8TO6_DITHER_ENABLE (1 << 3)
2775 #define   PFIT_FILTER_FUZZY	(0 << 24)
2776 #define   PFIT_SCALING_AUTO	(0 << 26)
2777 #define   PFIT_SCALING_PROGRAMMED (1 << 26)
2778 #define   PFIT_SCALING_PILLAR	(2 << 26)
2779 #define   PFIT_SCALING_LETTER	(3 << 26)
2780 #define PFIT_PGM_RATIOS _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61234)
2781 /* Pre-965 */
2782 #define		PFIT_VERT_SCALE_SHIFT		20
2783 #define		PFIT_VERT_SCALE_MASK		0xfff00000
2784 #define		PFIT_HORIZ_SCALE_SHIFT		4
2785 #define		PFIT_HORIZ_SCALE_MASK		0x0000fff0
2786 /* 965+ */
2787 #define		PFIT_VERT_SCALE_SHIFT_965	16
2788 #define		PFIT_VERT_SCALE_MASK_965	0x1fff0000
2789 #define		PFIT_HORIZ_SCALE_SHIFT_965	0
2790 #define		PFIT_HORIZ_SCALE_MASK_965	0x00001fff
2791 
2792 #define PFIT_AUTO_RATIOS _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61238)
2793 
2794 #define PCH_GTC_CTL		_MMIO(0xe7000)
2795 #define   PCH_GTC_ENABLE	(1 << 31)
2796 
2797 /* TV port control */
2798 #define TV_CTL			_MMIO(0x68000)
2799 /* Enables the TV encoder */
2800 # define TV_ENC_ENABLE			(1 << 31)
2801 /* Sources the TV encoder input from pipe B instead of A. */
2802 # define TV_ENC_PIPE_SEL_SHIFT		30
2803 # define TV_ENC_PIPE_SEL_MASK		(1 << 30)
2804 # define TV_ENC_PIPE_SEL(pipe)		((pipe) << 30)
2805 /* Outputs composite video (DAC A only) */
2806 # define TV_ENC_OUTPUT_COMPOSITE	(0 << 28)
2807 /* Outputs SVideo video (DAC B/C) */
2808 # define TV_ENC_OUTPUT_SVIDEO		(1 << 28)
2809 /* Outputs Component video (DAC A/B/C) */
2810 # define TV_ENC_OUTPUT_COMPONENT	(2 << 28)
2811 /* Outputs Composite and SVideo (DAC A/B/C) */
2812 # define TV_ENC_OUTPUT_SVIDEO_COMPOSITE	(3 << 28)
2813 # define TV_TRILEVEL_SYNC		(1 << 21)
2814 /* Enables slow sync generation (945GM only) */
2815 # define TV_SLOW_SYNC			(1 << 20)
2816 /* Selects 4x oversampling for 480i and 576p */
2817 # define TV_OVERSAMPLE_4X		(0 << 18)
2818 /* Selects 2x oversampling for 720p and 1080i */
2819 # define TV_OVERSAMPLE_2X		(1 << 18)
2820 /* Selects no oversampling for 1080p */
2821 # define TV_OVERSAMPLE_NONE		(2 << 18)
2822 /* Selects 8x oversampling */
2823 # define TV_OVERSAMPLE_8X		(3 << 18)
2824 # define TV_OVERSAMPLE_MASK		(3 << 18)
2825 /* Selects progressive mode rather than interlaced */
2826 # define TV_PROGRESSIVE			(1 << 17)
2827 /* Sets the colorburst to PAL mode.  Required for non-M PAL modes. */
2828 # define TV_PAL_BURST			(1 << 16)
2829 /* Field for setting delay of Y compared to C */
2830 # define TV_YC_SKEW_MASK		(7 << 12)
2831 /* Enables a fix for 480p/576p standard definition modes on the 915GM only */
2832 # define TV_ENC_SDP_FIX			(1 << 11)
2833 /*
2834  * Enables a fix for the 915GM only.
2835  *
2836  * Not sure what it does.
2837  */
2838 # define TV_ENC_C0_FIX			(1 << 10)
2839 /* Bits that must be preserved by software */
2840 # define TV_CTL_SAVE			((1 << 11) | (3 << 9) | (7 << 6) | 0xf)
2841 # define TV_FUSE_STATE_MASK		(3 << 4)
2842 /* Read-only state that reports all features enabled */
2843 # define TV_FUSE_STATE_ENABLED		(0 << 4)
2844 /* Read-only state that reports that Macrovision is disabled in hardware*/
2845 # define TV_FUSE_STATE_NO_MACROVISION	(1 << 4)
2846 /* Read-only state that reports that TV-out is disabled in hardware. */
2847 # define TV_FUSE_STATE_DISABLED		(2 << 4)
2848 /* Normal operation */
2849 # define TV_TEST_MODE_NORMAL		(0 << 0)
2850 /* Encoder test pattern 1 - combo pattern */
2851 # define TV_TEST_MODE_PATTERN_1		(1 << 0)
2852 /* Encoder test pattern 2 - full screen vertical 75% color bars */
2853 # define TV_TEST_MODE_PATTERN_2		(2 << 0)
2854 /* Encoder test pattern 3 - full screen horizontal 75% color bars */
2855 # define TV_TEST_MODE_PATTERN_3		(3 << 0)
2856 /* Encoder test pattern 4 - random noise */
2857 # define TV_TEST_MODE_PATTERN_4		(4 << 0)
2858 /* Encoder test pattern 5 - linear color ramps */
2859 # define TV_TEST_MODE_PATTERN_5		(5 << 0)
2860 /*
2861  * This test mode forces the DACs to 50% of full output.
2862  *
2863  * This is used for load detection in combination with TVDAC_SENSE_MASK
2864  */
2865 # define TV_TEST_MODE_MONITOR_DETECT	(7 << 0)
2866 # define TV_TEST_MODE_MASK		(7 << 0)
2867 
2868 #define TV_DAC			_MMIO(0x68004)
2869 # define TV_DAC_SAVE		0x00ffff00
2870 /*
2871  * Reports that DAC state change logic has reported change (RO).
2872  *
2873  * This gets cleared when TV_DAC_STATE_EN is cleared
2874 */
2875 # define TVDAC_STATE_CHG		(1 << 31)
2876 # define TVDAC_SENSE_MASK		(7 << 28)
2877 /* Reports that DAC A voltage is above the detect threshold */
2878 # define TVDAC_A_SENSE			(1 << 30)
2879 /* Reports that DAC B voltage is above the detect threshold */
2880 # define TVDAC_B_SENSE			(1 << 29)
2881 /* Reports that DAC C voltage is above the detect threshold */
2882 # define TVDAC_C_SENSE			(1 << 28)
2883 /*
2884  * Enables DAC state detection logic, for load-based TV detection.
2885  *
2886  * The PLL of the chosen pipe (in TV_CTL) must be running, and the encoder set
2887  * to off, for load detection to work.
2888  */
2889 # define TVDAC_STATE_CHG_EN		(1 << 27)
2890 /* Sets the DAC A sense value to high */
2891 # define TVDAC_A_SENSE_CTL		(1 << 26)
2892 /* Sets the DAC B sense value to high */
2893 # define TVDAC_B_SENSE_CTL		(1 << 25)
2894 /* Sets the DAC C sense value to high */
2895 # define TVDAC_C_SENSE_CTL		(1 << 24)
2896 /* Overrides the ENC_ENABLE and DAC voltage levels */
2897 # define DAC_CTL_OVERRIDE		(1 << 7)
2898 /* Sets the slew rate.  Must be preserved in software */
2899 # define ENC_TVDAC_SLEW_FAST		(1 << 6)
2900 # define DAC_A_1_3_V			(0 << 4)
2901 # define DAC_A_1_1_V			(1 << 4)
2902 # define DAC_A_0_7_V			(2 << 4)
2903 # define DAC_A_MASK			(3 << 4)
2904 # define DAC_B_1_3_V			(0 << 2)
2905 # define DAC_B_1_1_V			(1 << 2)
2906 # define DAC_B_0_7_V			(2 << 2)
2907 # define DAC_B_MASK			(3 << 2)
2908 # define DAC_C_1_3_V			(0 << 0)
2909 # define DAC_C_1_1_V			(1 << 0)
2910 # define DAC_C_0_7_V			(2 << 0)
2911 # define DAC_C_MASK			(3 << 0)
2912 
2913 /*
2914  * CSC coefficients are stored in a floating point format with 9 bits of
2915  * mantissa and 2 or 3 bits of exponent.  The exponent is represented as 2**-n,
2916  * where 2-bit exponents are unsigned n, and 3-bit exponents are signed n with
2917  * -1 (0x3) being the only legal negative value.
2918  */
2919 #define TV_CSC_Y		_MMIO(0x68010)
2920 # define TV_RY_MASK			0x07ff0000
2921 # define TV_RY_SHIFT			16
2922 # define TV_GY_MASK			0x00000fff
2923 # define TV_GY_SHIFT			0
2924 
2925 #define TV_CSC_Y2		_MMIO(0x68014)
2926 # define TV_BY_MASK			0x07ff0000
2927 # define TV_BY_SHIFT			16
2928 /*
2929  * Y attenuation for component video.
2930  *
2931  * Stored in 1.9 fixed point.
2932  */
2933 # define TV_AY_MASK			0x000003ff
2934 # define TV_AY_SHIFT			0
2935 
2936 #define TV_CSC_U		_MMIO(0x68018)
2937 # define TV_RU_MASK			0x07ff0000
2938 # define TV_RU_SHIFT			16
2939 # define TV_GU_MASK			0x000007ff
2940 # define TV_GU_SHIFT			0
2941 
2942 #define TV_CSC_U2		_MMIO(0x6801c)
2943 # define TV_BU_MASK			0x07ff0000
2944 # define TV_BU_SHIFT			16
2945 /*
2946  * U attenuation for component video.
2947  *
2948  * Stored in 1.9 fixed point.
2949  */
2950 # define TV_AU_MASK			0x000003ff
2951 # define TV_AU_SHIFT			0
2952 
2953 #define TV_CSC_V		_MMIO(0x68020)
2954 # define TV_RV_MASK			0x0fff0000
2955 # define TV_RV_SHIFT			16
2956 # define TV_GV_MASK			0x000007ff
2957 # define TV_GV_SHIFT			0
2958 
2959 #define TV_CSC_V2		_MMIO(0x68024)
2960 # define TV_BV_MASK			0x07ff0000
2961 # define TV_BV_SHIFT			16
2962 /*
2963  * V attenuation for component video.
2964  *
2965  * Stored in 1.9 fixed point.
2966  */
2967 # define TV_AV_MASK			0x000007ff
2968 # define TV_AV_SHIFT			0
2969 
2970 #define TV_CLR_KNOBS		_MMIO(0x68028)
2971 /* 2s-complement brightness adjustment */
2972 # define TV_BRIGHTNESS_MASK		0xff000000
2973 # define TV_BRIGHTNESS_SHIFT		24
2974 /* Contrast adjustment, as a 2.6 unsigned floating point number */
2975 # define TV_CONTRAST_MASK		0x00ff0000
2976 # define TV_CONTRAST_SHIFT		16
2977 /* Saturation adjustment, as a 2.6 unsigned floating point number */
2978 # define TV_SATURATION_MASK		0x0000ff00
2979 # define TV_SATURATION_SHIFT		8
2980 /* Hue adjustment, as an integer phase angle in degrees */
2981 # define TV_HUE_MASK			0x000000ff
2982 # define TV_HUE_SHIFT			0
2983 
2984 #define TV_CLR_LEVEL		_MMIO(0x6802c)
2985 /* Controls the DAC level for black */
2986 # define TV_BLACK_LEVEL_MASK		0x01ff0000
2987 # define TV_BLACK_LEVEL_SHIFT		16
2988 /* Controls the DAC level for blanking */
2989 # define TV_BLANK_LEVEL_MASK		0x000001ff
2990 # define TV_BLANK_LEVEL_SHIFT		0
2991 
2992 #define TV_H_CTL_1		_MMIO(0x68030)
2993 /* Number of pixels in the hsync. */
2994 # define TV_HSYNC_END_MASK		0x1fff0000
2995 # define TV_HSYNC_END_SHIFT		16
2996 /* Total number of pixels minus one in the line (display and blanking). */
2997 # define TV_HTOTAL_MASK			0x00001fff
2998 # define TV_HTOTAL_SHIFT		0
2999 
3000 #define TV_H_CTL_2		_MMIO(0x68034)
3001 /* Enables the colorburst (needed for non-component color) */
3002 # define TV_BURST_ENA			(1 << 31)
3003 /* Offset of the colorburst from the start of hsync, in pixels minus one. */
3004 # define TV_HBURST_START_SHIFT		16
3005 # define TV_HBURST_START_MASK		0x1fff0000
3006 /* Length of the colorburst */
3007 # define TV_HBURST_LEN_SHIFT		0
3008 # define TV_HBURST_LEN_MASK		0x0001fff
3009 
3010 #define TV_H_CTL_3		_MMIO(0x68038)
3011 /* End of hblank, measured in pixels minus one from start of hsync */
3012 # define TV_HBLANK_END_SHIFT		16
3013 # define TV_HBLANK_END_MASK		0x1fff0000
3014 /* Start of hblank, measured in pixels minus one from start of hsync */
3015 # define TV_HBLANK_START_SHIFT		0
3016 # define TV_HBLANK_START_MASK		0x0001fff
3017 
3018 #define TV_V_CTL_1		_MMIO(0x6803c)
3019 /* XXX */
3020 # define TV_NBR_END_SHIFT		16
3021 # define TV_NBR_END_MASK		0x07ff0000
3022 /* XXX */
3023 # define TV_VI_END_F1_SHIFT		8
3024 # define TV_VI_END_F1_MASK		0x00003f00
3025 /* XXX */
3026 # define TV_VI_END_F2_SHIFT		0
3027 # define TV_VI_END_F2_MASK		0x0000003f
3028 
3029 #define TV_V_CTL_2		_MMIO(0x68040)
3030 /* Length of vsync, in half lines */
3031 # define TV_VSYNC_LEN_MASK		0x07ff0000
3032 # define TV_VSYNC_LEN_SHIFT		16
3033 /* Offset of the start of vsync in field 1, measured in one less than the
3034  * number of half lines.
3035  */
3036 # define TV_VSYNC_START_F1_MASK		0x00007f00
3037 # define TV_VSYNC_START_F1_SHIFT	8
3038 /*
3039  * Offset of the start of vsync in field 2, measured in one less than the
3040  * number of half lines.
3041  */
3042 # define TV_VSYNC_START_F2_MASK		0x0000007f
3043 # define TV_VSYNC_START_F2_SHIFT	0
3044 
3045 #define TV_V_CTL_3		_MMIO(0x68044)
3046 /* Enables generation of the equalization signal */
3047 # define TV_EQUAL_ENA			(1 << 31)
3048 /* Length of vsync, in half lines */
3049 # define TV_VEQ_LEN_MASK		0x007f0000
3050 # define TV_VEQ_LEN_SHIFT		16
3051 /* Offset of the start of equalization in field 1, measured in one less than
3052  * the number of half lines.
3053  */
3054 # define TV_VEQ_START_F1_MASK		0x0007f00
3055 # define TV_VEQ_START_F1_SHIFT		8
3056 /*
3057  * Offset of the start of equalization in field 2, measured in one less than
3058  * the number of half lines.
3059  */
3060 # define TV_VEQ_START_F2_MASK		0x000007f
3061 # define TV_VEQ_START_F2_SHIFT		0
3062 
3063 #define TV_V_CTL_4		_MMIO(0x68048)
3064 /*
3065  * Offset to start of vertical colorburst, measured in one less than the
3066  * number of lines from vertical start.
3067  */
3068 # define TV_VBURST_START_F1_MASK	0x003f0000
3069 # define TV_VBURST_START_F1_SHIFT	16
3070 /*
3071  * Offset to the end of vertical colorburst, measured in one less than the
3072  * number of lines from the start of NBR.
3073  */
3074 # define TV_VBURST_END_F1_MASK		0x000000ff
3075 # define TV_VBURST_END_F1_SHIFT		0
3076 
3077 #define TV_V_CTL_5		_MMIO(0x6804c)
3078 /*
3079  * Offset to start of vertical colorburst, measured in one less than the
3080  * number of lines from vertical start.
3081  */
3082 # define TV_VBURST_START_F2_MASK	0x003f0000
3083 # define TV_VBURST_START_F2_SHIFT	16
3084 /*
3085  * Offset to the end of vertical colorburst, measured in one less than the
3086  * number of lines from the start of NBR.
3087  */
3088 # define TV_VBURST_END_F2_MASK		0x000000ff
3089 # define TV_VBURST_END_F2_SHIFT		0
3090 
3091 #define TV_V_CTL_6		_MMIO(0x68050)
3092 /*
3093  * Offset to start of vertical colorburst, measured in one less than the
3094  * number of lines from vertical start.
3095  */
3096 # define TV_VBURST_START_F3_MASK	0x003f0000
3097 # define TV_VBURST_START_F3_SHIFT	16
3098 /*
3099  * Offset to the end of vertical colorburst, measured in one less than the
3100  * number of lines from the start of NBR.
3101  */
3102 # define TV_VBURST_END_F3_MASK		0x000000ff
3103 # define TV_VBURST_END_F3_SHIFT		0
3104 
3105 #define TV_V_CTL_7		_MMIO(0x68054)
3106 /*
3107  * Offset to start of vertical colorburst, measured in one less than the
3108  * number of lines from vertical start.
3109  */
3110 # define TV_VBURST_START_F4_MASK	0x003f0000
3111 # define TV_VBURST_START_F4_SHIFT	16
3112 /*
3113  * Offset to the end of vertical colorburst, measured in one less than the
3114  * number of lines from the start of NBR.
3115  */
3116 # define TV_VBURST_END_F4_MASK		0x000000ff
3117 # define TV_VBURST_END_F4_SHIFT		0
3118 
3119 #define TV_SC_CTL_1		_MMIO(0x68060)
3120 /* Turns on the first subcarrier phase generation DDA */
3121 # define TV_SC_DDA1_EN			(1 << 31)
3122 /* Turns on the first subcarrier phase generation DDA */
3123 # define TV_SC_DDA2_EN			(1 << 30)
3124 /* Turns on the first subcarrier phase generation DDA */
3125 # define TV_SC_DDA3_EN			(1 << 29)
3126 /* Sets the subcarrier DDA to reset frequency every other field */
3127 # define TV_SC_RESET_EVERY_2		(0 << 24)
3128 /* Sets the subcarrier DDA to reset frequency every fourth field */
3129 # define TV_SC_RESET_EVERY_4		(1 << 24)
3130 /* Sets the subcarrier DDA to reset frequency every eighth field */
3131 # define TV_SC_RESET_EVERY_8		(2 << 24)
3132 /* Sets the subcarrier DDA to never reset the frequency */
3133 # define TV_SC_RESET_NEVER		(3 << 24)
3134 /* Sets the peak amplitude of the colorburst.*/
3135 # define TV_BURST_LEVEL_MASK		0x00ff0000
3136 # define TV_BURST_LEVEL_SHIFT		16
3137 /* Sets the increment of the first subcarrier phase generation DDA */
3138 # define TV_SCDDA1_INC_MASK		0x00000fff
3139 # define TV_SCDDA1_INC_SHIFT		0
3140 
3141 #define TV_SC_CTL_2		_MMIO(0x68064)
3142 /* Sets the rollover for the second subcarrier phase generation DDA */
3143 # define TV_SCDDA2_SIZE_MASK		0x7fff0000
3144 # define TV_SCDDA2_SIZE_SHIFT		16
3145 /* Sets the increent of the second subcarrier phase generation DDA */
3146 # define TV_SCDDA2_INC_MASK		0x00007fff
3147 # define TV_SCDDA2_INC_SHIFT		0
3148 
3149 #define TV_SC_CTL_3		_MMIO(0x68068)
3150 /* Sets the rollover for the third subcarrier phase generation DDA */
3151 # define TV_SCDDA3_SIZE_MASK		0x7fff0000
3152 # define TV_SCDDA3_SIZE_SHIFT		16
3153 /* Sets the increent of the third subcarrier phase generation DDA */
3154 # define TV_SCDDA3_INC_MASK		0x00007fff
3155 # define TV_SCDDA3_INC_SHIFT		0
3156 
3157 #define TV_WIN_POS		_MMIO(0x68070)
3158 /* X coordinate of the display from the start of horizontal active */
3159 # define TV_XPOS_MASK			0x1fff0000
3160 # define TV_XPOS_SHIFT			16
3161 /* Y coordinate of the display from the start of vertical active (NBR) */
3162 # define TV_YPOS_MASK			0x00000fff
3163 # define TV_YPOS_SHIFT			0
3164 
3165 #define TV_WIN_SIZE		_MMIO(0x68074)
3166 /* Horizontal size of the display window, measured in pixels*/
3167 # define TV_XSIZE_MASK			0x1fff0000
3168 # define TV_XSIZE_SHIFT			16
3169 /*
3170  * Vertical size of the display window, measured in pixels.
3171  *
3172  * Must be even for interlaced modes.
3173  */
3174 # define TV_YSIZE_MASK			0x00000fff
3175 # define TV_YSIZE_SHIFT			0
3176 
3177 #define TV_FILTER_CTL_1		_MMIO(0x68080)
3178 /*
3179  * Enables automatic scaling calculation.
3180  *
3181  * If set, the rest of the registers are ignored, and the calculated values can
3182  * be read back from the register.
3183  */
3184 # define TV_AUTO_SCALE			(1 << 31)
3185 /*
3186  * Disables the vertical filter.
3187  *
3188  * This is required on modes more than 1024 pixels wide */
3189 # define TV_V_FILTER_BYPASS		(1 << 29)
3190 /* Enables adaptive vertical filtering */
3191 # define TV_VADAPT			(1 << 28)
3192 # define TV_VADAPT_MODE_MASK		(3 << 26)
3193 /* Selects the least adaptive vertical filtering mode */
3194 # define TV_VADAPT_MODE_LEAST		(0 << 26)
3195 /* Selects the moderately adaptive vertical filtering mode */
3196 # define TV_VADAPT_MODE_MODERATE	(1 << 26)
3197 /* Selects the most adaptive vertical filtering mode */
3198 # define TV_VADAPT_MODE_MOST		(3 << 26)
3199 /*
3200  * Sets the horizontal scaling factor.
3201  *
3202  * This should be the fractional part of the horizontal scaling factor divided
3203  * by the oversampling rate.  TV_HSCALE should be less than 1, and set to:
3204  *
3205  * (src width - 1) / ((oversample * dest width) - 1)
3206  */
3207 # define TV_HSCALE_FRAC_MASK		0x00003fff
3208 # define TV_HSCALE_FRAC_SHIFT		0
3209 
3210 #define TV_FILTER_CTL_2		_MMIO(0x68084)
3211 /*
3212  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
3213  *
3214  * TV_VSCALE should be (src height - 1) / ((interlace * dest height) - 1)
3215  */
3216 # define TV_VSCALE_INT_MASK		0x00038000
3217 # define TV_VSCALE_INT_SHIFT		15
3218 /*
3219  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
3220  *
3221  * \sa TV_VSCALE_INT_MASK
3222  */
3223 # define TV_VSCALE_FRAC_MASK		0x00007fff
3224 # define TV_VSCALE_FRAC_SHIFT		0
3225 
3226 #define TV_FILTER_CTL_3		_MMIO(0x68088)
3227 /*
3228  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
3229  *
3230  * TV_VSCALE should be (src height - 1) / (1/4 * (dest height - 1))
3231  *
3232  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
3233  */
3234 # define TV_VSCALE_IP_INT_MASK		0x00038000
3235 # define TV_VSCALE_IP_INT_SHIFT		15
3236 /*
3237  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
3238  *
3239  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
3240  *
3241  * \sa TV_VSCALE_IP_INT_MASK
3242  */
3243 # define TV_VSCALE_IP_FRAC_MASK		0x00007fff
3244 # define TV_VSCALE_IP_FRAC_SHIFT		0
3245 
3246 #define TV_CC_CONTROL		_MMIO(0x68090)
3247 # define TV_CC_ENABLE			(1 << 31)
3248 /*
3249  * Specifies which field to send the CC data in.
3250  *
3251  * CC data is usually sent in field 0.
3252  */
3253 # define TV_CC_FID_MASK			(1 << 27)
3254 # define TV_CC_FID_SHIFT		27
3255 /* Sets the horizontal position of the CC data.  Usually 135. */
3256 # define TV_CC_HOFF_MASK		0x03ff0000
3257 # define TV_CC_HOFF_SHIFT		16
3258 /* Sets the vertical position of the CC data.  Usually 21 */
3259 # define TV_CC_LINE_MASK		0x0000003f
3260 # define TV_CC_LINE_SHIFT		0
3261 
3262 #define TV_CC_DATA		_MMIO(0x68094)
3263 # define TV_CC_RDY			(1 << 31)
3264 /* Second word of CC data to be transmitted. */
3265 # define TV_CC_DATA_2_MASK		0x007f0000
3266 # define TV_CC_DATA_2_SHIFT		16
3267 /* First word of CC data to be transmitted. */
3268 # define TV_CC_DATA_1_MASK		0x0000007f
3269 # define TV_CC_DATA_1_SHIFT		0
3270 
3271 #define TV_H_LUMA(i)		_MMIO(0x68100 + (i) * 4) /* 60 registers */
3272 #define TV_H_CHROMA(i)		_MMIO(0x68200 + (i) * 4) /* 60 registers */
3273 #define TV_V_LUMA(i)		_MMIO(0x68300 + (i) * 4) /* 43 registers */
3274 #define TV_V_CHROMA(i)		_MMIO(0x68400 + (i) * 4) /* 43 registers */
3275 
3276 /* Display Port */
3277 #define DP_A			_MMIO(0x64000) /* eDP */
3278 #define DP_B			_MMIO(0x64100)
3279 #define DP_C			_MMIO(0x64200)
3280 #define DP_D			_MMIO(0x64300)
3281 
3282 #define VLV_DP_B		_MMIO(VLV_DISPLAY_BASE + 0x64100)
3283 #define VLV_DP_C		_MMIO(VLV_DISPLAY_BASE + 0x64200)
3284 #define CHV_DP_D		_MMIO(VLV_DISPLAY_BASE + 0x64300)
3285 
3286 #define   DP_PORT_EN			(1 << 31)
3287 #define   DP_PIPE_SEL_SHIFT		30
3288 #define   DP_PIPE_SEL_MASK		(1 << 30)
3289 #define   DP_PIPE_SEL(pipe)		((pipe) << 30)
3290 #define   DP_PIPE_SEL_SHIFT_IVB		29
3291 #define   DP_PIPE_SEL_MASK_IVB		(3 << 29)
3292 #define   DP_PIPE_SEL_IVB(pipe)		((pipe) << 29)
3293 #define   DP_PIPE_SEL_SHIFT_CHV		16
3294 #define   DP_PIPE_SEL_MASK_CHV		(3 << 16)
3295 #define   DP_PIPE_SEL_CHV(pipe)		((pipe) << 16)
3296 
3297 /* Link training mode - select a suitable mode for each stage */
3298 #define   DP_LINK_TRAIN_PAT_1		(0 << 28)
3299 #define   DP_LINK_TRAIN_PAT_2		(1 << 28)
3300 #define   DP_LINK_TRAIN_PAT_IDLE	(2 << 28)
3301 #define   DP_LINK_TRAIN_OFF		(3 << 28)
3302 #define   DP_LINK_TRAIN_MASK		(3 << 28)
3303 #define   DP_LINK_TRAIN_SHIFT		28
3304 
3305 /* CPT Link training mode */
3306 #define   DP_LINK_TRAIN_PAT_1_CPT	(0 << 8)
3307 #define   DP_LINK_TRAIN_PAT_2_CPT	(1 << 8)
3308 #define   DP_LINK_TRAIN_PAT_IDLE_CPT	(2 << 8)
3309 #define   DP_LINK_TRAIN_OFF_CPT		(3 << 8)
3310 #define   DP_LINK_TRAIN_MASK_CPT	(7 << 8)
3311 #define   DP_LINK_TRAIN_SHIFT_CPT	8
3312 
3313 /* Signal voltages. These are mostly controlled by the other end */
3314 #define   DP_VOLTAGE_0_4		(0 << 25)
3315 #define   DP_VOLTAGE_0_6		(1 << 25)
3316 #define   DP_VOLTAGE_0_8		(2 << 25)
3317 #define   DP_VOLTAGE_1_2		(3 << 25)
3318 #define   DP_VOLTAGE_MASK		(7 << 25)
3319 #define   DP_VOLTAGE_SHIFT		25
3320 
3321 /* Signal pre-emphasis levels, like voltages, the other end tells us what
3322  * they want
3323  */
3324 #define   DP_PRE_EMPHASIS_0		(0 << 22)
3325 #define   DP_PRE_EMPHASIS_3_5		(1 << 22)
3326 #define   DP_PRE_EMPHASIS_6		(2 << 22)
3327 #define   DP_PRE_EMPHASIS_9_5		(3 << 22)
3328 #define   DP_PRE_EMPHASIS_MASK		(7 << 22)
3329 #define   DP_PRE_EMPHASIS_SHIFT		22
3330 
3331 /* How many wires to use. I guess 3 was too hard */
3332 #define   DP_PORT_WIDTH(width)		(((width) - 1) << 19)
3333 #define   DP_PORT_WIDTH_MASK		(7 << 19)
3334 #define   DP_PORT_WIDTH_SHIFT		19
3335 
3336 /* Mystic DPCD version 1.1 special mode */
3337 #define   DP_ENHANCED_FRAMING		(1 << 18)
3338 
3339 /* eDP */
3340 #define   DP_PLL_FREQ_270MHZ		(0 << 16)
3341 #define   DP_PLL_FREQ_162MHZ		(1 << 16)
3342 #define   DP_PLL_FREQ_MASK		(3 << 16)
3343 
3344 /* locked once port is enabled */
3345 #define   DP_PORT_REVERSAL		(1 << 15)
3346 
3347 /* eDP */
3348 #define   DP_PLL_ENABLE			(1 << 14)
3349 
3350 /* sends the clock on lane 15 of the PEG for debug */
3351 #define   DP_CLOCK_OUTPUT_ENABLE	(1 << 13)
3352 
3353 #define   DP_SCRAMBLING_DISABLE		(1 << 12)
3354 #define   DP_SCRAMBLING_DISABLE_IRONLAKE	(1 << 7)
3355 
3356 /* limit RGB values to avoid confusing TVs */
3357 #define   DP_COLOR_RANGE_16_235		(1 << 8)
3358 
3359 /* Turn on the audio link */
3360 #define   DP_AUDIO_OUTPUT_ENABLE	(1 << 6)
3361 
3362 /* vs and hs sync polarity */
3363 #define   DP_SYNC_VS_HIGH		(1 << 4)
3364 #define   DP_SYNC_HS_HIGH		(1 << 3)
3365 
3366 /* A fantasy */
3367 #define   DP_DETECTED			(1 << 2)
3368 
3369 /* The aux channel provides a way to talk to the
3370  * signal sink for DDC etc. Max packet size supported
3371  * is 20 bytes in each direction, hence the 5 fixed
3372  * data registers
3373  */
3374 #define _DPA_AUX_CH_CTL		(DISPLAY_MMIO_BASE(dev_priv) + 0x64010)
3375 #define _DPA_AUX_CH_DATA1	(DISPLAY_MMIO_BASE(dev_priv) + 0x64014)
3376 
3377 #define _DPB_AUX_CH_CTL		(DISPLAY_MMIO_BASE(dev_priv) + 0x64110)
3378 #define _DPB_AUX_CH_DATA1	(DISPLAY_MMIO_BASE(dev_priv) + 0x64114)
3379 
3380 #define DP_AUX_CH_CTL(aux_ch)	_MMIO_PORT(aux_ch, _DPA_AUX_CH_CTL, _DPB_AUX_CH_CTL)
3381 #define DP_AUX_CH_DATA(aux_ch, i)	_MMIO(_PORT(aux_ch, _DPA_AUX_CH_DATA1, _DPB_AUX_CH_DATA1) + (i) * 4) /* 5 registers */
3382 
3383 #define _XELPDP_USBC1_AUX_CH_CTL	0x16F210
3384 #define _XELPDP_USBC2_AUX_CH_CTL	0x16F410
3385 #define _XELPDP_USBC3_AUX_CH_CTL	0x16F610
3386 #define _XELPDP_USBC4_AUX_CH_CTL	0x16F810
3387 
3388 #define XELPDP_DP_AUX_CH_CTL(aux_ch)		_MMIO(_PICK(aux_ch, \
3389 						       _DPA_AUX_CH_CTL, \
3390 						       _DPB_AUX_CH_CTL, \
3391 						       0, /* port/aux_ch C is non-existent */ \
3392 						       _XELPDP_USBC1_AUX_CH_CTL, \
3393 						       _XELPDP_USBC2_AUX_CH_CTL, \
3394 						       _XELPDP_USBC3_AUX_CH_CTL, \
3395 						       _XELPDP_USBC4_AUX_CH_CTL))
3396 
3397 #define _XELPDP_USBC1_AUX_CH_DATA1      0x16F214
3398 #define _XELPDP_USBC2_AUX_CH_DATA1      0x16F414
3399 #define _XELPDP_USBC3_AUX_CH_DATA1      0x16F614
3400 #define _XELPDP_USBC4_AUX_CH_DATA1      0x16F814
3401 
3402 #define XELPDP_DP_AUX_CH_DATA(aux_ch, i)	_MMIO(_PICK(aux_ch, \
3403 						       _DPA_AUX_CH_DATA1, \
3404 						       _DPB_AUX_CH_DATA1, \
3405 						       0, /* port/aux_ch C is non-existent */ \
3406 						       _XELPDP_USBC1_AUX_CH_DATA1, \
3407 						       _XELPDP_USBC2_AUX_CH_DATA1, \
3408 						       _XELPDP_USBC3_AUX_CH_DATA1, \
3409 						       _XELPDP_USBC4_AUX_CH_DATA1) + (i) * 4)
3410 
3411 #define   DP_AUX_CH_CTL_SEND_BUSY	    (1 << 31)
3412 #define   DP_AUX_CH_CTL_DONE		    (1 << 30)
3413 #define   DP_AUX_CH_CTL_INTERRUPT	    (1 << 29)
3414 #define   DP_AUX_CH_CTL_TIME_OUT_ERROR	    (1 << 28)
3415 #define   DP_AUX_CH_CTL_TIME_OUT_400us	    (0 << 26)
3416 #define   DP_AUX_CH_CTL_TIME_OUT_600us	    (1 << 26)
3417 #define   DP_AUX_CH_CTL_TIME_OUT_800us	    (2 << 26)
3418 #define   DP_AUX_CH_CTL_TIME_OUT_MAX	    (3 << 26) /* Varies per platform */
3419 #define   DP_AUX_CH_CTL_TIME_OUT_MASK	    (3 << 26)
3420 #define   DP_AUX_CH_CTL_RECEIVE_ERROR	    (1 << 25)
3421 #define   DP_AUX_CH_CTL_MESSAGE_SIZE_MASK    (0x1f << 20)
3422 #define   DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT   20
3423 #define   XELPDP_DP_AUX_CH_CTL_POWER_REQUEST REG_BIT(19)
3424 #define   XELPDP_DP_AUX_CH_CTL_POWER_STATUS  REG_BIT(18)
3425 #define   DP_AUX_CH_CTL_PRECHARGE_2US_MASK   (0xf << 16)
3426 #define   DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT  16
3427 #define   DP_AUX_CH_CTL_AUX_AKSV_SELECT	    (1 << 15)
3428 #define   DP_AUX_CH_CTL_MANCHESTER_TEST	    (1 << 14)
3429 #define   DP_AUX_CH_CTL_SYNC_TEST	    (1 << 13)
3430 #define   DP_AUX_CH_CTL_DEGLITCH_TEST	    (1 << 12)
3431 #define   DP_AUX_CH_CTL_PRECHARGE_TEST	    (1 << 11)
3432 #define   DP_AUX_CH_CTL_BIT_CLOCK_2X_MASK    (0x7ff)
3433 #define   DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT   0
3434 #define   DP_AUX_CH_CTL_PSR_DATA_AUX_REG_SKL	(1 << 14)
3435 #define   DP_AUX_CH_CTL_FS_DATA_AUX_REG_SKL	(1 << 13)
3436 #define   DP_AUX_CH_CTL_GTC_DATA_AUX_REG_SKL	(1 << 12)
3437 #define   DP_AUX_CH_CTL_TBT_IO			(1 << 11)
3438 #define   DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL_MASK (0x1f << 5)
3439 #define   DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(c) (((c) - 1) << 5)
3440 #define   DP_AUX_CH_CTL_SYNC_PULSE_SKL(c)   ((c) - 1)
3441 
3442 /*
3443  * Computing GMCH M and N values for the Display Port link
3444  *
3445  * GMCH M/N = dot clock * bytes per pixel / ls_clk * # of lanes
3446  *
3447  * ls_clk (we assume) is the DP link clock (1.62 or 2.7 GHz)
3448  *
3449  * The GMCH value is used internally
3450  *
3451  * bytes_per_pixel is the number of bytes coming out of the plane,
3452  * which is after the LUTs, so we want the bytes for our color format.
3453  * For our current usage, this is always 3, one byte for R, G and B.
3454  */
3455 #define _PIPEA_DATA_M_G4X	0x70050
3456 #define _PIPEB_DATA_M_G4X	0x71050
3457 
3458 /* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */
3459 #define  TU_SIZE_MASK		REG_GENMASK(30, 25)
3460 #define  TU_SIZE(x)		REG_FIELD_PREP(TU_SIZE_MASK, (x) - 1) /* default size 64 */
3461 
3462 #define  DATA_LINK_M_N_MASK	REG_GENMASK(23, 0)
3463 #define  DATA_LINK_N_MAX	(0x800000)
3464 
3465 #define _PIPEA_DATA_N_G4X	0x70054
3466 #define _PIPEB_DATA_N_G4X	0x71054
3467 
3468 /*
3469  * Computing Link M and N values for the Display Port link
3470  *
3471  * Link M / N = pixel_clock / ls_clk
3472  *
3473  * (the DP spec calls pixel_clock the 'strm_clk')
3474  *
3475  * The Link value is transmitted in the Main Stream
3476  * Attributes and VB-ID.
3477  */
3478 
3479 #define _PIPEA_LINK_M_G4X	0x70060
3480 #define _PIPEB_LINK_M_G4X	0x71060
3481 #define _PIPEA_LINK_N_G4X	0x70064
3482 #define _PIPEB_LINK_N_G4X	0x71064
3483 
3484 #define PIPE_DATA_M_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_DATA_M_G4X, _PIPEB_DATA_M_G4X)
3485 #define PIPE_DATA_N_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_DATA_N_G4X, _PIPEB_DATA_N_G4X)
3486 #define PIPE_LINK_M_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_LINK_M_G4X, _PIPEB_LINK_M_G4X)
3487 #define PIPE_LINK_N_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_LINK_N_G4X, _PIPEB_LINK_N_G4X)
3488 
3489 /* Display & cursor control */
3490 
3491 /* Pipe A */
3492 #define _PIPEADSL		0x70000
3493 #define   PIPEDSL_CURR_FIELD	REG_BIT(31) /* ctg+ */
3494 #define   PIPEDSL_LINE_MASK	REG_GENMASK(19, 0)
3495 #define _PIPEACONF		0x70008
3496 #define   PIPECONF_ENABLE			REG_BIT(31)
3497 #define   PIPECONF_DOUBLE_WIDE			REG_BIT(30) /* pre-i965 */
3498 #define   PIPECONF_STATE_ENABLE			REG_BIT(30) /* i965+ */
3499 #define   PIPECONF_DSI_PLL_LOCKED		REG_BIT(29) /* vlv & pipe A only */
3500 #define   PIPECONF_FRAME_START_DELAY_MASK	REG_GENMASK(28, 27) /* pre-hsw */
3501 #define   PIPECONF_FRAME_START_DELAY(x)		REG_FIELD_PREP(PIPECONF_FRAME_START_DELAY_MASK, (x)) /* pre-hsw: 0-3 */
3502 #define   PIPECONF_PIPE_LOCKED			REG_BIT(25)
3503 #define   PIPECONF_FORCE_BORDER			REG_BIT(25)
3504 #define   PIPECONF_GAMMA_MODE_MASK_I9XX		REG_BIT(24) /* gmch */
3505 #define   PIPECONF_GAMMA_MODE_MASK_ILK		REG_GENMASK(25, 24) /* ilk-ivb */
3506 #define   PIPECONF_GAMMA_MODE_8BIT		REG_FIELD_PREP(PIPECONF_GAMMA_MODE_MASK, 0)
3507 #define   PIPECONF_GAMMA_MODE_10BIT		REG_FIELD_PREP(PIPECONF_GAMMA_MODE_MASK, 1)
3508 #define   PIPECONF_GAMMA_MODE_12BIT		REG_FIELD_PREP(PIPECONF_GAMMA_MODE_MASK_ILK, 2) /* ilk-ivb */
3509 #define   PIPECONF_GAMMA_MODE_SPLIT		REG_FIELD_PREP(PIPECONF_GAMMA_MODE_MASK_ILK, 3) /* ivb */
3510 #define   PIPECONF_GAMMA_MODE(x)		REG_FIELD_PREP(PIPECONF_GAMMA_MODE_MASK_ILK, (x)) /* pass in GAMMA_MODE_MODE_* */
3511 #define   PIPECONF_INTERLACE_MASK		REG_GENMASK(23, 21) /* gen3+ */
3512 #define   PIPECONF_INTERLACE_PROGRESSIVE	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK, 0)
3513 #define   PIPECONF_INTERLACE_W_SYNC_SHIFT_PANEL	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK, 4) /* gen4 only */
3514 #define   PIPECONF_INTERLACE_W_SYNC_SHIFT	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK, 5) /* gen4 only */
3515 #define   PIPECONF_INTERLACE_W_FIELD_INDICATION	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK, 6)
3516 #define   PIPECONF_INTERLACE_FIELD_0_ONLY	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK, 7) /* gen3 only */
3517 /*
3518  * ilk+: PF/D=progressive fetch/display, IF/D=interlaced fetch/display,
3519  * DBL=power saving pixel doubling, PF-ID* requires panel fitter
3520  */
3521 #define   PIPECONF_INTERLACE_MASK_ILK		REG_GENMASK(23, 21) /* ilk+ */
3522 #define   PIPECONF_INTERLACE_MASK_HSW		REG_GENMASK(22, 21) /* hsw+ */
3523 #define   PIPECONF_INTERLACE_PF_PD_ILK		REG_FIELD_PREP(PIPECONF_INTERLACE_MASK_ILK, 0)
3524 #define   PIPECONF_INTERLACE_PF_ID_ILK		REG_FIELD_PREP(PIPECONF_INTERLACE_MASK_ILK, 1)
3525 #define   PIPECONF_INTERLACE_IF_ID_ILK		REG_FIELD_PREP(PIPECONF_INTERLACE_MASK_ILK, 3)
3526 #define   PIPECONF_INTERLACE_IF_ID_DBL_ILK	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK_ILK, 4) /* ilk/snb only */
3527 #define   PIPECONF_INTERLACE_PF_ID_DBL_ILK	REG_FIELD_PREP(PIPECONF_INTERLACE_MASK_ILK, 5) /* ilk/snb only */
3528 #define   PIPECONF_REFRESH_RATE_ALT_ILK		REG_BIT(20)
3529 #define   PIPECONF_MSA_TIMING_DELAY_MASK	REG_GENMASK(19, 18) /* ilk/snb/ivb */
3530 #define   PIPECONF_MSA_TIMING_DELAY(x)		REG_FIELD_PREP(PIPECONF_MSA_TIMING_DELAY_MASK, (x))
3531 #define   PIPECONF_CXSR_DOWNCLOCK		REG_BIT(16)
3532 #define   PIPECONF_REFRESH_RATE_ALT_VLV		REG_BIT(14)
3533 #define   PIPECONF_COLOR_RANGE_SELECT		REG_BIT(13)
3534 #define   PIPECONF_OUTPUT_COLORSPACE_MASK	REG_GENMASK(12, 11) /* ilk-ivb */
3535 #define   PIPECONF_OUTPUT_COLORSPACE_RGB	REG_FIELD_PREP(PIPECONF_OUTPUT_COLORSPACE_MASK, 0) /* ilk-ivb */
3536 #define   PIPECONF_OUTPUT_COLORSPACE_YUV601	REG_FIELD_PREP(PIPECONF_OUTPUT_COLORSPACE_MASK, 1) /* ilk-ivb */
3537 #define   PIPECONF_OUTPUT_COLORSPACE_YUV709	REG_FIELD_PREP(PIPECONF_OUTPUT_COLORSPACE_MASK, 2) /* ilk-ivb */
3538 #define   PIPECONF_OUTPUT_COLORSPACE_YUV_HSW	REG_BIT(11) /* hsw only */
3539 #define   PIPECONF_BPC_MASK			REG_GENMASK(7, 5) /* ctg-ivb */
3540 #define   PIPECONF_BPC_8			REG_FIELD_PREP(PIPECONF_BPC_MASK, 0)
3541 #define   PIPECONF_BPC_10			REG_FIELD_PREP(PIPECONF_BPC_MASK, 1)
3542 #define   PIPECONF_BPC_6			REG_FIELD_PREP(PIPECONF_BPC_MASK, 2)
3543 #define   PIPECONF_BPC_12			REG_FIELD_PREP(PIPECONF_BPC_MASK, 3)
3544 #define   PIPECONF_DITHER_EN			REG_BIT(4)
3545 #define   PIPECONF_DITHER_TYPE_MASK		REG_GENMASK(3, 2)
3546 #define   PIPECONF_DITHER_TYPE_SP		REG_FIELD_PREP(PIPECONF_DITHER_TYPE_MASK, 0)
3547 #define   PIPECONF_DITHER_TYPE_ST1		REG_FIELD_PREP(PIPECONF_DITHER_TYPE_MASK, 1)
3548 #define   PIPECONF_DITHER_TYPE_ST2		REG_FIELD_PREP(PIPECONF_DITHER_TYPE_MASK, 2)
3549 #define   PIPECONF_DITHER_TYPE_TEMP		REG_FIELD_PREP(PIPECONF_DITHER_TYPE_MASK, 3)
3550 #define _PIPEASTAT		0x70024
3551 #define   PIPE_FIFO_UNDERRUN_STATUS		(1UL << 31)
3552 #define   SPRITE1_FLIP_DONE_INT_EN_VLV		(1UL << 30)
3553 #define   PIPE_CRC_ERROR_ENABLE			(1UL << 29)
3554 #define   PIPE_CRC_DONE_ENABLE			(1UL << 28)
3555 #define   PERF_COUNTER2_INTERRUPT_EN		(1UL << 27)
3556 #define   PIPE_GMBUS_EVENT_ENABLE		(1UL << 27)
3557 #define   PLANE_FLIP_DONE_INT_EN_VLV		(1UL << 26)
3558 #define   PIPE_HOTPLUG_INTERRUPT_ENABLE		(1UL << 26)
3559 #define   PIPE_VSYNC_INTERRUPT_ENABLE		(1UL << 25)
3560 #define   PIPE_DISPLAY_LINE_COMPARE_ENABLE	(1UL << 24)
3561 #define   PIPE_DPST_EVENT_ENABLE		(1UL << 23)
3562 #define   SPRITE0_FLIP_DONE_INT_EN_VLV		(1UL << 22)
3563 #define   PIPE_LEGACY_BLC_EVENT_ENABLE		(1UL << 22)
3564 #define   PIPE_ODD_FIELD_INTERRUPT_ENABLE	(1UL << 21)
3565 #define   PIPE_EVEN_FIELD_INTERRUPT_ENABLE	(1UL << 20)
3566 #define   PIPE_B_PSR_INTERRUPT_ENABLE_VLV	(1UL << 19)
3567 #define   PERF_COUNTER_INTERRUPT_EN		(1UL << 19)
3568 #define   PIPE_HOTPLUG_TV_INTERRUPT_ENABLE	(1UL << 18) /* pre-965 */
3569 #define   PIPE_START_VBLANK_INTERRUPT_ENABLE	(1UL << 18) /* 965 or later */
3570 #define   PIPE_FRAMESTART_INTERRUPT_ENABLE	(1UL << 17)
3571 #define   PIPE_VBLANK_INTERRUPT_ENABLE		(1UL << 17)
3572 #define   PIPEA_HBLANK_INT_EN_VLV		(1UL << 16)
3573 #define   PIPE_OVERLAY_UPDATED_ENABLE		(1UL << 16)
3574 #define   SPRITE1_FLIP_DONE_INT_STATUS_VLV	(1UL << 15)
3575 #define   SPRITE0_FLIP_DONE_INT_STATUS_VLV	(1UL << 14)
3576 #define   PIPE_CRC_ERROR_INTERRUPT_STATUS	(1UL << 13)
3577 #define   PIPE_CRC_DONE_INTERRUPT_STATUS	(1UL << 12)
3578 #define   PERF_COUNTER2_INTERRUPT_STATUS	(1UL << 11)
3579 #define   PIPE_GMBUS_INTERRUPT_STATUS		(1UL << 11)
3580 #define   PLANE_FLIP_DONE_INT_STATUS_VLV	(1UL << 10)
3581 #define   PIPE_HOTPLUG_INTERRUPT_STATUS		(1UL << 10)
3582 #define   PIPE_VSYNC_INTERRUPT_STATUS		(1UL << 9)
3583 #define   PIPE_DISPLAY_LINE_COMPARE_STATUS	(1UL << 8)
3584 #define   PIPE_DPST_EVENT_STATUS		(1UL << 7)
3585 #define   PIPE_A_PSR_STATUS_VLV			(1UL << 6)
3586 #define   PIPE_LEGACY_BLC_EVENT_STATUS		(1UL << 6)
3587 #define   PIPE_ODD_FIELD_INTERRUPT_STATUS	(1UL << 5)
3588 #define   PIPE_EVEN_FIELD_INTERRUPT_STATUS	(1UL << 4)
3589 #define   PIPE_B_PSR_STATUS_VLV			(1UL << 3)
3590 #define   PERF_COUNTER_INTERRUPT_STATUS		(1UL << 3)
3591 #define   PIPE_HOTPLUG_TV_INTERRUPT_STATUS	(1UL << 2) /* pre-965 */
3592 #define   PIPE_START_VBLANK_INTERRUPT_STATUS	(1UL << 2) /* 965 or later */
3593 #define   PIPE_FRAMESTART_INTERRUPT_STATUS	(1UL << 1)
3594 #define   PIPE_VBLANK_INTERRUPT_STATUS		(1UL << 1)
3595 #define   PIPE_HBLANK_INT_STATUS		(1UL << 0)
3596 #define   PIPE_OVERLAY_UPDATED_STATUS		(1UL << 0)
3597 
3598 #define PIPESTAT_INT_ENABLE_MASK		0x7fff0000
3599 #define PIPESTAT_INT_STATUS_MASK		0x0000ffff
3600 
3601 #define PIPE_A_OFFSET		0x70000
3602 #define PIPE_B_OFFSET		0x71000
3603 #define PIPE_C_OFFSET		0x72000
3604 #define PIPE_D_OFFSET		0x73000
3605 #define CHV_PIPE_C_OFFSET	0x74000
3606 /*
3607  * There's actually no pipe EDP. Some pipe registers have
3608  * simply shifted from the pipe to the transcoder, while
3609  * keeping their original offset. Thus we need PIPE_EDP_OFFSET
3610  * to access such registers in transcoder EDP.
3611  */
3612 #define PIPE_EDP_OFFSET	0x7f000
3613 
3614 /* ICL DSI 0 and 1 */
3615 #define PIPE_DSI0_OFFSET	0x7b000
3616 #define PIPE_DSI1_OFFSET	0x7b800
3617 
3618 #define PIPECONF(pipe)		_MMIO_PIPE2(pipe, _PIPEACONF)
3619 #define PIPEDSL(pipe)		_MMIO_PIPE2(pipe, _PIPEADSL)
3620 #define PIPEFRAME(pipe)		_MMIO_PIPE2(pipe, _PIPEAFRAMEHIGH)
3621 #define PIPEFRAMEPIXEL(pipe)	_MMIO_PIPE2(pipe, _PIPEAFRAMEPIXEL)
3622 #define PIPESTAT(pipe)		_MMIO_PIPE2(pipe, _PIPEASTAT)
3623 
3624 #define  _PIPEAGCMAX           0x70010
3625 #define  _PIPEBGCMAX           0x71010
3626 #define PIPEGCMAX(pipe, i)     _MMIO_PIPE2(pipe, _PIPEAGCMAX + (i) * 4) /* u1.16 */
3627 
3628 #define _PIPE_ARB_CTL_A			0x70028 /* icl+ */
3629 #define PIPE_ARB_CTL(pipe)		_MMIO_PIPE2(pipe, _PIPE_ARB_CTL_A)
3630 #define   PIPE_ARB_USE_PROG_SLOTS	REG_BIT(13)
3631 
3632 #define _PIPE_MISC_A			0x70030
3633 #define _PIPE_MISC_B			0x71030
3634 #define   PIPEMISC_YUV420_ENABLE		REG_BIT(27) /* glk+ */
3635 #define   PIPEMISC_YUV420_MODE_FULL_BLEND	REG_BIT(26) /* glk+ */
3636 #define   PIPEMISC_HDR_MODE_PRECISION		REG_BIT(23) /* icl+ */
3637 #define   PIPEMISC_OUTPUT_COLORSPACE_YUV	REG_BIT(11)
3638 #define   PIPEMISC_PIXEL_ROUNDING_TRUNC		REG_BIT(8) /* tgl+ */
3639 /*
3640  * For Display < 13, Bits 5-7 of PIPE MISC represent DITHER BPC with
3641  * valid values of: 6, 8, 10 BPC.
3642  * ADLP+, the bits 5-7 represent PORT OUTPUT BPC with valid values of:
3643  * 6, 8, 10, 12 BPC.
3644  */
3645 #define   PIPEMISC_BPC_MASK			REG_GENMASK(7, 5)
3646 #define   PIPEMISC_BPC_8			REG_FIELD_PREP(PIPEMISC_BPC_MASK, 0)
3647 #define   PIPEMISC_BPC_10			REG_FIELD_PREP(PIPEMISC_BPC_MASK, 1)
3648 #define   PIPEMISC_BPC_6			REG_FIELD_PREP(PIPEMISC_BPC_MASK, 2)
3649 #define   PIPEMISC_BPC_12_ADLP			REG_FIELD_PREP(PIPEMISC_BPC_MASK, 4) /* adlp+ */
3650 #define   PIPEMISC_DITHER_ENABLE		REG_BIT(4)
3651 #define   PIPEMISC_DITHER_TYPE_MASK		REG_GENMASK(3, 2)
3652 #define   PIPEMISC_DITHER_TYPE_SP		REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 0)
3653 #define   PIPEMISC_DITHER_TYPE_ST1		REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 1)
3654 #define   PIPEMISC_DITHER_TYPE_ST2		REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 2)
3655 #define   PIPEMISC_DITHER_TYPE_TEMP		REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 3)
3656 #define PIPEMISC(pipe)			_MMIO_PIPE2(pipe, _PIPE_MISC_A)
3657 
3658 #define _PIPE_MISC2_A					0x7002C
3659 #define _PIPE_MISC2_B					0x7102C
3660 #define   PIPE_MISC2_BUBBLE_COUNTER_MASK	REG_GENMASK(31, 24)
3661 #define   PIPE_MISC2_BUBBLE_COUNTER_SCALER_EN	REG_FIELD_PREP(PIPE_MISC2_BUBBLE_COUNTER_MASK, 80)
3662 #define   PIPE_MISC2_BUBBLE_COUNTER_SCALER_DIS	REG_FIELD_PREP(PIPE_MISC2_BUBBLE_COUNTER_MASK, 20)
3663 #define PIPE_MISC2(pipe)					_MMIO_PIPE2(pipe, _PIPE_MISC2_A)
3664 
3665 /* Skylake+ pipe bottom (background) color */
3666 #define _SKL_BOTTOM_COLOR_A		0x70034
3667 #define _SKL_BOTTOM_COLOR_B		0x71034
3668 #define   SKL_BOTTOM_COLOR_GAMMA_ENABLE		REG_BIT(31)
3669 #define   SKL_BOTTOM_COLOR_CSC_ENABLE		REG_BIT(30)
3670 #define SKL_BOTTOM_COLOR(pipe)		_MMIO_PIPE(pipe, _SKL_BOTTOM_COLOR_A, _SKL_BOTTOM_COLOR_B)
3671 
3672 #define _ICL_PIPE_A_STATUS			0x70058
3673 #define ICL_PIPESTATUS(pipe)			_MMIO_PIPE2(pipe, _ICL_PIPE_A_STATUS)
3674 #define   PIPE_STATUS_UNDERRUN				REG_BIT(31)
3675 #define   PIPE_STATUS_SOFT_UNDERRUN_XELPD		REG_BIT(28)
3676 #define   PIPE_STATUS_HARD_UNDERRUN_XELPD		REG_BIT(27)
3677 #define   PIPE_STATUS_PORT_UNDERRUN_XELPD		REG_BIT(26)
3678 
3679 #define VLV_DPFLIPSTAT				_MMIO(VLV_DISPLAY_BASE + 0x70028)
3680 #define   PIPEB_LINE_COMPARE_INT_EN			REG_BIT(29)
3681 #define   PIPEB_HLINE_INT_EN			REG_BIT(28)
3682 #define   PIPEB_VBLANK_INT_EN			REG_BIT(27)
3683 #define   SPRITED_FLIP_DONE_INT_EN			REG_BIT(26)
3684 #define   SPRITEC_FLIP_DONE_INT_EN			REG_BIT(25)
3685 #define   PLANEB_FLIP_DONE_INT_EN			REG_BIT(24)
3686 #define   PIPE_PSR_INT_EN			REG_BIT(22)
3687 #define   PIPEA_LINE_COMPARE_INT_EN			REG_BIT(21)
3688 #define   PIPEA_HLINE_INT_EN			REG_BIT(20)
3689 #define   PIPEA_VBLANK_INT_EN			REG_BIT(19)
3690 #define   SPRITEB_FLIP_DONE_INT_EN			REG_BIT(18)
3691 #define   SPRITEA_FLIP_DONE_INT_EN			REG_BIT(17)
3692 #define   PLANEA_FLIPDONE_INT_EN			REG_BIT(16)
3693 #define   PIPEC_LINE_COMPARE_INT_EN			REG_BIT(13)
3694 #define   PIPEC_HLINE_INT_EN			REG_BIT(12)
3695 #define   PIPEC_VBLANK_INT_EN			REG_BIT(11)
3696 #define   SPRITEF_FLIPDONE_INT_EN			REG_BIT(10)
3697 #define   SPRITEE_FLIPDONE_INT_EN			REG_BIT(9)
3698 #define   PLANEC_FLIPDONE_INT_EN			REG_BIT(8)
3699 
3700 #define DPINVGTT				_MMIO(VLV_DISPLAY_BASE + 0x7002c) /* VLV/CHV only */
3701 #define   DPINVGTT_EN_MASK_CHV				REG_GENMASK(27, 16)
3702 #define   DPINVGTT_EN_MASK_VLV				REG_GENMASK(23, 16)
3703 #define   SPRITEF_INVALID_GTT_INT_EN			REG_BIT(27)
3704 #define   SPRITEE_INVALID_GTT_INT_EN			REG_BIT(26)
3705 #define   PLANEC_INVALID_GTT_INT_EN			REG_BIT(25)
3706 #define   CURSORC_INVALID_GTT_INT_EN			REG_BIT(24)
3707 #define   CURSORB_INVALID_GTT_INT_EN			REG_BIT(23)
3708 #define   CURSORA_INVALID_GTT_INT_EN			REG_BIT(22)
3709 #define   SPRITED_INVALID_GTT_INT_EN			REG_BIT(21)
3710 #define   SPRITEC_INVALID_GTT_INT_EN			REG_BIT(20)
3711 #define   PLANEB_INVALID_GTT_INT_EN			REG_BIT(19)
3712 #define   SPRITEB_INVALID_GTT_INT_EN			REG_BIT(18)
3713 #define   SPRITEA_INVALID_GTT_INT_EN			REG_BIT(17)
3714 #define   PLANEA_INVALID_GTT_INT_EN			REG_BIT(16)
3715 #define   DPINVGTT_STATUS_MASK_CHV			REG_GENMASK(11, 0)
3716 #define   DPINVGTT_STATUS_MASK_VLV			REG_GENMASK(7, 0)
3717 #define   SPRITEF_INVALID_GTT_STATUS			REG_BIT(11)
3718 #define   SPRITEE_INVALID_GTT_STATUS			REG_BIT(10)
3719 #define   PLANEC_INVALID_GTT_STATUS			REG_BIT(9)
3720 #define   CURSORC_INVALID_GTT_STATUS			REG_BIT(8)
3721 #define   CURSORB_INVALID_GTT_STATUS			REG_BIT(7)
3722 #define   CURSORA_INVALID_GTT_STATUS			REG_BIT(6)
3723 #define   SPRITED_INVALID_GTT_STATUS			REG_BIT(5)
3724 #define   SPRITEC_INVALID_GTT_STATUS			REG_BIT(4)
3725 #define   PLANEB_INVALID_GTT_STATUS			REG_BIT(3)
3726 #define   SPRITEB_INVALID_GTT_STATUS			REG_BIT(2)
3727 #define   SPRITEA_INVALID_GTT_STATUS			REG_BIT(1)
3728 #define   PLANEA_INVALID_GTT_STATUS			REG_BIT(0)
3729 
3730 #define DSPARB			_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70030)
3731 #define   DSPARB_CSTART_MASK	(0x7f << 7)
3732 #define   DSPARB_CSTART_SHIFT	7
3733 #define   DSPARB_BSTART_MASK	(0x7f)
3734 #define   DSPARB_BSTART_SHIFT	0
3735 #define   DSPARB_BEND_SHIFT	9 /* on 855 */
3736 #define   DSPARB_AEND_SHIFT	0
3737 #define   DSPARB_SPRITEA_SHIFT_VLV	0
3738 #define   DSPARB_SPRITEA_MASK_VLV	(0xff << 0)
3739 #define   DSPARB_SPRITEB_SHIFT_VLV	8
3740 #define   DSPARB_SPRITEB_MASK_VLV	(0xff << 8)
3741 #define   DSPARB_SPRITEC_SHIFT_VLV	16
3742 #define   DSPARB_SPRITEC_MASK_VLV	(0xff << 16)
3743 #define   DSPARB_SPRITED_SHIFT_VLV	24
3744 #define   DSPARB_SPRITED_MASK_VLV	(0xff << 24)
3745 #define DSPARB2				_MMIO(VLV_DISPLAY_BASE + 0x70060) /* vlv/chv */
3746 #define   DSPARB_SPRITEA_HI_SHIFT_VLV	0
3747 #define   DSPARB_SPRITEA_HI_MASK_VLV	(0x1 << 0)
3748 #define   DSPARB_SPRITEB_HI_SHIFT_VLV	4
3749 #define   DSPARB_SPRITEB_HI_MASK_VLV	(0x1 << 4)
3750 #define   DSPARB_SPRITEC_HI_SHIFT_VLV	8
3751 #define   DSPARB_SPRITEC_HI_MASK_VLV	(0x1 << 8)
3752 #define   DSPARB_SPRITED_HI_SHIFT_VLV	12
3753 #define   DSPARB_SPRITED_HI_MASK_VLV	(0x1 << 12)
3754 #define   DSPARB_SPRITEE_HI_SHIFT_VLV	16
3755 #define   DSPARB_SPRITEE_HI_MASK_VLV	(0x1 << 16)
3756 #define   DSPARB_SPRITEF_HI_SHIFT_VLV	20
3757 #define   DSPARB_SPRITEF_HI_MASK_VLV	(0x1 << 20)
3758 #define DSPARB3				_MMIO(VLV_DISPLAY_BASE + 0x7006c) /* chv */
3759 #define   DSPARB_SPRITEE_SHIFT_VLV	0
3760 #define   DSPARB_SPRITEE_MASK_VLV	(0xff << 0)
3761 #define   DSPARB_SPRITEF_SHIFT_VLV	8
3762 #define   DSPARB_SPRITEF_MASK_VLV	(0xff << 8)
3763 
3764 /* pnv/gen4/g4x/vlv/chv */
3765 #define DSPFW1		_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70034)
3766 #define   DSPFW_SR_SHIFT		23
3767 #define   DSPFW_SR_MASK			(0x1ff << 23)
3768 #define   DSPFW_CURSORB_SHIFT		16
3769 #define   DSPFW_CURSORB_MASK		(0x3f << 16)
3770 #define   DSPFW_PLANEB_SHIFT		8
3771 #define   DSPFW_PLANEB_MASK		(0x7f << 8)
3772 #define   DSPFW_PLANEB_MASK_VLV		(0xff << 8) /* vlv/chv */
3773 #define   DSPFW_PLANEA_SHIFT		0
3774 #define   DSPFW_PLANEA_MASK		(0x7f << 0)
3775 #define   DSPFW_PLANEA_MASK_VLV		(0xff << 0) /* vlv/chv */
3776 #define DSPFW2		_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70038)
3777 #define   DSPFW_FBC_SR_EN		(1 << 31)	  /* g4x */
3778 #define   DSPFW_FBC_SR_SHIFT		28
3779 #define   DSPFW_FBC_SR_MASK		(0x7 << 28) /* g4x */
3780 #define   DSPFW_FBC_HPLL_SR_SHIFT	24
3781 #define   DSPFW_FBC_HPLL_SR_MASK	(0xf << 24) /* g4x */
3782 #define   DSPFW_SPRITEB_SHIFT		(16)
3783 #define   DSPFW_SPRITEB_MASK		(0x7f << 16) /* g4x */
3784 #define   DSPFW_SPRITEB_MASK_VLV	(0xff << 16) /* vlv/chv */
3785 #define   DSPFW_CURSORA_SHIFT		8
3786 #define   DSPFW_CURSORA_MASK		(0x3f << 8)
3787 #define   DSPFW_PLANEC_OLD_SHIFT	0
3788 #define   DSPFW_PLANEC_OLD_MASK		(0x7f << 0) /* pre-gen4 sprite C */
3789 #define   DSPFW_SPRITEA_SHIFT		0
3790 #define   DSPFW_SPRITEA_MASK		(0x7f << 0) /* g4x */
3791 #define   DSPFW_SPRITEA_MASK_VLV	(0xff << 0) /* vlv/chv */
3792 #define DSPFW3		_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x7003c)
3793 #define   DSPFW_HPLL_SR_EN		(1 << 31)
3794 #define   PINEVIEW_SELF_REFRESH_EN	(1 << 30)
3795 #define   DSPFW_CURSOR_SR_SHIFT		24
3796 #define   DSPFW_CURSOR_SR_MASK		(0x3f << 24)
3797 #define   DSPFW_HPLL_CURSOR_SHIFT	16
3798 #define   DSPFW_HPLL_CURSOR_MASK	(0x3f << 16)
3799 #define   DSPFW_HPLL_SR_SHIFT		0
3800 #define   DSPFW_HPLL_SR_MASK		(0x1ff << 0)
3801 
3802 /* vlv/chv */
3803 #define DSPFW4		_MMIO(VLV_DISPLAY_BASE + 0x70070)
3804 #define   DSPFW_SPRITEB_WM1_SHIFT	16
3805 #define   DSPFW_SPRITEB_WM1_MASK	(0xff << 16)
3806 #define   DSPFW_CURSORA_WM1_SHIFT	8
3807 #define   DSPFW_CURSORA_WM1_MASK	(0x3f << 8)
3808 #define   DSPFW_SPRITEA_WM1_SHIFT	0
3809 #define   DSPFW_SPRITEA_WM1_MASK	(0xff << 0)
3810 #define DSPFW5		_MMIO(VLV_DISPLAY_BASE + 0x70074)
3811 #define   DSPFW_PLANEB_WM1_SHIFT	24
3812 #define   DSPFW_PLANEB_WM1_MASK		(0xff << 24)
3813 #define   DSPFW_PLANEA_WM1_SHIFT	16
3814 #define   DSPFW_PLANEA_WM1_MASK		(0xff << 16)
3815 #define   DSPFW_CURSORB_WM1_SHIFT	8
3816 #define   DSPFW_CURSORB_WM1_MASK	(0x3f << 8)
3817 #define   DSPFW_CURSOR_SR_WM1_SHIFT	0
3818 #define   DSPFW_CURSOR_SR_WM1_MASK	(0x3f << 0)
3819 #define DSPFW6		_MMIO(VLV_DISPLAY_BASE + 0x70078)
3820 #define   DSPFW_SR_WM1_SHIFT		0
3821 #define   DSPFW_SR_WM1_MASK		(0x1ff << 0)
3822 #define DSPFW7		_MMIO(VLV_DISPLAY_BASE + 0x7007c)
3823 #define DSPFW7_CHV	_MMIO(VLV_DISPLAY_BASE + 0x700b4) /* wtf #1? */
3824 #define   DSPFW_SPRITED_WM1_SHIFT	24
3825 #define   DSPFW_SPRITED_WM1_MASK	(0xff << 24)
3826 #define   DSPFW_SPRITED_SHIFT		16
3827 #define   DSPFW_SPRITED_MASK_VLV	(0xff << 16)
3828 #define   DSPFW_SPRITEC_WM1_SHIFT	8
3829 #define   DSPFW_SPRITEC_WM1_MASK	(0xff << 8)
3830 #define   DSPFW_SPRITEC_SHIFT		0
3831 #define   DSPFW_SPRITEC_MASK_VLV	(0xff << 0)
3832 #define DSPFW8_CHV	_MMIO(VLV_DISPLAY_BASE + 0x700b8)
3833 #define   DSPFW_SPRITEF_WM1_SHIFT	24
3834 #define   DSPFW_SPRITEF_WM1_MASK	(0xff << 24)
3835 #define   DSPFW_SPRITEF_SHIFT		16
3836 #define   DSPFW_SPRITEF_MASK_VLV	(0xff << 16)
3837 #define   DSPFW_SPRITEE_WM1_SHIFT	8
3838 #define   DSPFW_SPRITEE_WM1_MASK	(0xff << 8)
3839 #define   DSPFW_SPRITEE_SHIFT		0
3840 #define   DSPFW_SPRITEE_MASK_VLV	(0xff << 0)
3841 #define DSPFW9_CHV	_MMIO(VLV_DISPLAY_BASE + 0x7007c) /* wtf #2? */
3842 #define   DSPFW_PLANEC_WM1_SHIFT	24
3843 #define   DSPFW_PLANEC_WM1_MASK		(0xff << 24)
3844 #define   DSPFW_PLANEC_SHIFT		16
3845 #define   DSPFW_PLANEC_MASK_VLV		(0xff << 16)
3846 #define   DSPFW_CURSORC_WM1_SHIFT	8
3847 #define   DSPFW_CURSORC_WM1_MASK	(0x3f << 16)
3848 #define   DSPFW_CURSORC_SHIFT		0
3849 #define   DSPFW_CURSORC_MASK		(0x3f << 0)
3850 
3851 /* vlv/chv high order bits */
3852 #define DSPHOWM		_MMIO(VLV_DISPLAY_BASE + 0x70064)
3853 #define   DSPFW_SR_HI_SHIFT		24
3854 #define   DSPFW_SR_HI_MASK		(3 << 24) /* 2 bits for chv, 1 for vlv */
3855 #define   DSPFW_SPRITEF_HI_SHIFT	23
3856 #define   DSPFW_SPRITEF_HI_MASK		(1 << 23)
3857 #define   DSPFW_SPRITEE_HI_SHIFT	22
3858 #define   DSPFW_SPRITEE_HI_MASK		(1 << 22)
3859 #define   DSPFW_PLANEC_HI_SHIFT		21
3860 #define   DSPFW_PLANEC_HI_MASK		(1 << 21)
3861 #define   DSPFW_SPRITED_HI_SHIFT	20
3862 #define   DSPFW_SPRITED_HI_MASK		(1 << 20)
3863 #define   DSPFW_SPRITEC_HI_SHIFT	16
3864 #define   DSPFW_SPRITEC_HI_MASK		(1 << 16)
3865 #define   DSPFW_PLANEB_HI_SHIFT		12
3866 #define   DSPFW_PLANEB_HI_MASK		(1 << 12)
3867 #define   DSPFW_SPRITEB_HI_SHIFT	8
3868 #define   DSPFW_SPRITEB_HI_MASK		(1 << 8)
3869 #define   DSPFW_SPRITEA_HI_SHIFT	4
3870 #define   DSPFW_SPRITEA_HI_MASK		(1 << 4)
3871 #define   DSPFW_PLANEA_HI_SHIFT		0
3872 #define   DSPFW_PLANEA_HI_MASK		(1 << 0)
3873 #define DSPHOWM1	_MMIO(VLV_DISPLAY_BASE + 0x70068)
3874 #define   DSPFW_SR_WM1_HI_SHIFT		24
3875 #define   DSPFW_SR_WM1_HI_MASK		(3 << 24) /* 2 bits for chv, 1 for vlv */
3876 #define   DSPFW_SPRITEF_WM1_HI_SHIFT	23
3877 #define   DSPFW_SPRITEF_WM1_HI_MASK	(1 << 23)
3878 #define   DSPFW_SPRITEE_WM1_HI_SHIFT	22
3879 #define   DSPFW_SPRITEE_WM1_HI_MASK	(1 << 22)
3880 #define   DSPFW_PLANEC_WM1_HI_SHIFT	21
3881 #define   DSPFW_PLANEC_WM1_HI_MASK	(1 << 21)
3882 #define   DSPFW_SPRITED_WM1_HI_SHIFT	20
3883 #define   DSPFW_SPRITED_WM1_HI_MASK	(1 << 20)
3884 #define   DSPFW_SPRITEC_WM1_HI_SHIFT	16
3885 #define   DSPFW_SPRITEC_WM1_HI_MASK	(1 << 16)
3886 #define   DSPFW_PLANEB_WM1_HI_SHIFT	12
3887 #define   DSPFW_PLANEB_WM1_HI_MASK	(1 << 12)
3888 #define   DSPFW_SPRITEB_WM1_HI_SHIFT	8
3889 #define   DSPFW_SPRITEB_WM1_HI_MASK	(1 << 8)
3890 #define   DSPFW_SPRITEA_WM1_HI_SHIFT	4
3891 #define   DSPFW_SPRITEA_WM1_HI_MASK	(1 << 4)
3892 #define   DSPFW_PLANEA_WM1_HI_SHIFT	0
3893 #define   DSPFW_PLANEA_WM1_HI_MASK	(1 << 0)
3894 
3895 /* drain latency register values*/
3896 #define VLV_DDL(pipe)			_MMIO(VLV_DISPLAY_BASE + 0x70050 + 4 * (pipe))
3897 #define DDL_CURSOR_SHIFT		24
3898 #define DDL_SPRITE_SHIFT(sprite)	(8 + 8 * (sprite))
3899 #define DDL_PLANE_SHIFT			0
3900 #define DDL_PRECISION_HIGH		(1 << 7)
3901 #define DDL_PRECISION_LOW		(0 << 7)
3902 #define DRAIN_LATENCY_MASK		0x7f
3903 
3904 #define CBR1_VLV			_MMIO(VLV_DISPLAY_BASE + 0x70400)
3905 #define  CBR_PND_DEADLINE_DISABLE	(1 << 31)
3906 #define  CBR_PWM_CLOCK_MUX_SELECT	(1 << 30)
3907 
3908 #define CBR4_VLV			_MMIO(VLV_DISPLAY_BASE + 0x70450)
3909 #define  CBR_DPLLBMD_PIPE(pipe)		(1 << (7 + (pipe) * 11)) /* pipes B and C */
3910 
3911 /* FIFO watermark sizes etc */
3912 #define G4X_FIFO_LINE_SIZE	64
3913 #define I915_FIFO_LINE_SIZE	64
3914 #define I830_FIFO_LINE_SIZE	32
3915 
3916 #define VALLEYVIEW_FIFO_SIZE	255
3917 #define G4X_FIFO_SIZE		127
3918 #define I965_FIFO_SIZE		512
3919 #define I945_FIFO_SIZE		127
3920 #define I915_FIFO_SIZE		95
3921 #define I855GM_FIFO_SIZE	127 /* In cachelines */
3922 #define I830_FIFO_SIZE		95
3923 
3924 #define VALLEYVIEW_MAX_WM	0xff
3925 #define G4X_MAX_WM		0x3f
3926 #define I915_MAX_WM		0x3f
3927 
3928 #define PINEVIEW_DISPLAY_FIFO	512 /* in 64byte unit */
3929 #define PINEVIEW_FIFO_LINE_SIZE	64
3930 #define PINEVIEW_MAX_WM		0x1ff
3931 #define PINEVIEW_DFT_WM		0x3f
3932 #define PINEVIEW_DFT_HPLLOFF_WM	0
3933 #define PINEVIEW_GUARD_WM		10
3934 #define PINEVIEW_CURSOR_FIFO		64
3935 #define PINEVIEW_CURSOR_MAX_WM	0x3f
3936 #define PINEVIEW_CURSOR_DFT_WM	0
3937 #define PINEVIEW_CURSOR_GUARD_WM	5
3938 
3939 #define VALLEYVIEW_CURSOR_MAX_WM 64
3940 #define I965_CURSOR_FIFO	64
3941 #define I965_CURSOR_MAX_WM	32
3942 #define I965_CURSOR_DFT_WM	8
3943 
3944 /* Watermark register definitions for SKL */
3945 #define _CUR_WM_A_0		0x70140
3946 #define _CUR_WM_B_0		0x71140
3947 #define _CUR_WM_SAGV_A		0x70158
3948 #define _CUR_WM_SAGV_B		0x71158
3949 #define _CUR_WM_SAGV_TRANS_A	0x7015C
3950 #define _CUR_WM_SAGV_TRANS_B	0x7115C
3951 #define _CUR_WM_TRANS_A		0x70168
3952 #define _CUR_WM_TRANS_B		0x71168
3953 #define _PLANE_WM_1_A_0		0x70240
3954 #define _PLANE_WM_1_B_0		0x71240
3955 #define _PLANE_WM_2_A_0		0x70340
3956 #define _PLANE_WM_2_B_0		0x71340
3957 #define _PLANE_WM_SAGV_1_A	0x70258
3958 #define _PLANE_WM_SAGV_1_B	0x71258
3959 #define _PLANE_WM_SAGV_2_A	0x70358
3960 #define _PLANE_WM_SAGV_2_B	0x71358
3961 #define _PLANE_WM_SAGV_TRANS_1_A	0x7025C
3962 #define _PLANE_WM_SAGV_TRANS_1_B	0x7125C
3963 #define _PLANE_WM_SAGV_TRANS_2_A	0x7035C
3964 #define _PLANE_WM_SAGV_TRANS_2_B	0x7135C
3965 #define _PLANE_WM_TRANS_1_A	0x70268
3966 #define _PLANE_WM_TRANS_1_B	0x71268
3967 #define _PLANE_WM_TRANS_2_A	0x70368
3968 #define _PLANE_WM_TRANS_2_B	0x71368
3969 #define   PLANE_WM_EN		(1 << 31)
3970 #define   PLANE_WM_IGNORE_LINES	(1 << 30)
3971 #define   PLANE_WM_LINES_MASK	REG_GENMASK(26, 14)
3972 #define   PLANE_WM_BLOCKS_MASK	REG_GENMASK(11, 0)
3973 
3974 #define _CUR_WM_0(pipe) _PIPE(pipe, _CUR_WM_A_0, _CUR_WM_B_0)
3975 #define CUR_WM(pipe, level) _MMIO(_CUR_WM_0(pipe) + ((4) * (level)))
3976 #define CUR_WM_SAGV(pipe) _MMIO_PIPE(pipe, _CUR_WM_SAGV_A, _CUR_WM_SAGV_B)
3977 #define CUR_WM_SAGV_TRANS(pipe) _MMIO_PIPE(pipe, _CUR_WM_SAGV_TRANS_A, _CUR_WM_SAGV_TRANS_B)
3978 #define CUR_WM_TRANS(pipe) _MMIO_PIPE(pipe, _CUR_WM_TRANS_A, _CUR_WM_TRANS_B)
3979 #define _PLANE_WM_1(pipe) _PIPE(pipe, _PLANE_WM_1_A_0, _PLANE_WM_1_B_0)
3980 #define _PLANE_WM_2(pipe) _PIPE(pipe, _PLANE_WM_2_A_0, _PLANE_WM_2_B_0)
3981 #define _PLANE_WM_BASE(pipe, plane) \
3982 	_PLANE(plane, _PLANE_WM_1(pipe), _PLANE_WM_2(pipe))
3983 #define PLANE_WM(pipe, plane, level) \
3984 	_MMIO(_PLANE_WM_BASE(pipe, plane) + ((4) * (level)))
3985 #define _PLANE_WM_SAGV_1(pipe) \
3986 	_PIPE(pipe, _PLANE_WM_SAGV_1_A, _PLANE_WM_SAGV_1_B)
3987 #define _PLANE_WM_SAGV_2(pipe) \
3988 	_PIPE(pipe, _PLANE_WM_SAGV_2_A, _PLANE_WM_SAGV_2_B)
3989 #define PLANE_WM_SAGV(pipe, plane) \
3990 	_MMIO(_PLANE(plane, _PLANE_WM_SAGV_1(pipe), _PLANE_WM_SAGV_2(pipe)))
3991 #define _PLANE_WM_SAGV_TRANS_1(pipe) \
3992 	_PIPE(pipe, _PLANE_WM_SAGV_TRANS_1_A, _PLANE_WM_SAGV_TRANS_1_B)
3993 #define _PLANE_WM_SAGV_TRANS_2(pipe) \
3994 	_PIPE(pipe, _PLANE_WM_SAGV_TRANS_2_A, _PLANE_WM_SAGV_TRANS_2_B)
3995 #define PLANE_WM_SAGV_TRANS(pipe, plane) \
3996 	_MMIO(_PLANE(plane, _PLANE_WM_SAGV_TRANS_1(pipe), _PLANE_WM_SAGV_TRANS_2(pipe)))
3997 #define _PLANE_WM_TRANS_1(pipe) \
3998 	_PIPE(pipe, _PLANE_WM_TRANS_1_A, _PLANE_WM_TRANS_1_B)
3999 #define _PLANE_WM_TRANS_2(pipe) \
4000 	_PIPE(pipe, _PLANE_WM_TRANS_2_A, _PLANE_WM_TRANS_2_B)
4001 #define PLANE_WM_TRANS(pipe, plane) \
4002 	_MMIO(_PLANE(plane, _PLANE_WM_TRANS_1(pipe), _PLANE_WM_TRANS_2(pipe)))
4003 
4004 /* define the Watermark register on Ironlake */
4005 #define _WM0_PIPEA_ILK		0x45100
4006 #define _WM0_PIPEB_ILK		0x45104
4007 #define _WM0_PIPEC_IVB		0x45200
4008 #define WM0_PIPE_ILK(pipe)	_MMIO_PIPE3((pipe), _WM0_PIPEA_ILK, \
4009 					    _WM0_PIPEB_ILK, _WM0_PIPEC_IVB)
4010 #define  WM0_PIPE_PRIMARY_MASK	REG_GENMASK(31, 16)
4011 #define  WM0_PIPE_SPRITE_MASK	REG_GENMASK(15, 8)
4012 #define  WM0_PIPE_CURSOR_MASK	REG_GENMASK(7, 0)
4013 #define  WM0_PIPE_PRIMARY(x)	REG_FIELD_PREP(WM0_PIPE_PRIMARY_MASK, (x))
4014 #define  WM0_PIPE_SPRITE(x)	REG_FIELD_PREP(WM0_PIPE_SPRITE_MASK, (x))
4015 #define  WM0_PIPE_CURSOR(x)	REG_FIELD_PREP(WM0_PIPE_CURSOR_MASK, (x))
4016 #define WM1_LP_ILK		_MMIO(0x45108)
4017 #define WM2_LP_ILK		_MMIO(0x4510c)
4018 #define WM3_LP_ILK		_MMIO(0x45110)
4019 #define  WM_LP_ENABLE		REG_BIT(31)
4020 #define  WM_LP_LATENCY_MASK	REG_GENMASK(30, 24)
4021 #define  WM_LP_FBC_MASK_BDW	REG_GENMASK(23, 19)
4022 #define  WM_LP_FBC_MASK_ILK	REG_GENMASK(23, 20)
4023 #define  WM_LP_PRIMARY_MASK	REG_GENMASK(18, 8)
4024 #define  WM_LP_CURSOR_MASK	REG_GENMASK(7, 0)
4025 #define  WM_LP_LATENCY(x)	REG_FIELD_PREP(WM_LP_LATENCY_MASK, (x))
4026 #define  WM_LP_FBC_BDW(x)	REG_FIELD_PREP(WM_LP_FBC_MASK_BDW, (x))
4027 #define  WM_LP_FBC_ILK(x)	REG_FIELD_PREP(WM_LP_FBC_MASK_ILK, (x))
4028 #define  WM_LP_PRIMARY(x)	REG_FIELD_PREP(WM_LP_PRIMARY_MASK, (x))
4029 #define  WM_LP_CURSOR(x)	REG_FIELD_PREP(WM_LP_CURSOR_MASK, (x))
4030 #define WM1S_LP_ILK		_MMIO(0x45120)
4031 #define WM2S_LP_IVB		_MMIO(0x45124)
4032 #define WM3S_LP_IVB		_MMIO(0x45128)
4033 #define  WM_LP_SPRITE_ENABLE	REG_BIT(31) /* ilk/snb WM1S only */
4034 #define  WM_LP_SPRITE_MASK	REG_GENMASK(10, 0)
4035 #define  WM_LP_SPRITE(x)	REG_FIELD_PREP(WM_LP_SPRITE_MASK, (x))
4036 
4037 /*
4038  * The two pipe frame counter registers are not synchronized, so
4039  * reading a stable value is somewhat tricky. The following code
4040  * should work:
4041  *
4042  *  do {
4043  *    high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
4044  *             PIPE_FRAME_HIGH_SHIFT;
4045  *    low1 =  ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >>
4046  *             PIPE_FRAME_LOW_SHIFT);
4047  *    high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
4048  *             PIPE_FRAME_HIGH_SHIFT);
4049  *  } while (high1 != high2);
4050  *  frame = (high1 << 8) | low1;
4051  */
4052 #define _PIPEAFRAMEHIGH          0x70040
4053 #define   PIPE_FRAME_HIGH_MASK    0x0000ffff
4054 #define   PIPE_FRAME_HIGH_SHIFT   0
4055 #define _PIPEAFRAMEPIXEL         0x70044
4056 #define   PIPE_FRAME_LOW_MASK     0xff000000
4057 #define   PIPE_FRAME_LOW_SHIFT    24
4058 #define   PIPE_PIXEL_MASK         0x00ffffff
4059 #define   PIPE_PIXEL_SHIFT        0
4060 /* GM45+ just has to be different */
4061 #define _PIPEA_FRMCOUNT_G4X	0x70040
4062 #define _PIPEA_FLIPCOUNT_G4X	0x70044
4063 #define PIPE_FRMCOUNT_G4X(pipe) _MMIO_PIPE2(pipe, _PIPEA_FRMCOUNT_G4X)
4064 #define PIPE_FLIPCOUNT_G4X(pipe) _MMIO_PIPE2(pipe, _PIPEA_FLIPCOUNT_G4X)
4065 
4066 /* Cursor A & B regs */
4067 #define _CURACNTR		0x70080
4068 /* Old style CUR*CNTR flags (desktop 8xx) */
4069 #define   CURSOR_ENABLE			REG_BIT(31)
4070 #define   CURSOR_PIPE_GAMMA_ENABLE	REG_BIT(30)
4071 #define   CURSOR_STRIDE_MASK	REG_GENMASK(29, 28)
4072 #define   CURSOR_STRIDE(stride)	REG_FIELD_PREP(CURSOR_STRIDE_MASK, ffs(stride) - 9) /* 256,512,1k,2k */
4073 #define   CURSOR_FORMAT_MASK	REG_GENMASK(26, 24)
4074 #define   CURSOR_FORMAT_2C	REG_FIELD_PREP(CURSOR_FORMAT_MASK, 0)
4075 #define   CURSOR_FORMAT_3C	REG_FIELD_PREP(CURSOR_FORMAT_MASK, 1)
4076 #define   CURSOR_FORMAT_4C	REG_FIELD_PREP(CURSOR_FORMAT_MASK, 2)
4077 #define   CURSOR_FORMAT_ARGB	REG_FIELD_PREP(CURSOR_FORMAT_MASK, 4)
4078 #define   CURSOR_FORMAT_XRGB	REG_FIELD_PREP(CURSOR_FORMAT_MASK, 5)
4079 /* New style CUR*CNTR flags */
4080 #define   MCURSOR_ARB_SLOTS_MASK	REG_GENMASK(30, 28) /* icl+ */
4081 #define   MCURSOR_ARB_SLOTS(x)		REG_FIELD_PREP(MCURSOR_ARB_SLOTS_MASK, (x)) /* icl+ */
4082 #define   MCURSOR_PIPE_SEL_MASK		REG_GENMASK(29, 28)
4083 #define   MCURSOR_PIPE_SEL(pipe)	REG_FIELD_PREP(MCURSOR_PIPE_SEL_MASK, (pipe))
4084 #define   MCURSOR_PIPE_GAMMA_ENABLE	REG_BIT(26)
4085 #define   MCURSOR_PIPE_CSC_ENABLE	REG_BIT(24) /* ilk+ */
4086 #define   MCURSOR_ROTATE_180		REG_BIT(15)
4087 #define   MCURSOR_TRICKLE_FEED_DISABLE	REG_BIT(14)
4088 #define   MCURSOR_MODE_MASK		0x27
4089 #define   MCURSOR_MODE_DISABLE		0x00
4090 #define   MCURSOR_MODE_128_32B_AX	0x02
4091 #define   MCURSOR_MODE_256_32B_AX	0x03
4092 #define   MCURSOR_MODE_64_32B_AX	0x07
4093 #define   MCURSOR_MODE_128_ARGB_AX	(0x20 | MCURSOR_MODE_128_32B_AX)
4094 #define   MCURSOR_MODE_256_ARGB_AX	(0x20 | MCURSOR_MODE_256_32B_AX)
4095 #define   MCURSOR_MODE_64_ARGB_AX	(0x20 | MCURSOR_MODE_64_32B_AX)
4096 #define _CURABASE		0x70084
4097 #define _CURAPOS		0x70088
4098 #define   CURSOR_POS_Y_SIGN		REG_BIT(31)
4099 #define   CURSOR_POS_Y_MASK		REG_GENMASK(30, 16)
4100 #define   CURSOR_POS_Y(y)		REG_FIELD_PREP(CURSOR_POS_Y_MASK, (y))
4101 #define   CURSOR_POS_X_SIGN		REG_BIT(15)
4102 #define   CURSOR_POS_X_MASK		REG_GENMASK(14, 0)
4103 #define   CURSOR_POS_X(x)		REG_FIELD_PREP(CURSOR_POS_X_MASK, (x))
4104 #define _CURASIZE		0x700a0 /* 845/865 */
4105 #define   CURSOR_HEIGHT_MASK		REG_GENMASK(21, 12)
4106 #define   CURSOR_HEIGHT(h)		REG_FIELD_PREP(CURSOR_HEIGHT_MASK, (h))
4107 #define   CURSOR_WIDTH_MASK		REG_GENMASK(9, 0)
4108 #define   CURSOR_WIDTH(w)		REG_FIELD_PREP(CURSOR_WIDTH_MASK, (w))
4109 #define _CUR_FBC_CTL_A		0x700a0 /* ivb+ */
4110 #define   CUR_FBC_EN			REG_BIT(31)
4111 #define   CUR_FBC_HEIGHT_MASK		REG_GENMASK(7, 0)
4112 #define   CUR_FBC_HEIGHT(h)		REG_FIELD_PREP(CUR_FBC_HEIGHT_MASK, (h))
4113 #define _CURASURFLIVE		0x700ac /* g4x+ */
4114 #define _CURBCNTR		0x700c0
4115 #define _CURBBASE		0x700c4
4116 #define _CURBPOS		0x700c8
4117 
4118 #define _CURBCNTR_IVB		0x71080
4119 #define _CURBBASE_IVB		0x71084
4120 #define _CURBPOS_IVB		0x71088
4121 
4122 #define CURCNTR(pipe) _MMIO_CURSOR2(pipe, _CURACNTR)
4123 #define CURBASE(pipe) _MMIO_CURSOR2(pipe, _CURABASE)
4124 #define CURPOS(pipe) _MMIO_CURSOR2(pipe, _CURAPOS)
4125 #define CURSIZE(pipe) _MMIO_CURSOR2(pipe, _CURASIZE)
4126 #define CUR_FBC_CTL(pipe) _MMIO_CURSOR2(pipe, _CUR_FBC_CTL_A)
4127 #define CURSURFLIVE(pipe) _MMIO_CURSOR2(pipe, _CURASURFLIVE)
4128 
4129 #define CURSOR_A_OFFSET 0x70080
4130 #define CURSOR_B_OFFSET 0x700c0
4131 #define CHV_CURSOR_C_OFFSET 0x700e0
4132 #define IVB_CURSOR_B_OFFSET 0x71080
4133 #define IVB_CURSOR_C_OFFSET 0x72080
4134 #define TGL_CURSOR_D_OFFSET 0x73080
4135 
4136 /* Display A control */
4137 #define _DSPAADDR_VLV				0x7017C /* vlv/chv */
4138 #define _DSPACNTR				0x70180
4139 #define   DISP_ENABLE			REG_BIT(31)
4140 #define   DISP_PIPE_GAMMA_ENABLE	REG_BIT(30)
4141 #define   DISP_FORMAT_MASK		REG_GENMASK(29, 26)
4142 #define   DISP_FORMAT_8BPP		REG_FIELD_PREP(DISP_FORMAT_MASK, 2)
4143 #define   DISP_FORMAT_BGRA555		REG_FIELD_PREP(DISP_FORMAT_MASK, 3)
4144 #define   DISP_FORMAT_BGRX555		REG_FIELD_PREP(DISP_FORMAT_MASK, 4)
4145 #define   DISP_FORMAT_BGRX565		REG_FIELD_PREP(DISP_FORMAT_MASK, 5)
4146 #define   DISP_FORMAT_BGRX888		REG_FIELD_PREP(DISP_FORMAT_MASK, 6)
4147 #define   DISP_FORMAT_BGRA888		REG_FIELD_PREP(DISP_FORMAT_MASK, 7)
4148 #define   DISP_FORMAT_RGBX101010	REG_FIELD_PREP(DISP_FORMAT_MASK, 8)
4149 #define   DISP_FORMAT_RGBA101010	REG_FIELD_PREP(DISP_FORMAT_MASK, 9)
4150 #define   DISP_FORMAT_BGRX101010	REG_FIELD_PREP(DISP_FORMAT_MASK, 10)
4151 #define   DISP_FORMAT_BGRA101010	REG_FIELD_PREP(DISP_FORMAT_MASK, 11)
4152 #define   DISP_FORMAT_RGBX161616	REG_FIELD_PREP(DISP_FORMAT_MASK, 12)
4153 #define   DISP_FORMAT_RGBX888		REG_FIELD_PREP(DISP_FORMAT_MASK, 14)
4154 #define   DISP_FORMAT_RGBA888		REG_FIELD_PREP(DISP_FORMAT_MASK, 15)
4155 #define   DISP_STEREO_ENABLE		REG_BIT(25)
4156 #define   DISP_PIPE_CSC_ENABLE		REG_BIT(24) /* ilk+ */
4157 #define   DISP_PIPE_SEL_MASK		REG_GENMASK(25, 24)
4158 #define   DISP_PIPE_SEL(pipe)		REG_FIELD_PREP(DISP_PIPE_SEL_MASK, (pipe))
4159 #define   DISP_SRC_KEY_ENABLE		REG_BIT(22)
4160 #define   DISP_LINE_DOUBLE		REG_BIT(20)
4161 #define   DISP_STEREO_POLARITY_SECOND	REG_BIT(18)
4162 #define   DISP_ALPHA_PREMULTIPLY	REG_BIT(16) /* CHV pipe B */
4163 #define   DISP_ROTATE_180		REG_BIT(15)
4164 #define   DISP_TRICKLE_FEED_DISABLE	REG_BIT(14) /* g4x+ */
4165 #define   DISP_TILED			REG_BIT(10)
4166 #define   DISP_ASYNC_FLIP		REG_BIT(9) /* g4x+ */
4167 #define   DISP_MIRROR			REG_BIT(8) /* CHV pipe B */
4168 #define _DSPAADDR				0x70184
4169 #define _DSPASTRIDE				0x70188
4170 #define _DSPAPOS				0x7018C /* reserved */
4171 #define   DISP_POS_Y_MASK		REG_GENMASK(31, 16)
4172 #define   DISP_POS_Y(y)			REG_FIELD_PREP(DISP_POS_Y_MASK, (y))
4173 #define   DISP_POS_X_MASK		REG_GENMASK(15, 0)
4174 #define   DISP_POS_X(x)			REG_FIELD_PREP(DISP_POS_X_MASK, (x))
4175 #define _DSPASIZE				0x70190
4176 #define   DISP_HEIGHT_MASK		REG_GENMASK(31, 16)
4177 #define   DISP_HEIGHT(h)		REG_FIELD_PREP(DISP_HEIGHT_MASK, (h))
4178 #define   DISP_WIDTH_MASK		REG_GENMASK(15, 0)
4179 #define   DISP_WIDTH(w)			REG_FIELD_PREP(DISP_WIDTH_MASK, (w))
4180 #define _DSPASURF				0x7019C /* 965+ only */
4181 #define   DISP_ADDR_MASK		REG_GENMASK(31, 12)
4182 #define _DSPATILEOFF				0x701A4 /* 965+ only */
4183 #define   DISP_OFFSET_Y_MASK		REG_GENMASK(31, 16)
4184 #define   DISP_OFFSET_Y(y)		REG_FIELD_PREP(DISP_OFFSET_Y_MASK, (y))
4185 #define   DISP_OFFSET_X_MASK		REG_GENMASK(15, 0)
4186 #define   DISP_OFFSET_X(x)		REG_FIELD_PREP(DISP_OFFSET_X_MASK, (x))
4187 #define _DSPAOFFSET				0x701A4 /* HSW */
4188 #define _DSPASURFLIVE				0x701AC
4189 #define _DSPAGAMC				0x701E0
4190 
4191 #define DSPADDR_VLV(plane)	_MMIO_PIPE2(plane, _DSPAADDR_VLV)
4192 #define DSPCNTR(plane)		_MMIO_PIPE2(plane, _DSPACNTR)
4193 #define DSPADDR(plane)		_MMIO_PIPE2(plane, _DSPAADDR)
4194 #define DSPSTRIDE(plane)	_MMIO_PIPE2(plane, _DSPASTRIDE)
4195 #define DSPPOS(plane)		_MMIO_PIPE2(plane, _DSPAPOS)
4196 #define DSPSIZE(plane)		_MMIO_PIPE2(plane, _DSPASIZE)
4197 #define DSPSURF(plane)		_MMIO_PIPE2(plane, _DSPASURF)
4198 #define DSPTILEOFF(plane)	_MMIO_PIPE2(plane, _DSPATILEOFF)
4199 #define DSPLINOFF(plane)	DSPADDR(plane)
4200 #define DSPOFFSET(plane)	_MMIO_PIPE2(plane, _DSPAOFFSET)
4201 #define DSPSURFLIVE(plane)	_MMIO_PIPE2(plane, _DSPASURFLIVE)
4202 #define DSPGAMC(plane, i)	_MMIO_PIPE2(plane, _DSPAGAMC + (5 - (i)) * 4) /* plane C only, 6 x u0.8 */
4203 
4204 /* CHV pipe B blender and primary plane */
4205 #define _CHV_BLEND_A		0x60a00
4206 #define   CHV_BLEND_MASK	REG_GENMASK(31, 30)
4207 #define   CHV_BLEND_LEGACY	REG_FIELD_PREP(CHV_BLEND_MASK, 0)
4208 #define   CHV_BLEND_ANDROID	REG_FIELD_PREP(CHV_BLEND_MASK, 1)
4209 #define   CHV_BLEND_MPO		REG_FIELD_PREP(CHV_BLEND_MASK, 2)
4210 #define _CHV_CANVAS_A		0x60a04
4211 #define   CHV_CANVAS_RED_MASK	REG_GENMASK(29, 20)
4212 #define   CHV_CANVAS_GREEN_MASK	REG_GENMASK(19, 10)
4213 #define   CHV_CANVAS_BLUE_MASK	REG_GENMASK(9, 0)
4214 #define _PRIMPOS_A		0x60a08
4215 #define   PRIM_POS_Y_MASK	REG_GENMASK(31, 16)
4216 #define   PRIM_POS_Y(y)		REG_FIELD_PREP(PRIM_POS_Y_MASK, (y))
4217 #define   PRIM_POS_X_MASK	REG_GENMASK(15, 0)
4218 #define   PRIM_POS_X(x)		REG_FIELD_PREP(PRIM_POS_X_MASK, (x))
4219 #define _PRIMSIZE_A		0x60a0c
4220 #define   PRIM_HEIGHT_MASK	REG_GENMASK(31, 16)
4221 #define   PRIM_HEIGHT(h)	REG_FIELD_PREP(PRIM_HEIGHT_MASK, (h))
4222 #define   PRIM_WIDTH_MASK	REG_GENMASK(15, 0)
4223 #define   PRIM_WIDTH(w)		REG_FIELD_PREP(PRIM_WIDTH_MASK, (w))
4224 #define _PRIMCNSTALPHA_A	0x60a10
4225 #define   PRIM_CONST_ALPHA_ENABLE	REG_BIT(31)
4226 #define   PRIM_CONST_ALPHA_MASK		REG_GENMASK(7, 0)
4227 #define   PRIM_CONST_ALPHA(alpha)	REG_FIELD_PREP(PRIM_CONST_ALPHA_MASK, (alpha))
4228 
4229 #define CHV_BLEND(pipe)		_MMIO_TRANS2(pipe, _CHV_BLEND_A)
4230 #define CHV_CANVAS(pipe)	_MMIO_TRANS2(pipe, _CHV_CANVAS_A)
4231 #define PRIMPOS(plane)		_MMIO_TRANS2(plane, _PRIMPOS_A)
4232 #define PRIMSIZE(plane)		_MMIO_TRANS2(plane, _PRIMSIZE_A)
4233 #define PRIMCNSTALPHA(plane)	_MMIO_TRANS2(plane, _PRIMCNSTALPHA_A)
4234 
4235 /* Display/Sprite base address macros */
4236 #define DISP_BASEADDR_MASK	(0xfffff000)
4237 #define I915_LO_DISPBASE(val)	((val) & ~DISP_BASEADDR_MASK)
4238 #define I915_HI_DISPBASE(val)	((val) & DISP_BASEADDR_MASK)
4239 
4240 /*
4241  * VBIOS flags
4242  * gen2:
4243  * [00:06] alm,mgm
4244  * [10:16] all
4245  * [30:32] alm,mgm
4246  * gen3+:
4247  * [00:0f] all
4248  * [10:1f] all
4249  * [30:32] all
4250  */
4251 #define SWF0(i)	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70410 + (i) * 4)
4252 #define SWF1(i)	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x71410 + (i) * 4)
4253 #define SWF3(i)	_MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x72414 + (i) * 4)
4254 #define SWF_ILK(i)	_MMIO(0x4F000 + (i) * 4)
4255 
4256 /* Pipe B */
4257 #define _PIPEBDSL		(DISPLAY_MMIO_BASE(dev_priv) + 0x71000)
4258 #define _PIPEBCONF		(DISPLAY_MMIO_BASE(dev_priv) + 0x71008)
4259 #define _PIPEBSTAT		(DISPLAY_MMIO_BASE(dev_priv) + 0x71024)
4260 #define _PIPEBFRAMEHIGH		0x71040
4261 #define _PIPEBFRAMEPIXEL	0x71044
4262 #define _PIPEB_FRMCOUNT_G4X	(DISPLAY_MMIO_BASE(dev_priv) + 0x71040)
4263 #define _PIPEB_FLIPCOUNT_G4X	(DISPLAY_MMIO_BASE(dev_priv) + 0x71044)
4264 
4265 
4266 /* Display B control */
4267 #define _DSPBCNTR		(DISPLAY_MMIO_BASE(dev_priv) + 0x71180)
4268 #define   DISP_ALPHA_TRANS_ENABLE	REG_BIT(15)
4269 #define   DISP_SPRITE_ABOVE_OVERLAY	REG_BIT(0)
4270 #define _DSPBADDR		(DISPLAY_MMIO_BASE(dev_priv) + 0x71184)
4271 #define _DSPBSTRIDE		(DISPLAY_MMIO_BASE(dev_priv) + 0x71188)
4272 #define _DSPBPOS		(DISPLAY_MMIO_BASE(dev_priv) + 0x7118C)
4273 #define _DSPBSIZE		(DISPLAY_MMIO_BASE(dev_priv) + 0x71190)
4274 #define _DSPBSURF		(DISPLAY_MMIO_BASE(dev_priv) + 0x7119C)
4275 #define _DSPBTILEOFF		(DISPLAY_MMIO_BASE(dev_priv) + 0x711A4)
4276 #define _DSPBOFFSET		(DISPLAY_MMIO_BASE(dev_priv) + 0x711A4)
4277 #define _DSPBSURFLIVE		(DISPLAY_MMIO_BASE(dev_priv) + 0x711AC)
4278 
4279 /* ICL DSI 0 and 1 */
4280 #define _PIPEDSI0CONF		0x7b008
4281 #define _PIPEDSI1CONF		0x7b808
4282 
4283 /* Sprite A control */
4284 #define _DVSACNTR		0x72180
4285 #define   DVS_ENABLE			REG_BIT(31)
4286 #define   DVS_PIPE_GAMMA_ENABLE		REG_BIT(30)
4287 #define   DVS_YUV_RANGE_CORRECTION_DISABLE	REG_BIT(27)
4288 #define   DVS_FORMAT_MASK		REG_GENMASK(26, 25)
4289 #define   DVS_FORMAT_YUV422		REG_FIELD_PREP(DVS_FORMAT_MASK, 0)
4290 #define   DVS_FORMAT_RGBX101010		REG_FIELD_PREP(DVS_FORMAT_MASK, 1)
4291 #define   DVS_FORMAT_RGBX888		REG_FIELD_PREP(DVS_FORMAT_MASK, 2)
4292 #define   DVS_FORMAT_RGBX161616		REG_FIELD_PREP(DVS_FORMAT_MASK, 3)
4293 #define   DVS_PIPE_CSC_ENABLE		REG_BIT(24)
4294 #define   DVS_SOURCE_KEY		REG_BIT(22)
4295 #define   DVS_RGB_ORDER_XBGR		REG_BIT(20)
4296 #define   DVS_YUV_FORMAT_BT709		REG_BIT(18)
4297 #define   DVS_YUV_ORDER_MASK		REG_GENMASK(17, 16)
4298 #define   DVS_YUV_ORDER_YUYV		REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 0)
4299 #define   DVS_YUV_ORDER_UYVY		REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 1)
4300 #define   DVS_YUV_ORDER_YVYU		REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 2)
4301 #define   DVS_YUV_ORDER_VYUY		REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 3)
4302 #define   DVS_ROTATE_180		REG_BIT(15)
4303 #define   DVS_TRICKLE_FEED_DISABLE	REG_BIT(14)
4304 #define   DVS_TILED			REG_BIT(10)
4305 #define   DVS_DEST_KEY			REG_BIT(2)
4306 #define _DVSALINOFF		0x72184
4307 #define _DVSASTRIDE		0x72188
4308 #define _DVSAPOS		0x7218c
4309 #define   DVS_POS_Y_MASK		REG_GENMASK(31, 16)
4310 #define   DVS_POS_Y(y)			REG_FIELD_PREP(DVS_POS_Y_MASK, (y))
4311 #define   DVS_POS_X_MASK		REG_GENMASK(15, 0)
4312 #define   DVS_POS_X(x)			REG_FIELD_PREP(DVS_POS_X_MASK, (x))
4313 #define _DVSASIZE		0x72190
4314 #define   DVS_HEIGHT_MASK		REG_GENMASK(31, 16)
4315 #define   DVS_HEIGHT(h)			REG_FIELD_PREP(DVS_HEIGHT_MASK, (h))
4316 #define   DVS_WIDTH_MASK		REG_GENMASK(15, 0)
4317 #define   DVS_WIDTH(w)			REG_FIELD_PREP(DVS_WIDTH_MASK, (w))
4318 #define _DVSAKEYVAL		0x72194
4319 #define _DVSAKEYMSK		0x72198
4320 #define _DVSASURF		0x7219c
4321 #define   DVS_ADDR_MASK			REG_GENMASK(31, 12)
4322 #define _DVSAKEYMAXVAL		0x721a0
4323 #define _DVSATILEOFF		0x721a4
4324 #define   DVS_OFFSET_Y_MASK		REG_GENMASK(31, 16)
4325 #define   DVS_OFFSET_Y(y)		REG_FIELD_PREP(DVS_OFFSET_Y_MASK, (y))
4326 #define   DVS_OFFSET_X_MASK		REG_GENMASK(15, 0)
4327 #define   DVS_OFFSET_X(x)		REG_FIELD_PREP(DVS_OFFSET_X_MASK, (x))
4328 #define _DVSASURFLIVE		0x721ac
4329 #define _DVSAGAMC_G4X		0x721e0 /* g4x */
4330 #define _DVSASCALE		0x72204
4331 #define   DVS_SCALE_ENABLE		REG_BIT(31)
4332 #define   DVS_FILTER_MASK		REG_GENMASK(30, 29)
4333 #define   DVS_FILTER_MEDIUM		REG_FIELD_PREP(DVS_FILTER_MASK, 0)
4334 #define   DVS_FILTER_ENHANCING		REG_FIELD_PREP(DVS_FILTER_MASK, 1)
4335 #define   DVS_FILTER_SOFTENING		REG_FIELD_PREP(DVS_FILTER_MASK, 2)
4336 #define   DVS_VERTICAL_OFFSET_HALF	REG_BIT(28) /* must be enabled below */
4337 #define   DVS_VERTICAL_OFFSET_ENABLE	REG_BIT(27)
4338 #define   DVS_SRC_WIDTH_MASK		REG_GENMASK(26, 16)
4339 #define   DVS_SRC_WIDTH(w)		REG_FIELD_PREP(DVS_SRC_WIDTH_MASK, (w))
4340 #define   DVS_SRC_HEIGHT_MASK		REG_GENMASK(10, 0)
4341 #define   DVS_SRC_HEIGHT(h)		REG_FIELD_PREP(DVS_SRC_HEIGHT_MASK, (h))
4342 #define _DVSAGAMC_ILK		0x72300 /* ilk/snb */
4343 #define _DVSAGAMCMAX_ILK	0x72340 /* ilk/snb */
4344 
4345 #define _DVSBCNTR		0x73180
4346 #define _DVSBLINOFF		0x73184
4347 #define _DVSBSTRIDE		0x73188
4348 #define _DVSBPOS		0x7318c
4349 #define _DVSBSIZE		0x73190
4350 #define _DVSBKEYVAL		0x73194
4351 #define _DVSBKEYMSK		0x73198
4352 #define _DVSBSURF		0x7319c
4353 #define _DVSBKEYMAXVAL		0x731a0
4354 #define _DVSBTILEOFF		0x731a4
4355 #define _DVSBSURFLIVE		0x731ac
4356 #define _DVSBGAMC_G4X		0x731e0 /* g4x */
4357 #define _DVSBSCALE		0x73204
4358 #define _DVSBGAMC_ILK		0x73300 /* ilk/snb */
4359 #define _DVSBGAMCMAX_ILK	0x73340 /* ilk/snb */
4360 
4361 #define DVSCNTR(pipe) _MMIO_PIPE(pipe, _DVSACNTR, _DVSBCNTR)
4362 #define DVSLINOFF(pipe) _MMIO_PIPE(pipe, _DVSALINOFF, _DVSBLINOFF)
4363 #define DVSSTRIDE(pipe) _MMIO_PIPE(pipe, _DVSASTRIDE, _DVSBSTRIDE)
4364 #define DVSPOS(pipe) _MMIO_PIPE(pipe, _DVSAPOS, _DVSBPOS)
4365 #define DVSSURF(pipe) _MMIO_PIPE(pipe, _DVSASURF, _DVSBSURF)
4366 #define DVSKEYMAX(pipe) _MMIO_PIPE(pipe, _DVSAKEYMAXVAL, _DVSBKEYMAXVAL)
4367 #define DVSSIZE(pipe) _MMIO_PIPE(pipe, _DVSASIZE, _DVSBSIZE)
4368 #define DVSSCALE(pipe) _MMIO_PIPE(pipe, _DVSASCALE, _DVSBSCALE)
4369 #define DVSTILEOFF(pipe) _MMIO_PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
4370 #define DVSKEYVAL(pipe) _MMIO_PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
4371 #define DVSKEYMSK(pipe) _MMIO_PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
4372 #define DVSSURFLIVE(pipe) _MMIO_PIPE(pipe, _DVSASURFLIVE, _DVSBSURFLIVE)
4373 #define DVSGAMC_G4X(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMC_G4X, _DVSBGAMC_G4X) + (5 - (i)) * 4) /* 6 x u0.8 */
4374 #define DVSGAMC_ILK(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMC_ILK, _DVSBGAMC_ILK) + (i) * 4) /* 16 x u0.10 */
4375 #define DVSGAMCMAX_ILK(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMCMAX_ILK, _DVSBGAMCMAX_ILK) + (i) * 4) /* 3 x u1.10 */
4376 
4377 #define _SPRA_CTL		0x70280
4378 #define   SPRITE_ENABLE				REG_BIT(31)
4379 #define   SPRITE_PIPE_GAMMA_ENABLE		REG_BIT(30)
4380 #define   SPRITE_YUV_RANGE_CORRECTION_DISABLE	REG_BIT(28)
4381 #define   SPRITE_FORMAT_MASK			REG_GENMASK(27, 25)
4382 #define   SPRITE_FORMAT_YUV422			REG_FIELD_PREP(SPRITE_FORMAT_MASK, 0)
4383 #define   SPRITE_FORMAT_RGBX101010		REG_FIELD_PREP(SPRITE_FORMAT_MASK, 1)
4384 #define   SPRITE_FORMAT_RGBX888			REG_FIELD_PREP(SPRITE_FORMAT_MASK, 2)
4385 #define   SPRITE_FORMAT_RGBX161616		REG_FIELD_PREP(SPRITE_FORMAT_MASK, 3)
4386 #define   SPRITE_FORMAT_YUV444			REG_FIELD_PREP(SPRITE_FORMAT_MASK, 4)
4387 #define   SPRITE_FORMAT_XR_BGR101010		REG_FIELD_PREP(SPRITE_FORMAT_MASK, 5) /* Extended range */
4388 #define   SPRITE_PIPE_CSC_ENABLE		REG_BIT(24)
4389 #define   SPRITE_SOURCE_KEY			REG_BIT(22)
4390 #define   SPRITE_RGB_ORDER_RGBX			REG_BIT(20) /* only for 888 and 161616 */
4391 #define   SPRITE_YUV_TO_RGB_CSC_DISABLE		REG_BIT(19)
4392 #define   SPRITE_YUV_TO_RGB_CSC_FORMAT_BT709	REG_BIT(18) /* 0 is BT601 */
4393 #define   SPRITE_YUV_ORDER_MASK			REG_GENMASK(17, 16)
4394 #define   SPRITE_YUV_ORDER_YUYV			REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 0)
4395 #define   SPRITE_YUV_ORDER_UYVY			REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 1)
4396 #define   SPRITE_YUV_ORDER_YVYU			REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 2)
4397 #define   SPRITE_YUV_ORDER_VYUY			REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 3)
4398 #define   SPRITE_ROTATE_180			REG_BIT(15)
4399 #define   SPRITE_TRICKLE_FEED_DISABLE		REG_BIT(14)
4400 #define   SPRITE_PLANE_GAMMA_DISABLE		REG_BIT(13)
4401 #define   SPRITE_TILED				REG_BIT(10)
4402 #define   SPRITE_DEST_KEY			REG_BIT(2)
4403 #define _SPRA_LINOFF		0x70284
4404 #define _SPRA_STRIDE		0x70288
4405 #define _SPRA_POS		0x7028c
4406 #define   SPRITE_POS_Y_MASK	REG_GENMASK(31, 16)
4407 #define   SPRITE_POS_Y(y)	REG_FIELD_PREP(SPRITE_POS_Y_MASK, (y))
4408 #define   SPRITE_POS_X_MASK	REG_GENMASK(15, 0)
4409 #define   SPRITE_POS_X(x)	REG_FIELD_PREP(SPRITE_POS_X_MASK, (x))
4410 #define _SPRA_SIZE		0x70290
4411 #define   SPRITE_HEIGHT_MASK	REG_GENMASK(31, 16)
4412 #define   SPRITE_HEIGHT(h)	REG_FIELD_PREP(SPRITE_HEIGHT_MASK, (h))
4413 #define   SPRITE_WIDTH_MASK	REG_GENMASK(15, 0)
4414 #define   SPRITE_WIDTH(w)	REG_FIELD_PREP(SPRITE_WIDTH_MASK, (w))
4415 #define _SPRA_KEYVAL		0x70294
4416 #define _SPRA_KEYMSK		0x70298
4417 #define _SPRA_SURF		0x7029c
4418 #define   SPRITE_ADDR_MASK	REG_GENMASK(31, 12)
4419 #define _SPRA_KEYMAX		0x702a0
4420 #define _SPRA_TILEOFF		0x702a4
4421 #define   SPRITE_OFFSET_Y_MASK	REG_GENMASK(31, 16)
4422 #define   SPRITE_OFFSET_Y(y)	REG_FIELD_PREP(SPRITE_OFFSET_Y_MASK, (y))
4423 #define   SPRITE_OFFSET_X_MASK	REG_GENMASK(15, 0)
4424 #define   SPRITE_OFFSET_X(x)	REG_FIELD_PREP(SPRITE_OFFSET_X_MASK, (x))
4425 #define _SPRA_OFFSET		0x702a4
4426 #define _SPRA_SURFLIVE		0x702ac
4427 #define _SPRA_SCALE		0x70304
4428 #define   SPRITE_SCALE_ENABLE			REG_BIT(31)
4429 #define   SPRITE_FILTER_MASK			REG_GENMASK(30, 29)
4430 #define   SPRITE_FILTER_MEDIUM			REG_FIELD_PREP(SPRITE_FILTER_MASK, 0)
4431 #define   SPRITE_FILTER_ENHANCING		REG_FIELD_PREP(SPRITE_FILTER_MASK, 1)
4432 #define   SPRITE_FILTER_SOFTENING		REG_FIELD_PREP(SPRITE_FILTER_MASK, 2)
4433 #define   SPRITE_VERTICAL_OFFSET_HALF		REG_BIT(28) /* must be enabled below */
4434 #define   SPRITE_VERTICAL_OFFSET_ENABLE		REG_BIT(27)
4435 #define   SPRITE_SRC_WIDTH_MASK			REG_GENMASK(26, 16)
4436 #define   SPRITE_SRC_WIDTH(w)			REG_FIELD_PREP(SPRITE_SRC_WIDTH_MASK, (w))
4437 #define   SPRITE_SRC_HEIGHT_MASK		REG_GENMASK(10, 0)
4438 #define   SPRITE_SRC_HEIGHT(h)			REG_FIELD_PREP(SPRITE_SRC_HEIGHT_MASK, (h))
4439 #define _SPRA_GAMC		0x70400
4440 #define _SPRA_GAMC16		0x70440
4441 #define _SPRA_GAMC17		0x7044c
4442 
4443 #define _SPRB_CTL		0x71280
4444 #define _SPRB_LINOFF		0x71284
4445 #define _SPRB_STRIDE		0x71288
4446 #define _SPRB_POS		0x7128c
4447 #define _SPRB_SIZE		0x71290
4448 #define _SPRB_KEYVAL		0x71294
4449 #define _SPRB_KEYMSK		0x71298
4450 #define _SPRB_SURF		0x7129c
4451 #define _SPRB_KEYMAX		0x712a0
4452 #define _SPRB_TILEOFF		0x712a4
4453 #define _SPRB_OFFSET		0x712a4
4454 #define _SPRB_SURFLIVE		0x712ac
4455 #define _SPRB_SCALE		0x71304
4456 #define _SPRB_GAMC		0x71400
4457 #define _SPRB_GAMC16		0x71440
4458 #define _SPRB_GAMC17		0x7144c
4459 
4460 #define SPRCTL(pipe) _MMIO_PIPE(pipe, _SPRA_CTL, _SPRB_CTL)
4461 #define SPRLINOFF(pipe) _MMIO_PIPE(pipe, _SPRA_LINOFF, _SPRB_LINOFF)
4462 #define SPRSTRIDE(pipe) _MMIO_PIPE(pipe, _SPRA_STRIDE, _SPRB_STRIDE)
4463 #define SPRPOS(pipe) _MMIO_PIPE(pipe, _SPRA_POS, _SPRB_POS)
4464 #define SPRSIZE(pipe) _MMIO_PIPE(pipe, _SPRA_SIZE, _SPRB_SIZE)
4465 #define SPRKEYVAL(pipe) _MMIO_PIPE(pipe, _SPRA_KEYVAL, _SPRB_KEYVAL)
4466 #define SPRKEYMSK(pipe) _MMIO_PIPE(pipe, _SPRA_KEYMSK, _SPRB_KEYMSK)
4467 #define SPRSURF(pipe) _MMIO_PIPE(pipe, _SPRA_SURF, _SPRB_SURF)
4468 #define SPRKEYMAX(pipe) _MMIO_PIPE(pipe, _SPRA_KEYMAX, _SPRB_KEYMAX)
4469 #define SPRTILEOFF(pipe) _MMIO_PIPE(pipe, _SPRA_TILEOFF, _SPRB_TILEOFF)
4470 #define SPROFFSET(pipe) _MMIO_PIPE(pipe, _SPRA_OFFSET, _SPRB_OFFSET)
4471 #define SPRSCALE(pipe) _MMIO_PIPE(pipe, _SPRA_SCALE, _SPRB_SCALE)
4472 #define SPRGAMC(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC) + (i) * 4) /* 16 x u0.10 */
4473 #define SPRGAMC16(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC16, _SPRB_GAMC16) + (i) * 4) /* 3 x u1.10 */
4474 #define SPRGAMC17(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC17, _SPRB_GAMC17) + (i) * 4) /* 3 x u2.10 */
4475 #define SPRSURFLIVE(pipe) _MMIO_PIPE(pipe, _SPRA_SURFLIVE, _SPRB_SURFLIVE)
4476 
4477 #define _SPACNTR		(VLV_DISPLAY_BASE + 0x72180)
4478 #define   SP_ENABLE			REG_BIT(31)
4479 #define   SP_PIPE_GAMMA_ENABLE		REG_BIT(30)
4480 #define   SP_FORMAT_MASK		REG_GENMASK(29, 26)
4481 #define   SP_FORMAT_YUV422		REG_FIELD_PREP(SP_FORMAT_MASK, 0)
4482 #define   SP_FORMAT_8BPP		REG_FIELD_PREP(SP_FORMAT_MASK, 2)
4483 #define   SP_FORMAT_BGR565		REG_FIELD_PREP(SP_FORMAT_MASK, 5)
4484 #define   SP_FORMAT_BGRX8888		REG_FIELD_PREP(SP_FORMAT_MASK, 6)
4485 #define   SP_FORMAT_BGRA8888		REG_FIELD_PREP(SP_FORMAT_MASK, 7)
4486 #define   SP_FORMAT_RGBX1010102		REG_FIELD_PREP(SP_FORMAT_MASK, 8)
4487 #define   SP_FORMAT_RGBA1010102		REG_FIELD_PREP(SP_FORMAT_MASK, 9)
4488 #define   SP_FORMAT_BGRX1010102		REG_FIELD_PREP(SP_FORMAT_MASK, 10) /* CHV pipe B */
4489 #define   SP_FORMAT_BGRA1010102		REG_FIELD_PREP(SP_FORMAT_MASK, 11) /* CHV pipe B */
4490 #define   SP_FORMAT_RGBX8888		REG_FIELD_PREP(SP_FORMAT_MASK, 14)
4491 #define   SP_FORMAT_RGBA8888		REG_FIELD_PREP(SP_FORMAT_MASK, 15)
4492 #define   SP_ALPHA_PREMULTIPLY		REG_BIT(23) /* CHV pipe B */
4493 #define   SP_SOURCE_KEY			REG_BIT(22)
4494 #define   SP_YUV_FORMAT_BT709		REG_BIT(18)
4495 #define   SP_YUV_ORDER_MASK		REG_GENMASK(17, 16)
4496 #define   SP_YUV_ORDER_YUYV		REG_FIELD_PREP(SP_YUV_ORDER_MASK, 0)
4497 #define   SP_YUV_ORDER_UYVY		REG_FIELD_PREP(SP_YUV_ORDER_MASK, 1)
4498 #define   SP_YUV_ORDER_YVYU		REG_FIELD_PREP(SP_YUV_ORDER_MASK, 2)
4499 #define   SP_YUV_ORDER_VYUY		REG_FIELD_PREP(SP_YUV_ORDER_MASK, 3)
4500 #define   SP_ROTATE_180			REG_BIT(15)
4501 #define   SP_TILED			REG_BIT(10)
4502 #define   SP_MIRROR			REG_BIT(8) /* CHV pipe B */
4503 #define _SPALINOFF		(VLV_DISPLAY_BASE + 0x72184)
4504 #define _SPASTRIDE		(VLV_DISPLAY_BASE + 0x72188)
4505 #define _SPAPOS			(VLV_DISPLAY_BASE + 0x7218c)
4506 #define   SP_POS_Y_MASK			REG_GENMASK(31, 16)
4507 #define   SP_POS_Y(y)			REG_FIELD_PREP(SP_POS_Y_MASK, (y))
4508 #define   SP_POS_X_MASK			REG_GENMASK(15, 0)
4509 #define   SP_POS_X(x)			REG_FIELD_PREP(SP_POS_X_MASK, (x))
4510 #define _SPASIZE		(VLV_DISPLAY_BASE + 0x72190)
4511 #define   SP_HEIGHT_MASK		REG_GENMASK(31, 16)
4512 #define   SP_HEIGHT(h)			REG_FIELD_PREP(SP_HEIGHT_MASK, (h))
4513 #define   SP_WIDTH_MASK			REG_GENMASK(15, 0)
4514 #define   SP_WIDTH(w)			REG_FIELD_PREP(SP_WIDTH_MASK, (w))
4515 #define _SPAKEYMINVAL		(VLV_DISPLAY_BASE + 0x72194)
4516 #define _SPAKEYMSK		(VLV_DISPLAY_BASE + 0x72198)
4517 #define _SPASURF		(VLV_DISPLAY_BASE + 0x7219c)
4518 #define   SP_ADDR_MASK			REG_GENMASK(31, 12)
4519 #define _SPAKEYMAXVAL		(VLV_DISPLAY_BASE + 0x721a0)
4520 #define _SPATILEOFF		(VLV_DISPLAY_BASE + 0x721a4)
4521 #define   SP_OFFSET_Y_MASK		REG_GENMASK(31, 16)
4522 #define   SP_OFFSET_Y(y)		REG_FIELD_PREP(SP_OFFSET_Y_MASK, (y))
4523 #define   SP_OFFSET_X_MASK		REG_GENMASK(15, 0)
4524 #define   SP_OFFSET_X(x)		REG_FIELD_PREP(SP_OFFSET_X_MASK, (x))
4525 #define _SPACONSTALPHA		(VLV_DISPLAY_BASE + 0x721a8)
4526 #define   SP_CONST_ALPHA_ENABLE		REG_BIT(31)
4527 #define   SP_CONST_ALPHA_MASK		REG_GENMASK(7, 0)
4528 #define   SP_CONST_ALPHA(alpha)		REG_FIELD_PREP(SP_CONST_ALPHA_MASK, (alpha))
4529 #define _SPACLRC0		(VLV_DISPLAY_BASE + 0x721d0)
4530 #define   SP_CONTRAST_MASK		REG_GENMASK(26, 18)
4531 #define   SP_CONTRAST(x)		REG_FIELD_PREP(SP_CONTRAST_MASK, (x)) /* u3.6 */
4532 #define   SP_BRIGHTNESS_MASK		REG_GENMASK(7, 0)
4533 #define   SP_BRIGHTNESS(x)		REG_FIELD_PREP(SP_BRIGHTNESS_MASK, (x)) /* s8 */
4534 #define _SPACLRC1		(VLV_DISPLAY_BASE + 0x721d4)
4535 #define   SP_SH_SIN_MASK		REG_GENMASK(26, 16)
4536 #define   SP_SH_SIN(x)			REG_FIELD_PREP(SP_SH_SIN_MASK, (x)) /* s4.7 */
4537 #define   SP_SH_COS_MASK		REG_GENMASK(9, 0)
4538 #define   SP_SH_COS(x)			REG_FIELD_PREP(SP_SH_COS_MASK, (x)) /* u3.7 */
4539 #define _SPAGAMC		(VLV_DISPLAY_BASE + 0x721e0)
4540 
4541 #define _SPBCNTR		(VLV_DISPLAY_BASE + 0x72280)
4542 #define _SPBLINOFF		(VLV_DISPLAY_BASE + 0x72284)
4543 #define _SPBSTRIDE		(VLV_DISPLAY_BASE + 0x72288)
4544 #define _SPBPOS			(VLV_DISPLAY_BASE + 0x7228c)
4545 #define _SPBSIZE		(VLV_DISPLAY_BASE + 0x72290)
4546 #define _SPBKEYMINVAL		(VLV_DISPLAY_BASE + 0x72294)
4547 #define _SPBKEYMSK		(VLV_DISPLAY_BASE + 0x72298)
4548 #define _SPBSURF		(VLV_DISPLAY_BASE + 0x7229c)
4549 #define _SPBKEYMAXVAL		(VLV_DISPLAY_BASE + 0x722a0)
4550 #define _SPBTILEOFF		(VLV_DISPLAY_BASE + 0x722a4)
4551 #define _SPBCONSTALPHA		(VLV_DISPLAY_BASE + 0x722a8)
4552 #define _SPBCLRC0		(VLV_DISPLAY_BASE + 0x722d0)
4553 #define _SPBCLRC1		(VLV_DISPLAY_BASE + 0x722d4)
4554 #define _SPBGAMC		(VLV_DISPLAY_BASE + 0x722e0)
4555 
4556 #define _VLV_SPR(pipe, plane_id, reg_a, reg_b) \
4557 	_PIPE((pipe) * 2 + (plane_id) - PLANE_SPRITE0, (reg_a), (reg_b))
4558 #define _MMIO_VLV_SPR(pipe, plane_id, reg_a, reg_b) \
4559 	_MMIO(_VLV_SPR((pipe), (plane_id), (reg_a), (reg_b)))
4560 
4561 #define SPCNTR(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPACNTR, _SPBCNTR)
4562 #define SPLINOFF(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPALINOFF, _SPBLINOFF)
4563 #define SPSTRIDE(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPASTRIDE, _SPBSTRIDE)
4564 #define SPPOS(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPAPOS, _SPBPOS)
4565 #define SPSIZE(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPASIZE, _SPBSIZE)
4566 #define SPKEYMINVAL(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMINVAL, _SPBKEYMINVAL)
4567 #define SPKEYMSK(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMSK, _SPBKEYMSK)
4568 #define SPSURF(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPASURF, _SPBSURF)
4569 #define SPKEYMAXVAL(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMAXVAL, _SPBKEYMAXVAL)
4570 #define SPTILEOFF(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPATILEOFF, _SPBTILEOFF)
4571 #define SPCONSTALPHA(pipe, plane_id)	_MMIO_VLV_SPR((pipe), (plane_id), _SPACONSTALPHA, _SPBCONSTALPHA)
4572 #define SPCLRC0(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPACLRC0, _SPBCLRC0)
4573 #define SPCLRC1(pipe, plane_id)		_MMIO_VLV_SPR((pipe), (plane_id), _SPACLRC1, _SPBCLRC1)
4574 #define SPGAMC(pipe, plane_id, i)	_MMIO(_VLV_SPR((pipe), (plane_id), _SPAGAMC, _SPBGAMC) + (5 - (i)) * 4) /* 6 x u0.10 */
4575 
4576 /*
4577  * CHV pipe B sprite CSC
4578  *
4579  * |cr|   |c0 c1 c2|   |cr + cr_ioff|   |cr_ooff|
4580  * |yg| = |c3 c4 c5| x |yg + yg_ioff| + |yg_ooff|
4581  * |cb|   |c6 c7 c8|   |cb + cr_ioff|   |cb_ooff|
4582  */
4583 #define _MMIO_CHV_SPCSC(plane_id, reg) \
4584 	_MMIO(VLV_DISPLAY_BASE + ((plane_id) - PLANE_SPRITE0) * 0x1000 + (reg))
4585 
4586 #define SPCSCYGOFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d900)
4587 #define SPCSCCBOFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d904)
4588 #define SPCSCCROFF(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d908)
4589 #define  SPCSC_OOFF_MASK	REG_GENMASK(26, 16)
4590 #define  SPCSC_OOFF(x)		REG_FIELD_PREP(SPCSC_OOFF_MASK, (x) & 0x7ff) /* s11 */
4591 #define  SPCSC_IOFF_MASK	REG_GENMASK(10, 0)
4592 #define  SPCSC_IOFF(x)		REG_FIELD_PREP(SPCSC_IOFF_MASK, (x) & 0x7ff) /* s11 */
4593 
4594 #define SPCSCC01(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d90c)
4595 #define SPCSCC23(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d910)
4596 #define SPCSCC45(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d914)
4597 #define SPCSCC67(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d918)
4598 #define SPCSCC8(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d91c)
4599 #define  SPCSC_C1_MASK		REG_GENMASK(30, 16)
4600 #define  SPCSC_C1(x)		REG_FIELD_PREP(SPCSC_C1_MASK, (x) & 0x7fff) /* s3.12 */
4601 #define  SPCSC_C0_MASK		REG_GENMASK(14, 0)
4602 #define  SPCSC_C0(x)		REG_FIELD_PREP(SPCSC_C0_MASK, (x) & 0x7fff) /* s3.12 */
4603 
4604 #define SPCSCYGICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d920)
4605 #define SPCSCCBICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d924)
4606 #define SPCSCCRICLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d928)
4607 #define  SPCSC_IMAX_MASK	REG_GENMASK(26, 16)
4608 #define  SPCSC_IMAX(x)		REG_FIELD_PREP(SPCSC_IMAX_MASK, (x) & 0x7ff) /* s11 */
4609 #define  SPCSC_IMIN_MASK	REG_GENMASK(10, 0)
4610 #define  SPCSC_IMIN(x)		REG_FIELD_PREP(SPCSC_IMIN_MASK, (x) & 0x7ff) /* s11 */
4611 
4612 #define SPCSCYGOCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d92c)
4613 #define SPCSCCBOCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d930)
4614 #define SPCSCCROCLAMP(plane_id)	_MMIO_CHV_SPCSC(plane_id, 0x6d934)
4615 #define  SPCSC_OMAX_MASK	REG_GENMASK(25, 16)
4616 #define  SPCSC_OMAX(x)		REG_FIELD_PREP(SPCSC_OMAX_MASK, (x)) /* u10 */
4617 #define  SPCSC_OMIN_MASK	REG_GENMASK(9, 0)
4618 #define  SPCSC_OMIN(x)		REG_FIELD_PREP(SPCSC_OMIN_MASK, (x)) /* u10 */
4619 
4620 /* Skylake plane registers */
4621 
4622 #define _PLANE_CTL_1_A				0x70180
4623 #define _PLANE_CTL_2_A				0x70280
4624 #define _PLANE_CTL_3_A				0x70380
4625 #define   PLANE_CTL_ENABLE			REG_BIT(31)
4626 #define   PLANE_CTL_ARB_SLOTS_MASK		REG_GENMASK(30, 28) /* icl+ */
4627 #define   PLANE_CTL_ARB_SLOTS(x)		REG_FIELD_PREP(PLANE_CTL_ARB_SLOTS_MASK, (x)) /* icl+ */
4628 #define   PLANE_CTL_PIPE_GAMMA_ENABLE		REG_BIT(30) /* Pre-GLK */
4629 #define   PLANE_CTL_YUV_RANGE_CORRECTION_DISABLE	REG_BIT(28)
4630 /*
4631  * ICL+ uses the same PLANE_CTL_FORMAT bits, but the field definition
4632  * expanded to include bit 23 as well. However, the shift-24 based values
4633  * correctly map to the same formats in ICL, as long as bit 23 is set to 0
4634  */
4635 #define   PLANE_CTL_FORMAT_MASK_SKL		REG_GENMASK(27, 24) /* pre-icl */
4636 #define   PLANE_CTL_FORMAT_MASK_ICL		REG_GENMASK(27, 23) /* icl+ */
4637 #define   PLANE_CTL_FORMAT_YUV422		REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 0)
4638 #define   PLANE_CTL_FORMAT_NV12			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 1)
4639 #define   PLANE_CTL_FORMAT_XRGB_2101010		REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 2)
4640 #define   PLANE_CTL_FORMAT_P010			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 3)
4641 #define   PLANE_CTL_FORMAT_XRGB_8888		REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 4)
4642 #define   PLANE_CTL_FORMAT_P012			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 5)
4643 #define   PLANE_CTL_FORMAT_XRGB_16161616F	REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 6)
4644 #define   PLANE_CTL_FORMAT_P016			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 7)
4645 #define   PLANE_CTL_FORMAT_XYUV			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 8)
4646 #define   PLANE_CTL_FORMAT_INDEXED		REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 12)
4647 #define   PLANE_CTL_FORMAT_RGB_565		REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 14)
4648 #define   PLANE_CTL_FORMAT_Y210			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 1)
4649 #define   PLANE_CTL_FORMAT_Y212			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 3)
4650 #define   PLANE_CTL_FORMAT_Y216			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 5)
4651 #define   PLANE_CTL_FORMAT_Y410			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 7)
4652 #define   PLANE_CTL_FORMAT_Y412			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 9)
4653 #define   PLANE_CTL_FORMAT_Y416			REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 11)
4654 #define   PLANE_CTL_PIPE_CSC_ENABLE		REG_BIT(23) /* Pre-GLK */
4655 #define   PLANE_CTL_KEY_ENABLE_MASK		REG_GENMASK(22, 21)
4656 #define   PLANE_CTL_KEY_ENABLE_SOURCE		REG_FIELD_PREP(PLANE_CTL_KEY_ENABLE_MASK, 1)
4657 #define   PLANE_CTL_KEY_ENABLE_DESTINATION	REG_FIELD_PREP(PLANE_CTL_KEY_ENABLE_MASK, 2)
4658 #define   PLANE_CTL_ORDER_RGBX			REG_BIT(20)
4659 #define   PLANE_CTL_YUV420_Y_PLANE		REG_BIT(19)
4660 #define   PLANE_CTL_YUV_TO_RGB_CSC_FORMAT_BT709	REG_BIT(18)
4661 #define   PLANE_CTL_YUV422_ORDER_MASK		REG_GENMASK(17, 16)
4662 #define   PLANE_CTL_YUV422_ORDER_YUYV		REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 0)
4663 #define   PLANE_CTL_YUV422_ORDER_UYVY		REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 1)
4664 #define   PLANE_CTL_YUV422_ORDER_YVYU		REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 2)
4665 #define   PLANE_CTL_YUV422_ORDER_VYUY		REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 3)
4666 #define   PLANE_CTL_RENDER_DECOMPRESSION_ENABLE	REG_BIT(15)
4667 #define   PLANE_CTL_TRICKLE_FEED_DISABLE	REG_BIT(14)
4668 #define   PLANE_CTL_CLEAR_COLOR_DISABLE		REG_BIT(13) /* TGL+ */
4669 #define   PLANE_CTL_PLANE_GAMMA_DISABLE		REG_BIT(13) /* Pre-GLK */
4670 #define   PLANE_CTL_TILED_MASK			REG_GENMASK(12, 10)
4671 #define   PLANE_CTL_TILED_LINEAR		REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 0)
4672 #define   PLANE_CTL_TILED_X			REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 1)
4673 #define   PLANE_CTL_TILED_Y			REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 4)
4674 #define   PLANE_CTL_TILED_YF			REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 5)
4675 #define   PLANE_CTL_TILED_4                     REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 5)
4676 #define   PLANE_CTL_ASYNC_FLIP			REG_BIT(9)
4677 #define   PLANE_CTL_FLIP_HORIZONTAL		REG_BIT(8)
4678 #define   PLANE_CTL_MEDIA_DECOMPRESSION_ENABLE	REG_BIT(4) /* TGL+ */
4679 #define   PLANE_CTL_ALPHA_MASK			REG_GENMASK(5, 4) /* Pre-GLK */
4680 #define   PLANE_CTL_ALPHA_DISABLE		REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 0)
4681 #define   PLANE_CTL_ALPHA_SW_PREMULTIPLY	REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 2)
4682 #define   PLANE_CTL_ALPHA_HW_PREMULTIPLY	REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 3)
4683 #define   PLANE_CTL_ROTATE_MASK			REG_GENMASK(1, 0)
4684 #define   PLANE_CTL_ROTATE_0			REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 0)
4685 #define   PLANE_CTL_ROTATE_90			REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 1)
4686 #define   PLANE_CTL_ROTATE_180			REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 2)
4687 #define   PLANE_CTL_ROTATE_270			REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 3)
4688 #define _PLANE_STRIDE_1_A			0x70188
4689 #define _PLANE_STRIDE_2_A			0x70288
4690 #define _PLANE_STRIDE_3_A			0x70388
4691 #define   PLANE_STRIDE__MASK			REG_GENMASK(11, 0)
4692 #define   PLANE_STRIDE_(stride)			REG_FIELD_PREP(PLANE_STRIDE__MASK, (stride))
4693 #define _PLANE_POS_1_A				0x7018c
4694 #define _PLANE_POS_2_A				0x7028c
4695 #define _PLANE_POS_3_A				0x7038c
4696 #define   PLANE_POS_Y_MASK			REG_GENMASK(31, 16)
4697 #define   PLANE_POS_Y(y)			REG_FIELD_PREP(PLANE_POS_Y_MASK, (y))
4698 #define   PLANE_POS_X_MASK			REG_GENMASK(15, 0)
4699 #define   PLANE_POS_X(x)			REG_FIELD_PREP(PLANE_POS_X_MASK, (x))
4700 #define _PLANE_SIZE_1_A				0x70190
4701 #define _PLANE_SIZE_2_A				0x70290
4702 #define _PLANE_SIZE_3_A				0x70390
4703 #define   PLANE_HEIGHT_MASK			REG_GENMASK(31, 16)
4704 #define   PLANE_HEIGHT(h)			REG_FIELD_PREP(PLANE_HEIGHT_MASK, (h))
4705 #define   PLANE_WIDTH_MASK			REG_GENMASK(15, 0)
4706 #define   PLANE_WIDTH(w)			REG_FIELD_PREP(PLANE_WIDTH_MASK, (w))
4707 #define _PLANE_SURF_1_A				0x7019c
4708 #define _PLANE_SURF_2_A				0x7029c
4709 #define _PLANE_SURF_3_A				0x7039c
4710 #define   PLANE_SURF_ADDR_MASK			REG_GENMASK(31, 12)
4711 #define   PLANE_SURF_DECRYPT			REG_BIT(2)
4712 #define _PLANE_OFFSET_1_A			0x701a4
4713 #define _PLANE_OFFSET_2_A			0x702a4
4714 #define _PLANE_OFFSET_3_A			0x703a4
4715 #define   PLANE_OFFSET_Y_MASK			REG_GENMASK(31, 16)
4716 #define   PLANE_OFFSET_Y(y)			REG_FIELD_PREP(PLANE_OFFSET_Y_MASK, (y))
4717 #define   PLANE_OFFSET_X_MASK			REG_GENMASK(15, 0)
4718 #define   PLANE_OFFSET_X(x)			REG_FIELD_PREP(PLANE_OFFSET_X_MASK, (x))
4719 #define _PLANE_KEYVAL_1_A			0x70194
4720 #define _PLANE_KEYVAL_2_A			0x70294
4721 #define _PLANE_KEYMSK_1_A			0x70198
4722 #define _PLANE_KEYMSK_2_A			0x70298
4723 #define  PLANE_KEYMSK_ALPHA_ENABLE		(1 << 31)
4724 #define _PLANE_KEYMAX_1_A			0x701a0
4725 #define _PLANE_KEYMAX_2_A			0x702a0
4726 #define  PLANE_KEYMAX_ALPHA(a)			((a) << 24)
4727 #define _PLANE_CC_VAL_1_A			0x701b4
4728 #define _PLANE_CC_VAL_2_A			0x702b4
4729 #define _PLANE_AUX_DIST_1_A			0x701c0
4730 #define   PLANE_AUX_DISTANCE_MASK		REG_GENMASK(31, 12)
4731 #define   PLANE_AUX_STRIDE_MASK			REG_GENMASK(11, 0)
4732 #define   PLANE_AUX_STRIDE(stride)		REG_FIELD_PREP(PLANE_AUX_STRIDE_MASK, (stride))
4733 #define _PLANE_AUX_DIST_2_A			0x702c0
4734 #define _PLANE_AUX_OFFSET_1_A			0x701c4
4735 #define _PLANE_AUX_OFFSET_2_A			0x702c4
4736 #define _PLANE_CUS_CTL_1_A			0x701c8
4737 #define _PLANE_CUS_CTL_2_A			0x702c8
4738 #define   PLANE_CUS_ENABLE			REG_BIT(31)
4739 #define   PLANE_CUS_Y_PLANE_MASK			REG_BIT(30)
4740 #define   PLANE_CUS_Y_PLANE_4_RKL		REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 0)
4741 #define   PLANE_CUS_Y_PLANE_5_RKL		REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 1)
4742 #define   PLANE_CUS_Y_PLANE_6_ICL		REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 0)
4743 #define   PLANE_CUS_Y_PLANE_7_ICL		REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 1)
4744 #define   PLANE_CUS_HPHASE_SIGN_NEGATIVE		REG_BIT(19)
4745 #define   PLANE_CUS_HPHASE_MASK			REG_GENMASK(17, 16)
4746 #define   PLANE_CUS_HPHASE_0			REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 0)
4747 #define   PLANE_CUS_HPHASE_0_25			REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 1)
4748 #define   PLANE_CUS_HPHASE_0_5			REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 2)
4749 #define   PLANE_CUS_VPHASE_SIGN_NEGATIVE		REG_BIT(15)
4750 #define   PLANE_CUS_VPHASE_MASK			REG_GENMASK(13, 12)
4751 #define   PLANE_CUS_VPHASE_0			REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 0)
4752 #define   PLANE_CUS_VPHASE_0_25			REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 1)
4753 #define   PLANE_CUS_VPHASE_0_5			REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 2)
4754 #define _PLANE_COLOR_CTL_1_A			0x701CC /* GLK+ */
4755 #define _PLANE_COLOR_CTL_2_A			0x702CC /* GLK+ */
4756 #define _PLANE_COLOR_CTL_3_A			0x703CC /* GLK+ */
4757 #define   PLANE_COLOR_PIPE_GAMMA_ENABLE			REG_BIT(30) /* Pre-ICL */
4758 #define   PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE	REG_BIT(28)
4759 #define   PLANE_COLOR_PIPE_CSC_ENABLE			REG_BIT(23) /* Pre-ICL */
4760 #define   PLANE_COLOR_PLANE_CSC_ENABLE			REG_BIT(21) /* ICL+ */
4761 #define   PLANE_COLOR_INPUT_CSC_ENABLE			REG_BIT(20) /* ICL+ */
4762 #define   PLANE_COLOR_CSC_MODE_MASK			REG_GENMASK(19, 17)
4763 #define   PLANE_COLOR_CSC_MODE_BYPASS			REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 0)
4764 #define   PLANE_COLOR_CSC_MODE_YUV601_TO_RGB601		REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 1)
4765 #define   PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709		REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 2)
4766 #define   PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020	REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 3)
4767 #define   PLANE_COLOR_CSC_MODE_RGB709_TO_RGB2020	REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 4)
4768 #define   PLANE_COLOR_PLANE_GAMMA_DISABLE		REG_BIT(13)
4769 #define   PLANE_COLOR_ALPHA_MASK			REG_GENMASK(5, 4)
4770 #define   PLANE_COLOR_ALPHA_DISABLE			REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 0)
4771 #define   PLANE_COLOR_ALPHA_SW_PREMULTIPLY		REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 2)
4772 #define   PLANE_COLOR_ALPHA_HW_PREMULTIPLY		REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 3)
4773 #define _PLANE_BUF_CFG_1_A			0x7027c
4774 #define _PLANE_BUF_CFG_2_A			0x7037c
4775 #define _PLANE_NV12_BUF_CFG_1_A		0x70278
4776 #define _PLANE_NV12_BUF_CFG_2_A		0x70378
4777 
4778 #define _PLANE_CC_VAL_1_B		0x711b4
4779 #define _PLANE_CC_VAL_2_B		0x712b4
4780 #define _PLANE_CC_VAL_1(pipe, dw)	(_PIPE(pipe, _PLANE_CC_VAL_1_A, _PLANE_CC_VAL_1_B) + (dw) * 4)
4781 #define _PLANE_CC_VAL_2(pipe, dw)	(_PIPE(pipe, _PLANE_CC_VAL_2_A, _PLANE_CC_VAL_2_B) + (dw) * 4)
4782 #define PLANE_CC_VAL(pipe, plane, dw) \
4783 	_MMIO_PLANE((plane), _PLANE_CC_VAL_1((pipe), (dw)), _PLANE_CC_VAL_2((pipe), (dw)))
4784 
4785 /* Input CSC Register Definitions */
4786 #define _PLANE_INPUT_CSC_RY_GY_1_A	0x701E0
4787 #define _PLANE_INPUT_CSC_RY_GY_2_A	0x702E0
4788 
4789 #define _PLANE_INPUT_CSC_RY_GY_1_B	0x711E0
4790 #define _PLANE_INPUT_CSC_RY_GY_2_B	0x712E0
4791 
4792 #define _PLANE_INPUT_CSC_RY_GY_1(pipe)	\
4793 	_PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_1_A, \
4794 	     _PLANE_INPUT_CSC_RY_GY_1_B)
4795 #define _PLANE_INPUT_CSC_RY_GY_2(pipe)	\
4796 	_PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_2_A, \
4797 	     _PLANE_INPUT_CSC_RY_GY_2_B)
4798 
4799 #define PLANE_INPUT_CSC_COEFF(pipe, plane, index)	\
4800 	_MMIO_PLANE(plane, _PLANE_INPUT_CSC_RY_GY_1(pipe) +  (index) * 4, \
4801 		    _PLANE_INPUT_CSC_RY_GY_2(pipe) + (index) * 4)
4802 
4803 #define _PLANE_INPUT_CSC_PREOFF_HI_1_A		0x701F8
4804 #define _PLANE_INPUT_CSC_PREOFF_HI_2_A		0x702F8
4805 
4806 #define _PLANE_INPUT_CSC_PREOFF_HI_1_B		0x711F8
4807 #define _PLANE_INPUT_CSC_PREOFF_HI_2_B		0x712F8
4808 
4809 #define _PLANE_INPUT_CSC_PREOFF_HI_1(pipe)	\
4810 	_PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_1_A, \
4811 	     _PLANE_INPUT_CSC_PREOFF_HI_1_B)
4812 #define _PLANE_INPUT_CSC_PREOFF_HI_2(pipe)	\
4813 	_PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_2_A, \
4814 	     _PLANE_INPUT_CSC_PREOFF_HI_2_B)
4815 #define PLANE_INPUT_CSC_PREOFF(pipe, plane, index)	\
4816 	_MMIO_PLANE(plane, _PLANE_INPUT_CSC_PREOFF_HI_1(pipe) + (index) * 4, \
4817 		    _PLANE_INPUT_CSC_PREOFF_HI_2(pipe) + (index) * 4)
4818 
4819 #define _PLANE_INPUT_CSC_POSTOFF_HI_1_A		0x70204
4820 #define _PLANE_INPUT_CSC_POSTOFF_HI_2_A		0x70304
4821 
4822 #define _PLANE_INPUT_CSC_POSTOFF_HI_1_B		0x71204
4823 #define _PLANE_INPUT_CSC_POSTOFF_HI_2_B		0x71304
4824 
4825 #define _PLANE_INPUT_CSC_POSTOFF_HI_1(pipe)	\
4826 	_PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_1_A, \
4827 	     _PLANE_INPUT_CSC_POSTOFF_HI_1_B)
4828 #define _PLANE_INPUT_CSC_POSTOFF_HI_2(pipe)	\
4829 	_PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_2_A, \
4830 	     _PLANE_INPUT_CSC_POSTOFF_HI_2_B)
4831 #define PLANE_INPUT_CSC_POSTOFF(pipe, plane, index)	\
4832 	_MMIO_PLANE(plane, _PLANE_INPUT_CSC_POSTOFF_HI_1(pipe) + (index) * 4, \
4833 		    _PLANE_INPUT_CSC_POSTOFF_HI_2(pipe) + (index) * 4)
4834 
4835 #define _PLANE_CTL_1_B				0x71180
4836 #define _PLANE_CTL_2_B				0x71280
4837 #define _PLANE_CTL_3_B				0x71380
4838 #define _PLANE_CTL_1(pipe)	_PIPE(pipe, _PLANE_CTL_1_A, _PLANE_CTL_1_B)
4839 #define _PLANE_CTL_2(pipe)	_PIPE(pipe, _PLANE_CTL_2_A, _PLANE_CTL_2_B)
4840 #define _PLANE_CTL_3(pipe)	_PIPE(pipe, _PLANE_CTL_3_A, _PLANE_CTL_3_B)
4841 #define PLANE_CTL(pipe, plane)	\
4842 	_MMIO_PLANE(plane, _PLANE_CTL_1(pipe), _PLANE_CTL_2(pipe))
4843 
4844 #define _PLANE_STRIDE_1_B			0x71188
4845 #define _PLANE_STRIDE_2_B			0x71288
4846 #define _PLANE_STRIDE_3_B			0x71388
4847 #define _PLANE_STRIDE_1(pipe)	\
4848 	_PIPE(pipe, _PLANE_STRIDE_1_A, _PLANE_STRIDE_1_B)
4849 #define _PLANE_STRIDE_2(pipe)	\
4850 	_PIPE(pipe, _PLANE_STRIDE_2_A, _PLANE_STRIDE_2_B)
4851 #define _PLANE_STRIDE_3(pipe)	\
4852 	_PIPE(pipe, _PLANE_STRIDE_3_A, _PLANE_STRIDE_3_B)
4853 #define PLANE_STRIDE(pipe, plane)	\
4854 	_MMIO_PLANE(plane, _PLANE_STRIDE_1(pipe), _PLANE_STRIDE_2(pipe))
4855 
4856 #define _PLANE_POS_1_B				0x7118c
4857 #define _PLANE_POS_2_B				0x7128c
4858 #define _PLANE_POS_3_B				0x7138c
4859 #define _PLANE_POS_1(pipe)	_PIPE(pipe, _PLANE_POS_1_A, _PLANE_POS_1_B)
4860 #define _PLANE_POS_2(pipe)	_PIPE(pipe, _PLANE_POS_2_A, _PLANE_POS_2_B)
4861 #define _PLANE_POS_3(pipe)	_PIPE(pipe, _PLANE_POS_3_A, _PLANE_POS_3_B)
4862 #define PLANE_POS(pipe, plane)	\
4863 	_MMIO_PLANE(plane, _PLANE_POS_1(pipe), _PLANE_POS_2(pipe))
4864 
4865 #define _PLANE_SIZE_1_B				0x71190
4866 #define _PLANE_SIZE_2_B				0x71290
4867 #define _PLANE_SIZE_3_B				0x71390
4868 #define _PLANE_SIZE_1(pipe)	_PIPE(pipe, _PLANE_SIZE_1_A, _PLANE_SIZE_1_B)
4869 #define _PLANE_SIZE_2(pipe)	_PIPE(pipe, _PLANE_SIZE_2_A, _PLANE_SIZE_2_B)
4870 #define _PLANE_SIZE_3(pipe)	_PIPE(pipe, _PLANE_SIZE_3_A, _PLANE_SIZE_3_B)
4871 #define PLANE_SIZE(pipe, plane)	\
4872 	_MMIO_PLANE(plane, _PLANE_SIZE_1(pipe), _PLANE_SIZE_2(pipe))
4873 
4874 #define _PLANE_SURF_1_B				0x7119c
4875 #define _PLANE_SURF_2_B				0x7129c
4876 #define _PLANE_SURF_3_B				0x7139c
4877 #define _PLANE_SURF_1(pipe)	_PIPE(pipe, _PLANE_SURF_1_A, _PLANE_SURF_1_B)
4878 #define _PLANE_SURF_2(pipe)	_PIPE(pipe, _PLANE_SURF_2_A, _PLANE_SURF_2_B)
4879 #define _PLANE_SURF_3(pipe)	_PIPE(pipe, _PLANE_SURF_3_A, _PLANE_SURF_3_B)
4880 #define PLANE_SURF(pipe, plane)	\
4881 	_MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
4882 
4883 #define _PLANE_OFFSET_1_B			0x711a4
4884 #define _PLANE_OFFSET_2_B			0x712a4
4885 #define _PLANE_OFFSET_1(pipe) _PIPE(pipe, _PLANE_OFFSET_1_A, _PLANE_OFFSET_1_B)
4886 #define _PLANE_OFFSET_2(pipe) _PIPE(pipe, _PLANE_OFFSET_2_A, _PLANE_OFFSET_2_B)
4887 #define PLANE_OFFSET(pipe, plane)	\
4888 	_MMIO_PLANE(plane, _PLANE_OFFSET_1(pipe), _PLANE_OFFSET_2(pipe))
4889 
4890 #define _PLANE_KEYVAL_1_B			0x71194
4891 #define _PLANE_KEYVAL_2_B			0x71294
4892 #define _PLANE_KEYVAL_1(pipe) _PIPE(pipe, _PLANE_KEYVAL_1_A, _PLANE_KEYVAL_1_B)
4893 #define _PLANE_KEYVAL_2(pipe) _PIPE(pipe, _PLANE_KEYVAL_2_A, _PLANE_KEYVAL_2_B)
4894 #define PLANE_KEYVAL(pipe, plane)	\
4895 	_MMIO_PLANE(plane, _PLANE_KEYVAL_1(pipe), _PLANE_KEYVAL_2(pipe))
4896 
4897 #define _PLANE_KEYMSK_1_B			0x71198
4898 #define _PLANE_KEYMSK_2_B			0x71298
4899 #define _PLANE_KEYMSK_1(pipe) _PIPE(pipe, _PLANE_KEYMSK_1_A, _PLANE_KEYMSK_1_B)
4900 #define _PLANE_KEYMSK_2(pipe) _PIPE(pipe, _PLANE_KEYMSK_2_A, _PLANE_KEYMSK_2_B)
4901 #define PLANE_KEYMSK(pipe, plane)	\
4902 	_MMIO_PLANE(plane, _PLANE_KEYMSK_1(pipe), _PLANE_KEYMSK_2(pipe))
4903 
4904 #define _PLANE_KEYMAX_1_B			0x711a0
4905 #define _PLANE_KEYMAX_2_B			0x712a0
4906 #define _PLANE_KEYMAX_1(pipe) _PIPE(pipe, _PLANE_KEYMAX_1_A, _PLANE_KEYMAX_1_B)
4907 #define _PLANE_KEYMAX_2(pipe) _PIPE(pipe, _PLANE_KEYMAX_2_A, _PLANE_KEYMAX_2_B)
4908 #define PLANE_KEYMAX(pipe, plane)	\
4909 	_MMIO_PLANE(plane, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))
4910 
4911 #define _PLANE_BUF_CFG_1_B			0x7127c
4912 #define _PLANE_BUF_CFG_2_B			0x7137c
4913 /* skl+: 10 bits, icl+ 11 bits, adlp+ 12 bits */
4914 #define   PLANE_BUF_END_MASK		REG_GENMASK(27, 16)
4915 #define   PLANE_BUF_END(end)		REG_FIELD_PREP(PLANE_BUF_END_MASK, (end))
4916 #define   PLANE_BUF_START_MASK		REG_GENMASK(11, 0)
4917 #define   PLANE_BUF_START(start)	REG_FIELD_PREP(PLANE_BUF_START_MASK, (start))
4918 #define _PLANE_BUF_CFG_1(pipe)	\
4919 	_PIPE(pipe, _PLANE_BUF_CFG_1_A, _PLANE_BUF_CFG_1_B)
4920 #define _PLANE_BUF_CFG_2(pipe)	\
4921 	_PIPE(pipe, _PLANE_BUF_CFG_2_A, _PLANE_BUF_CFG_2_B)
4922 #define PLANE_BUF_CFG(pipe, plane)	\
4923 	_MMIO_PLANE(plane, _PLANE_BUF_CFG_1(pipe), _PLANE_BUF_CFG_2(pipe))
4924 
4925 #define _PLANE_NV12_BUF_CFG_1_B		0x71278
4926 #define _PLANE_NV12_BUF_CFG_2_B		0x71378
4927 #define _PLANE_NV12_BUF_CFG_1(pipe)	\
4928 	_PIPE(pipe, _PLANE_NV12_BUF_CFG_1_A, _PLANE_NV12_BUF_CFG_1_B)
4929 #define _PLANE_NV12_BUF_CFG_2(pipe)	\
4930 	_PIPE(pipe, _PLANE_NV12_BUF_CFG_2_A, _PLANE_NV12_BUF_CFG_2_B)
4931 #define PLANE_NV12_BUF_CFG(pipe, plane)	\
4932 	_MMIO_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe))
4933 
4934 #define _PLANE_AUX_DIST_1_B		0x711c0
4935 #define _PLANE_AUX_DIST_2_B		0x712c0
4936 #define _PLANE_AUX_DIST_1(pipe) \
4937 			_PIPE(pipe, _PLANE_AUX_DIST_1_A, _PLANE_AUX_DIST_1_B)
4938 #define _PLANE_AUX_DIST_2(pipe) \
4939 			_PIPE(pipe, _PLANE_AUX_DIST_2_A, _PLANE_AUX_DIST_2_B)
4940 #define PLANE_AUX_DIST(pipe, plane)     \
4941 	_MMIO_PLANE(plane, _PLANE_AUX_DIST_1(pipe), _PLANE_AUX_DIST_2(pipe))
4942 
4943 #define _PLANE_AUX_OFFSET_1_B		0x711c4
4944 #define _PLANE_AUX_OFFSET_2_B		0x712c4
4945 #define _PLANE_AUX_OFFSET_1(pipe)       \
4946 		_PIPE(pipe, _PLANE_AUX_OFFSET_1_A, _PLANE_AUX_OFFSET_1_B)
4947 #define _PLANE_AUX_OFFSET_2(pipe)       \
4948 		_PIPE(pipe, _PLANE_AUX_OFFSET_2_A, _PLANE_AUX_OFFSET_2_B)
4949 #define PLANE_AUX_OFFSET(pipe, plane)   \
4950 	_MMIO_PLANE(plane, _PLANE_AUX_OFFSET_1(pipe), _PLANE_AUX_OFFSET_2(pipe))
4951 
4952 #define _PLANE_CUS_CTL_1_B		0x711c8
4953 #define _PLANE_CUS_CTL_2_B		0x712c8
4954 #define _PLANE_CUS_CTL_1(pipe)       \
4955 		_PIPE(pipe, _PLANE_CUS_CTL_1_A, _PLANE_CUS_CTL_1_B)
4956 #define _PLANE_CUS_CTL_2(pipe)       \
4957 		_PIPE(pipe, _PLANE_CUS_CTL_2_A, _PLANE_CUS_CTL_2_B)
4958 #define PLANE_CUS_CTL(pipe, plane)   \
4959 	_MMIO_PLANE(plane, _PLANE_CUS_CTL_1(pipe), _PLANE_CUS_CTL_2(pipe))
4960 
4961 #define _PLANE_COLOR_CTL_1_B			0x711CC
4962 #define _PLANE_COLOR_CTL_2_B			0x712CC
4963 #define _PLANE_COLOR_CTL_3_B			0x713CC
4964 #define _PLANE_COLOR_CTL_1(pipe)	\
4965 	_PIPE(pipe, _PLANE_COLOR_CTL_1_A, _PLANE_COLOR_CTL_1_B)
4966 #define _PLANE_COLOR_CTL_2(pipe)	\
4967 	_PIPE(pipe, _PLANE_COLOR_CTL_2_A, _PLANE_COLOR_CTL_2_B)
4968 #define PLANE_COLOR_CTL(pipe, plane)	\
4969 	_MMIO_PLANE(plane, _PLANE_COLOR_CTL_1(pipe), _PLANE_COLOR_CTL_2(pipe))
4970 
4971 #define _SEL_FETCH_PLANE_BASE_1_A		0x70890
4972 #define _SEL_FETCH_PLANE_BASE_2_A		0x708B0
4973 #define _SEL_FETCH_PLANE_BASE_3_A		0x708D0
4974 #define _SEL_FETCH_PLANE_BASE_4_A		0x708F0
4975 #define _SEL_FETCH_PLANE_BASE_5_A		0x70920
4976 #define _SEL_FETCH_PLANE_BASE_6_A		0x70940
4977 #define _SEL_FETCH_PLANE_BASE_7_A		0x70960
4978 #define _SEL_FETCH_PLANE_BASE_CUR_A		0x70880
4979 #define _SEL_FETCH_PLANE_BASE_1_B		0x71890
4980 
4981 #define _SEL_FETCH_PLANE_BASE_A(plane) _PICK(plane, \
4982 					     _SEL_FETCH_PLANE_BASE_1_A, \
4983 					     _SEL_FETCH_PLANE_BASE_2_A, \
4984 					     _SEL_FETCH_PLANE_BASE_3_A, \
4985 					     _SEL_FETCH_PLANE_BASE_4_A, \
4986 					     _SEL_FETCH_PLANE_BASE_5_A, \
4987 					     _SEL_FETCH_PLANE_BASE_6_A, \
4988 					     _SEL_FETCH_PLANE_BASE_7_A, \
4989 					     _SEL_FETCH_PLANE_BASE_CUR_A)
4990 #define _SEL_FETCH_PLANE_BASE_1(pipe) _PIPE(pipe, _SEL_FETCH_PLANE_BASE_1_A, _SEL_FETCH_PLANE_BASE_1_B)
4991 #define _SEL_FETCH_PLANE_BASE(pipe, plane) (_SEL_FETCH_PLANE_BASE_1(pipe) - \
4992 					    _SEL_FETCH_PLANE_BASE_1_A + \
4993 					    _SEL_FETCH_PLANE_BASE_A(plane))
4994 
4995 #define _SEL_FETCH_PLANE_CTL_1_A		0x70890
4996 #define PLANE_SEL_FETCH_CTL(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
4997 					       _SEL_FETCH_PLANE_CTL_1_A - \
4998 					       _SEL_FETCH_PLANE_BASE_1_A)
4999 #define PLANE_SEL_FETCH_CTL_ENABLE		REG_BIT(31)
5000 
5001 #define _SEL_FETCH_PLANE_POS_1_A		0x70894
5002 #define PLANE_SEL_FETCH_POS(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
5003 					       _SEL_FETCH_PLANE_POS_1_A - \
5004 					       _SEL_FETCH_PLANE_BASE_1_A)
5005 
5006 #define _SEL_FETCH_PLANE_SIZE_1_A		0x70898
5007 #define PLANE_SEL_FETCH_SIZE(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
5008 						_SEL_FETCH_PLANE_SIZE_1_A - \
5009 						_SEL_FETCH_PLANE_BASE_1_A)
5010 
5011 #define _SEL_FETCH_PLANE_OFFSET_1_A		0x7089C
5012 #define PLANE_SEL_FETCH_OFFSET(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
5013 						  _SEL_FETCH_PLANE_OFFSET_1_A - \
5014 						  _SEL_FETCH_PLANE_BASE_1_A)
5015 
5016 /* SKL new cursor registers */
5017 #define _CUR_BUF_CFG_A				0x7017c
5018 #define _CUR_BUF_CFG_B				0x7117c
5019 #define CUR_BUF_CFG(pipe)	_MMIO_PIPE(pipe, _CUR_BUF_CFG_A, _CUR_BUF_CFG_B)
5020 
5021 /* VBIOS regs */
5022 #define VGACNTRL		_MMIO(0x71400)
5023 # define VGA_DISP_DISABLE			(1 << 31)
5024 # define VGA_2X_MODE				(1 << 30)
5025 # define VGA_PIPE_B_SELECT			(1 << 29)
5026 
5027 #define VLV_VGACNTRL		_MMIO(VLV_DISPLAY_BASE + 0x71400)
5028 
5029 /* Ironlake */
5030 
5031 #define CPU_VGACNTRL	_MMIO(0x41000)
5032 
5033 #define DIGITAL_PORT_HOTPLUG_CNTRL	_MMIO(0x44030)
5034 #define  DIGITAL_PORTA_HOTPLUG_ENABLE		(1 << 4)
5035 #define  DIGITAL_PORTA_PULSE_DURATION_2ms	(0 << 2) /* pre-HSW */
5036 #define  DIGITAL_PORTA_PULSE_DURATION_4_5ms	(1 << 2) /* pre-HSW */
5037 #define  DIGITAL_PORTA_PULSE_DURATION_6ms	(2 << 2) /* pre-HSW */
5038 #define  DIGITAL_PORTA_PULSE_DURATION_100ms	(3 << 2) /* pre-HSW */
5039 #define  DIGITAL_PORTA_PULSE_DURATION_MASK	(3 << 2) /* pre-HSW */
5040 #define  DIGITAL_PORTA_HOTPLUG_STATUS_MASK	(3 << 0)
5041 #define  DIGITAL_PORTA_HOTPLUG_NO_DETECT	(0 << 0)
5042 #define  DIGITAL_PORTA_HOTPLUG_SHORT_DETECT	(1 << 0)
5043 #define  DIGITAL_PORTA_HOTPLUG_LONG_DETECT	(2 << 0)
5044 
5045 /* refresh rate hardware control */
5046 #define RR_HW_CTL       _MMIO(0x45300)
5047 #define  RR_HW_LOW_POWER_FRAMES_MASK    0xff
5048 #define  RR_HW_HIGH_POWER_FRAMES_MASK   0xff00
5049 
5050 #define FDI_PLL_BIOS_0  _MMIO(0x46000)
5051 #define  FDI_PLL_FB_CLOCK_MASK  0xff
5052 #define FDI_PLL_BIOS_1  _MMIO(0x46004)
5053 #define FDI_PLL_BIOS_2  _MMIO(0x46008)
5054 #define DISPLAY_PORT_PLL_BIOS_0         _MMIO(0x4600c)
5055 #define DISPLAY_PORT_PLL_BIOS_1         _MMIO(0x46010)
5056 #define DISPLAY_PORT_PLL_BIOS_2         _MMIO(0x46014)
5057 
5058 #define PCH_3DCGDIS0		_MMIO(0x46020)
5059 # define MARIUNIT_CLOCK_GATE_DISABLE		(1 << 18)
5060 # define SVSMUNIT_CLOCK_GATE_DISABLE		(1 << 1)
5061 
5062 #define PCH_3DCGDIS1		_MMIO(0x46024)
5063 # define VFMUNIT_CLOCK_GATE_DISABLE		(1 << 11)
5064 
5065 #define FDI_PLL_FREQ_CTL        _MMIO(0x46030)
5066 #define  FDI_PLL_FREQ_CHANGE_REQUEST    (1 << 24)
5067 #define  FDI_PLL_FREQ_LOCK_LIMIT_MASK   0xfff00
5068 #define  FDI_PLL_FREQ_DISABLE_COUNT_LIMIT_MASK  0xff
5069 
5070 
5071 #define _PIPEA_DATA_M1		0x60030
5072 #define _PIPEA_DATA_N1		0x60034
5073 #define _PIPEA_DATA_M2		0x60038
5074 #define _PIPEA_DATA_N2		0x6003c
5075 #define _PIPEA_LINK_M1		0x60040
5076 #define _PIPEA_LINK_N1		0x60044
5077 #define _PIPEA_LINK_M2		0x60048
5078 #define _PIPEA_LINK_N2		0x6004c
5079 
5080 /* PIPEB timing regs are same start from 0x61000 */
5081 
5082 #define _PIPEB_DATA_M1		0x61030
5083 #define _PIPEB_DATA_N1		0x61034
5084 #define _PIPEB_DATA_M2		0x61038
5085 #define _PIPEB_DATA_N2		0x6103c
5086 #define _PIPEB_LINK_M1		0x61040
5087 #define _PIPEB_LINK_N1		0x61044
5088 #define _PIPEB_LINK_M2		0x61048
5089 #define _PIPEB_LINK_N2		0x6104c
5090 
5091 #define PIPE_DATA_M1(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_M1)
5092 #define PIPE_DATA_N1(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_N1)
5093 #define PIPE_DATA_M2(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_M2)
5094 #define PIPE_DATA_N2(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_N2)
5095 #define PIPE_LINK_M1(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_M1)
5096 #define PIPE_LINK_N1(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_N1)
5097 #define PIPE_LINK_M2(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_M2)
5098 #define PIPE_LINK_N2(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_N2)
5099 
5100 /* CPU panel fitter */
5101 /* IVB+ has 3 fitters, 0 is 7x5 capable, the other two only 3x3 */
5102 #define _PFA_CTL_1               0x68080
5103 #define _PFB_CTL_1               0x68880
5104 #define  PF_ENABLE              (1 << 31)
5105 #define  PF_PIPE_SEL_MASK_IVB	(3 << 29)
5106 #define  PF_PIPE_SEL_IVB(pipe)	((pipe) << 29)
5107 #define  PF_FILTER_MASK		(3 << 23)
5108 #define  PF_FILTER_PROGRAMMED	(0 << 23)
5109 #define  PF_FILTER_MED_3x3	(1 << 23)
5110 #define  PF_FILTER_EDGE_ENHANCE	(2 << 23)
5111 #define  PF_FILTER_EDGE_SOFTEN	(3 << 23)
5112 #define _PFA_WIN_SZ		0x68074
5113 #define _PFB_WIN_SZ		0x68874
5114 #define _PFA_WIN_POS		0x68070
5115 #define _PFB_WIN_POS		0x68870
5116 #define _PFA_VSCALE		0x68084
5117 #define _PFB_VSCALE		0x68884
5118 #define _PFA_HSCALE		0x68090
5119 #define _PFB_HSCALE		0x68890
5120 
5121 #define PF_CTL(pipe)		_MMIO_PIPE(pipe, _PFA_CTL_1, _PFB_CTL_1)
5122 #define PF_WIN_SZ(pipe)		_MMIO_PIPE(pipe, _PFA_WIN_SZ, _PFB_WIN_SZ)
5123 #define PF_WIN_POS(pipe)	_MMIO_PIPE(pipe, _PFA_WIN_POS, _PFB_WIN_POS)
5124 #define PF_VSCALE(pipe)		_MMIO_PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
5125 #define PF_HSCALE(pipe)		_MMIO_PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
5126 
5127 #define _PSA_CTL		0x68180
5128 #define _PSB_CTL		0x68980
5129 #define PS_ENABLE		(1 << 31)
5130 #define _PSA_WIN_SZ		0x68174
5131 #define _PSB_WIN_SZ		0x68974
5132 #define _PSA_WIN_POS		0x68170
5133 #define _PSB_WIN_POS		0x68970
5134 
5135 #define PS_CTL(pipe)		_MMIO_PIPE(pipe, _PSA_CTL, _PSB_CTL)
5136 #define PS_WIN_SZ(pipe)		_MMIO_PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
5137 #define PS_WIN_POS(pipe)	_MMIO_PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
5138 
5139 /*
5140  * Skylake scalers
5141  */
5142 #define _PS_1A_CTRL      0x68180
5143 #define _PS_2A_CTRL      0x68280
5144 #define _PS_1B_CTRL      0x68980
5145 #define _PS_2B_CTRL      0x68A80
5146 #define _PS_1C_CTRL      0x69180
5147 #define PS_SCALER_EN        (1 << 31)
5148 #define SKL_PS_SCALER_MODE_MASK (3 << 28)
5149 #define SKL_PS_SCALER_MODE_DYN  (0 << 28)
5150 #define SKL_PS_SCALER_MODE_HQ  (1 << 28)
5151 #define SKL_PS_SCALER_MODE_NV12 (2 << 28)
5152 #define PS_SCALER_MODE_PLANAR (1 << 29)
5153 #define PS_SCALER_MODE_NORMAL (0 << 29)
5154 #define PS_PLANE_SEL_MASK  (7 << 25)
5155 #define PS_PLANE_SEL(plane) (((plane) + 1) << 25)
5156 #define PS_FILTER_MASK         (3 << 23)
5157 #define PS_FILTER_MEDIUM       (0 << 23)
5158 #define PS_FILTER_PROGRAMMED   (1 << 23)
5159 #define PS_FILTER_EDGE_ENHANCE (2 << 23)
5160 #define PS_FILTER_BILINEAR     (3 << 23)
5161 #define PS_VERT3TAP            (1 << 21)
5162 #define PS_VERT_INT_INVERT_FIELD1 (0 << 20)
5163 #define PS_VERT_INT_INVERT_FIELD0 (1 << 20)
5164 #define PS_PWRUP_PROGRESS         (1 << 17)
5165 #define PS_V_FILTER_BYPASS        (1 << 8)
5166 #define PS_VADAPT_EN              (1 << 7)
5167 #define PS_VADAPT_MODE_MASK        (3 << 5)
5168 #define PS_VADAPT_MODE_LEAST_ADAPT (0 << 5)
5169 #define PS_VADAPT_MODE_MOD_ADAPT   (1 << 5)
5170 #define PS_VADAPT_MODE_MOST_ADAPT  (3 << 5)
5171 #define PS_PLANE_Y_SEL_MASK  (7 << 5)
5172 #define PS_PLANE_Y_SEL(plane) (((plane) + 1) << 5)
5173 #define PS_Y_VERT_FILTER_SELECT(set)   ((set) << 4)
5174 #define PS_Y_HORZ_FILTER_SELECT(set)   ((set) << 3)
5175 #define PS_UV_VERT_FILTER_SELECT(set)  ((set) << 2)
5176 #define PS_UV_HORZ_FILTER_SELECT(set)  ((set) << 1)
5177 
5178 #define _PS_PWR_GATE_1A     0x68160
5179 #define _PS_PWR_GATE_2A     0x68260
5180 #define _PS_PWR_GATE_1B     0x68960
5181 #define _PS_PWR_GATE_2B     0x68A60
5182 #define _PS_PWR_GATE_1C     0x69160
5183 #define PS_PWR_GATE_DIS_OVERRIDE       (1 << 31)
5184 #define PS_PWR_GATE_SETTLING_TIME_32   (0 << 3)
5185 #define PS_PWR_GATE_SETTLING_TIME_64   (1 << 3)
5186 #define PS_PWR_GATE_SETTLING_TIME_96   (2 << 3)
5187 #define PS_PWR_GATE_SETTLING_TIME_128  (3 << 3)
5188 #define PS_PWR_GATE_SLPEN_8             0
5189 #define PS_PWR_GATE_SLPEN_16            1
5190 #define PS_PWR_GATE_SLPEN_24            2
5191 #define PS_PWR_GATE_SLPEN_32            3
5192 
5193 #define _PS_WIN_POS_1A      0x68170
5194 #define _PS_WIN_POS_2A      0x68270
5195 #define _PS_WIN_POS_1B      0x68970
5196 #define _PS_WIN_POS_2B      0x68A70
5197 #define _PS_WIN_POS_1C      0x69170
5198 
5199 #define _PS_WIN_SZ_1A       0x68174
5200 #define _PS_WIN_SZ_2A       0x68274
5201 #define _PS_WIN_SZ_1B       0x68974
5202 #define _PS_WIN_SZ_2B       0x68A74
5203 #define _PS_WIN_SZ_1C       0x69174
5204 
5205 #define _PS_VSCALE_1A       0x68184
5206 #define _PS_VSCALE_2A       0x68284
5207 #define _PS_VSCALE_1B       0x68984
5208 #define _PS_VSCALE_2B       0x68A84
5209 #define _PS_VSCALE_1C       0x69184
5210 
5211 #define _PS_HSCALE_1A       0x68190
5212 #define _PS_HSCALE_2A       0x68290
5213 #define _PS_HSCALE_1B       0x68990
5214 #define _PS_HSCALE_2B       0x68A90
5215 #define _PS_HSCALE_1C       0x69190
5216 
5217 #define _PS_VPHASE_1A       0x68188
5218 #define _PS_VPHASE_2A       0x68288
5219 #define _PS_VPHASE_1B       0x68988
5220 #define _PS_VPHASE_2B       0x68A88
5221 #define _PS_VPHASE_1C       0x69188
5222 #define  PS_Y_PHASE(x)		((x) << 16)
5223 #define  PS_UV_RGB_PHASE(x)	((x) << 0)
5224 #define   PS_PHASE_MASK	(0x7fff << 1) /* u2.13 */
5225 #define   PS_PHASE_TRIP	(1 << 0)
5226 
5227 #define _PS_HPHASE_1A       0x68194
5228 #define _PS_HPHASE_2A       0x68294
5229 #define _PS_HPHASE_1B       0x68994
5230 #define _PS_HPHASE_2B       0x68A94
5231 #define _PS_HPHASE_1C       0x69194
5232 
5233 #define _PS_ECC_STAT_1A     0x681D0
5234 #define _PS_ECC_STAT_2A     0x682D0
5235 #define _PS_ECC_STAT_1B     0x689D0
5236 #define _PS_ECC_STAT_2B     0x68AD0
5237 #define _PS_ECC_STAT_1C     0x691D0
5238 
5239 #define _PS_COEF_SET0_INDEX_1A	   0x68198
5240 #define _PS_COEF_SET0_INDEX_2A	   0x68298
5241 #define _PS_COEF_SET0_INDEX_1B	   0x68998
5242 #define _PS_COEF_SET0_INDEX_2B	   0x68A98
5243 #define PS_COEE_INDEX_AUTO_INC	   (1 << 10)
5244 
5245 #define _PS_COEF_SET0_DATA_1A	   0x6819C
5246 #define _PS_COEF_SET0_DATA_2A	   0x6829C
5247 #define _PS_COEF_SET0_DATA_1B	   0x6899C
5248 #define _PS_COEF_SET0_DATA_2B	   0x68A9C
5249 
5250 #define _ID(id, a, b) _PICK_EVEN(id, a, b)
5251 #define SKL_PS_CTRL(pipe, id) _MMIO_PIPE(pipe,        \
5252 			_ID(id, _PS_1A_CTRL, _PS_2A_CTRL),       \
5253 			_ID(id, _PS_1B_CTRL, _PS_2B_CTRL))
5254 #define SKL_PS_PWR_GATE(pipe, id) _MMIO_PIPE(pipe,    \
5255 			_ID(id, _PS_PWR_GATE_1A, _PS_PWR_GATE_2A), \
5256 			_ID(id, _PS_PWR_GATE_1B, _PS_PWR_GATE_2B))
5257 #define SKL_PS_WIN_POS(pipe, id) _MMIO_PIPE(pipe,     \
5258 			_ID(id, _PS_WIN_POS_1A, _PS_WIN_POS_2A), \
5259 			_ID(id, _PS_WIN_POS_1B, _PS_WIN_POS_2B))
5260 #define SKL_PS_WIN_SZ(pipe, id)  _MMIO_PIPE(pipe,     \
5261 			_ID(id, _PS_WIN_SZ_1A, _PS_WIN_SZ_2A),   \
5262 			_ID(id, _PS_WIN_SZ_1B, _PS_WIN_SZ_2B))
5263 #define SKL_PS_VSCALE(pipe, id)  _MMIO_PIPE(pipe,     \
5264 			_ID(id, _PS_VSCALE_1A, _PS_VSCALE_2A),   \
5265 			_ID(id, _PS_VSCALE_1B, _PS_VSCALE_2B))
5266 #define SKL_PS_HSCALE(pipe, id)  _MMIO_PIPE(pipe,     \
5267 			_ID(id, _PS_HSCALE_1A, _PS_HSCALE_2A),   \
5268 			_ID(id, _PS_HSCALE_1B, _PS_HSCALE_2B))
5269 #define SKL_PS_VPHASE(pipe, id)  _MMIO_PIPE(pipe,     \
5270 			_ID(id, _PS_VPHASE_1A, _PS_VPHASE_2A),   \
5271 			_ID(id, _PS_VPHASE_1B, _PS_VPHASE_2B))
5272 #define SKL_PS_HPHASE(pipe, id)  _MMIO_PIPE(pipe,     \
5273 			_ID(id, _PS_HPHASE_1A, _PS_HPHASE_2A),   \
5274 			_ID(id, _PS_HPHASE_1B, _PS_HPHASE_2B))
5275 #define SKL_PS_ECC_STAT(pipe, id)  _MMIO_PIPE(pipe,     \
5276 			_ID(id, _PS_ECC_STAT_1A, _PS_ECC_STAT_2A),   \
5277 			_ID(id, _PS_ECC_STAT_1B, _PS_ECC_STAT_2B))
5278 #define GLK_PS_COEF_INDEX_SET(pipe, id, set)  _MMIO_PIPE(pipe,    \
5279 			_ID(id, _PS_COEF_SET0_INDEX_1A, _PS_COEF_SET0_INDEX_2A) + (set) * 8, \
5280 			_ID(id, _PS_COEF_SET0_INDEX_1B, _PS_COEF_SET0_INDEX_2B) + (set) * 8)
5281 
5282 #define GLK_PS_COEF_DATA_SET(pipe, id, set)  _MMIO_PIPE(pipe,     \
5283 			_ID(id, _PS_COEF_SET0_DATA_1A, _PS_COEF_SET0_DATA_2A) + (set) * 8, \
5284 			_ID(id, _PS_COEF_SET0_DATA_1B, _PS_COEF_SET0_DATA_2B) + (set) * 8)
5285 /* legacy palette */
5286 #define _LGC_PALETTE_A           0x4a000
5287 #define _LGC_PALETTE_B           0x4a800
5288 /* see PALETTE_* for the bits */
5289 #define LGC_PALETTE(pipe, i) _MMIO(_PIPE(pipe, _LGC_PALETTE_A, _LGC_PALETTE_B) + (i) * 4)
5290 
5291 /* ilk/snb precision palette */
5292 #define _PREC_PALETTE_A           0x4b000
5293 #define _PREC_PALETTE_B           0x4c000
5294 /* 10bit mode */
5295 #define   PREC_PALETTE_10_RED_MASK		REG_GENMASK(29, 20)
5296 #define   PREC_PALETTE_10_GREEN_MASK		REG_GENMASK(19, 10)
5297 #define   PREC_PALETTE_10_BLUE_MASK		REG_GENMASK(9, 0)
5298 /* 12.4 interpolated mode ldw */
5299 #define   PREC_PALETTE_12P4_RED_LDW_MASK	REG_GENMASK(29, 24)
5300 #define   PREC_PALETTE_12P4_GREEN_LDW_MASK	REG_GENMASK(19, 14)
5301 #define   PREC_PALETTE_12P4_BLUE_LDW_MASK	REG_GENMASK(9, 4)
5302 /* 12.4 interpolated mode udw */
5303 #define   PREC_PALETTE_12P4_RED_UDW_MASK	REG_GENMASK(29, 20)
5304 #define   PREC_PALETTE_12P4_GREEN_UDW_MASK	REG_GENMASK(19, 10)
5305 #define   PREC_PALETTE_12P4_BLUE_UDW_MASK	REG_GENMASK(9, 0)
5306 #define PREC_PALETTE(pipe, i) _MMIO(_PIPE(pipe, _PREC_PALETTE_A, _PREC_PALETTE_B) + (i) * 4)
5307 
5308 #define  _PREC_PIPEAGCMAX              0x4d000
5309 #define  _PREC_PIPEBGCMAX              0x4d010
5310 #define PREC_PIPEGCMAX(pipe, i)        _MMIO(_PIPE(pipe, _PIPEAGCMAX, _PIPEBGCMAX) + (i) * 4) /* u1.16 */
5311 
5312 #define _GAMMA_MODE_A		0x4a480
5313 #define _GAMMA_MODE_B		0x4ac80
5314 #define GAMMA_MODE(pipe) _MMIO_PIPE(pipe, _GAMMA_MODE_A, _GAMMA_MODE_B)
5315 #define  PRE_CSC_GAMMA_ENABLE			REG_BIT(31) /* icl+ */
5316 #define  POST_CSC_GAMMA_ENABLE			REG_BIT(30) /* icl+ */
5317 #define  PALETTE_ANTICOL_DISABLE		REG_BIT(15) /* skl+ */
5318 #define  GAMMA_MODE_MODE_MASK			REG_GENMASK(1, 0)
5319 #define  GAMMA_MODE_MODE_8BIT			REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 0)
5320 #define  GAMMA_MODE_MODE_10BIT			REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 1)
5321 #define  GAMMA_MODE_MODE_12BIT			REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 2)
5322 #define  GAMMA_MODE_MODE_SPLIT			REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 3) /* ivb-bdw */
5323 #define  GAMMA_MODE_MODE_12BIT_MULTI_SEG	REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 3) /* icl-tgl */
5324 
5325 /* Display Internal Timeout Register */
5326 #define RM_TIMEOUT		_MMIO(0x42060)
5327 #define  MMIO_TIMEOUT_US(us)	((us) << 0)
5328 
5329 /* interrupts */
5330 #define DE_MASTER_IRQ_CONTROL   (1 << 31)
5331 #define DE_SPRITEB_FLIP_DONE    (1 << 29)
5332 #define DE_SPRITEA_FLIP_DONE    (1 << 28)
5333 #define DE_PLANEB_FLIP_DONE     (1 << 27)
5334 #define DE_PLANEA_FLIP_DONE     (1 << 26)
5335 #define DE_PLANE_FLIP_DONE(plane) (1 << (26 + (plane)))
5336 #define DE_PCU_EVENT            (1 << 25)
5337 #define DE_GTT_FAULT            (1 << 24)
5338 #define DE_POISON               (1 << 23)
5339 #define DE_PERFORM_COUNTER      (1 << 22)
5340 #define DE_PCH_EVENT            (1 << 21)
5341 #define DE_AUX_CHANNEL_A        (1 << 20)
5342 #define DE_DP_A_HOTPLUG         (1 << 19)
5343 #define DE_GSE                  (1 << 18)
5344 #define DE_PIPEB_VBLANK         (1 << 15)
5345 #define DE_PIPEB_EVEN_FIELD     (1 << 14)
5346 #define DE_PIPEB_ODD_FIELD      (1 << 13)
5347 #define DE_PIPEB_LINE_COMPARE   (1 << 12)
5348 #define DE_PIPEB_VSYNC          (1 << 11)
5349 #define DE_PIPEB_CRC_DONE	(1 << 10)
5350 #define DE_PIPEB_FIFO_UNDERRUN  (1 << 8)
5351 #define DE_PIPEA_VBLANK         (1 << 7)
5352 #define DE_PIPE_VBLANK(pipe)    (1 << (7 + 8 * (pipe)))
5353 #define DE_PIPEA_EVEN_FIELD     (1 << 6)
5354 #define DE_PIPEA_ODD_FIELD      (1 << 5)
5355 #define DE_PIPEA_LINE_COMPARE   (1 << 4)
5356 #define DE_PIPEA_VSYNC          (1 << 3)
5357 #define DE_PIPEA_CRC_DONE	(1 << 2)
5358 #define DE_PIPE_CRC_DONE(pipe)	(1 << (2 + 8 * (pipe)))
5359 #define DE_PIPEA_FIFO_UNDERRUN  (1 << 0)
5360 #define DE_PIPE_FIFO_UNDERRUN(pipe)  (1 << (8 * (pipe)))
5361 
5362 /* More Ivybridge lolz */
5363 #define DE_ERR_INT_IVB			(1 << 30)
5364 #define DE_GSE_IVB			(1 << 29)
5365 #define DE_PCH_EVENT_IVB		(1 << 28)
5366 #define DE_DP_A_HOTPLUG_IVB		(1 << 27)
5367 #define DE_AUX_CHANNEL_A_IVB		(1 << 26)
5368 #define DE_EDP_PSR_INT_HSW		(1 << 19)
5369 #define DE_SPRITEC_FLIP_DONE_IVB	(1 << 14)
5370 #define DE_PLANEC_FLIP_DONE_IVB		(1 << 13)
5371 #define DE_PIPEC_VBLANK_IVB		(1 << 10)
5372 #define DE_SPRITEB_FLIP_DONE_IVB	(1 << 9)
5373 #define DE_PLANEB_FLIP_DONE_IVB		(1 << 8)
5374 #define DE_PIPEB_VBLANK_IVB		(1 << 5)
5375 #define DE_SPRITEA_FLIP_DONE_IVB	(1 << 4)
5376 #define DE_PLANEA_FLIP_DONE_IVB		(1 << 3)
5377 #define DE_PLANE_FLIP_DONE_IVB(plane)	(1 << (3 + 5 * (plane)))
5378 #define DE_PIPEA_VBLANK_IVB		(1 << 0)
5379 #define DE_PIPE_VBLANK_IVB(pipe)	(1 << ((pipe) * 5))
5380 
5381 #define VLV_MASTER_IER			_MMIO(0x4400c) /* Gunit master IER */
5382 #define   MASTER_INTERRUPT_ENABLE	(1 << 31)
5383 
5384 #define DEISR   _MMIO(0x44000)
5385 #define DEIMR   _MMIO(0x44004)
5386 #define DEIIR   _MMIO(0x44008)
5387 #define DEIER   _MMIO(0x4400c)
5388 
5389 #define GTISR   _MMIO(0x44010)
5390 #define GTIMR   _MMIO(0x44014)
5391 #define GTIIR   _MMIO(0x44018)
5392 #define GTIER   _MMIO(0x4401c)
5393 
5394 #define GEN8_MASTER_IRQ			_MMIO(0x44200)
5395 #define  GEN8_MASTER_IRQ_CONTROL	(1 << 31)
5396 #define  GEN8_PCU_IRQ			(1 << 30)
5397 #define  GEN8_DE_PCH_IRQ		(1 << 23)
5398 #define  GEN8_DE_MISC_IRQ		(1 << 22)
5399 #define  GEN8_DE_PORT_IRQ		(1 << 20)
5400 #define  GEN8_DE_PIPE_C_IRQ		(1 << 18)
5401 #define  GEN8_DE_PIPE_B_IRQ		(1 << 17)
5402 #define  GEN8_DE_PIPE_A_IRQ		(1 << 16)
5403 #define  GEN8_DE_PIPE_IRQ(pipe)		(1 << (16 + (pipe)))
5404 #define  GEN8_GT_VECS_IRQ		(1 << 6)
5405 #define  GEN8_GT_GUC_IRQ		(1 << 5)
5406 #define  GEN8_GT_PM_IRQ			(1 << 4)
5407 #define  GEN8_GT_VCS1_IRQ		(1 << 3) /* NB: VCS2 in bspec! */
5408 #define  GEN8_GT_VCS0_IRQ		(1 << 2) /* NB: VCS1 in bpsec! */
5409 #define  GEN8_GT_BCS_IRQ		(1 << 1)
5410 #define  GEN8_GT_RCS_IRQ		(1 << 0)
5411 
5412 #define XELPD_DISPLAY_ERR_FATAL_MASK	_MMIO(0x4421c)
5413 
5414 #define GEN8_GT_ISR(which) _MMIO(0x44300 + (0x10 * (which)))
5415 #define GEN8_GT_IMR(which) _MMIO(0x44304 + (0x10 * (which)))
5416 #define GEN8_GT_IIR(which) _MMIO(0x44308 + (0x10 * (which)))
5417 #define GEN8_GT_IER(which) _MMIO(0x4430c + (0x10 * (which)))
5418 
5419 #define GEN8_RCS_IRQ_SHIFT 0
5420 #define GEN8_BCS_IRQ_SHIFT 16
5421 #define GEN8_VCS0_IRQ_SHIFT 0  /* NB: VCS1 in bspec! */
5422 #define GEN8_VCS1_IRQ_SHIFT 16 /* NB: VCS2 in bpsec! */
5423 #define GEN8_VECS_IRQ_SHIFT 0
5424 #define GEN8_WD_IRQ_SHIFT 16
5425 
5426 #define GEN8_DE_PIPE_ISR(pipe) _MMIO(0x44400 + (0x10 * (pipe)))
5427 #define GEN8_DE_PIPE_IMR(pipe) _MMIO(0x44404 + (0x10 * (pipe)))
5428 #define GEN8_DE_PIPE_IIR(pipe) _MMIO(0x44408 + (0x10 * (pipe)))
5429 #define GEN8_DE_PIPE_IER(pipe) _MMIO(0x4440c + (0x10 * (pipe)))
5430 #define  GEN8_PIPE_FIFO_UNDERRUN	(1 << 31)
5431 #define  GEN8_PIPE_CDCLK_CRC_ERROR	(1 << 29)
5432 #define  GEN8_PIPE_CDCLK_CRC_DONE	(1 << 28)
5433 #define  XELPD_PIPE_SOFT_UNDERRUN	(1 << 22)
5434 #define  XELPD_PIPE_HARD_UNDERRUN	(1 << 21)
5435 #define  GEN8_PIPE_CURSOR_FAULT		(1 << 10)
5436 #define  GEN8_PIPE_SPRITE_FAULT		(1 << 9)
5437 #define  GEN8_PIPE_PRIMARY_FAULT	(1 << 8)
5438 #define  GEN8_PIPE_SPRITE_FLIP_DONE	(1 << 5)
5439 #define  GEN8_PIPE_PRIMARY_FLIP_DONE	(1 << 4)
5440 #define  GEN8_PIPE_SCAN_LINE_EVENT	(1 << 2)
5441 #define  GEN8_PIPE_VSYNC		(1 << 1)
5442 #define  GEN8_PIPE_VBLANK		(1 << 0)
5443 #define  GEN9_PIPE_CURSOR_FAULT		(1 << 11)
5444 #define  GEN11_PIPE_PLANE7_FAULT	(1 << 22)
5445 #define  GEN11_PIPE_PLANE6_FAULT	(1 << 21)
5446 #define  GEN11_PIPE_PLANE5_FAULT	(1 << 20)
5447 #define  GEN9_PIPE_PLANE4_FAULT		(1 << 10)
5448 #define  GEN9_PIPE_PLANE3_FAULT		(1 << 9)
5449 #define  GEN9_PIPE_PLANE2_FAULT		(1 << 8)
5450 #define  GEN9_PIPE_PLANE1_FAULT		(1 << 7)
5451 #define  GEN9_PIPE_PLANE4_FLIP_DONE	(1 << 6)
5452 #define  GEN9_PIPE_PLANE3_FLIP_DONE	(1 << 5)
5453 #define  GEN9_PIPE_PLANE2_FLIP_DONE	(1 << 4)
5454 #define  GEN9_PIPE_PLANE1_FLIP_DONE	(1 << 3)
5455 #define  GEN9_PIPE_PLANE_FLIP_DONE(p)	(1 << (3 + (p)))
5456 #define GEN8_DE_PIPE_IRQ_FAULT_ERRORS \
5457 	(GEN8_PIPE_CURSOR_FAULT | \
5458 	 GEN8_PIPE_SPRITE_FAULT | \
5459 	 GEN8_PIPE_PRIMARY_FAULT)
5460 #define GEN9_DE_PIPE_IRQ_FAULT_ERRORS \
5461 	(GEN9_PIPE_CURSOR_FAULT | \
5462 	 GEN9_PIPE_PLANE4_FAULT | \
5463 	 GEN9_PIPE_PLANE3_FAULT | \
5464 	 GEN9_PIPE_PLANE2_FAULT | \
5465 	 GEN9_PIPE_PLANE1_FAULT)
5466 #define GEN11_DE_PIPE_IRQ_FAULT_ERRORS \
5467 	(GEN9_DE_PIPE_IRQ_FAULT_ERRORS | \
5468 	 GEN11_PIPE_PLANE7_FAULT | \
5469 	 GEN11_PIPE_PLANE6_FAULT | \
5470 	 GEN11_PIPE_PLANE5_FAULT)
5471 #define RKL_DE_PIPE_IRQ_FAULT_ERRORS \
5472 	(GEN9_DE_PIPE_IRQ_FAULT_ERRORS | \
5473 	 GEN11_PIPE_PLANE5_FAULT)
5474 
5475 #define _HPD_PIN_DDI(hpd_pin)	((hpd_pin) - HPD_PORT_A)
5476 #define _HPD_PIN_TC(hpd_pin)	((hpd_pin) - HPD_PORT_TC1)
5477 
5478 #define GEN8_DE_PORT_ISR _MMIO(0x44440)
5479 #define GEN8_DE_PORT_IMR _MMIO(0x44444)
5480 #define GEN8_DE_PORT_IIR _MMIO(0x44448)
5481 #define GEN8_DE_PORT_IER _MMIO(0x4444c)
5482 #define  DSI1_NON_TE			(1 << 31)
5483 #define  DSI0_NON_TE			(1 << 30)
5484 #define  ICL_AUX_CHANNEL_E		(1 << 29)
5485 #define  ICL_AUX_CHANNEL_F		(1 << 28)
5486 #define  GEN9_AUX_CHANNEL_D		(1 << 27)
5487 #define  GEN9_AUX_CHANNEL_C		(1 << 26)
5488 #define  GEN9_AUX_CHANNEL_B		(1 << 25)
5489 #define  DSI1_TE			(1 << 24)
5490 #define  DSI0_TE			(1 << 23)
5491 #define  GEN8_DE_PORT_HOTPLUG(hpd_pin)	REG_BIT(3 + _HPD_PIN_DDI(hpd_pin))
5492 #define  BXT_DE_PORT_HOTPLUG_MASK	(GEN8_DE_PORT_HOTPLUG(HPD_PORT_A) | \
5493 					 GEN8_DE_PORT_HOTPLUG(HPD_PORT_B) | \
5494 					 GEN8_DE_PORT_HOTPLUG(HPD_PORT_C))
5495 #define  BDW_DE_PORT_HOTPLUG_MASK	GEN8_DE_PORT_HOTPLUG(HPD_PORT_A)
5496 #define  BXT_DE_PORT_GMBUS		(1 << 1)
5497 #define  GEN8_AUX_CHANNEL_A		(1 << 0)
5498 #define  TGL_DE_PORT_AUX_USBC6		REG_BIT(13)
5499 #define  XELPD_DE_PORT_AUX_DDIE		REG_BIT(13)
5500 #define  TGL_DE_PORT_AUX_USBC5		REG_BIT(12)
5501 #define  XELPD_DE_PORT_AUX_DDID		REG_BIT(12)
5502 #define  TGL_DE_PORT_AUX_USBC4		REG_BIT(11)
5503 #define  TGL_DE_PORT_AUX_USBC3		REG_BIT(10)
5504 #define  TGL_DE_PORT_AUX_USBC2		REG_BIT(9)
5505 #define  TGL_DE_PORT_AUX_USBC1		REG_BIT(8)
5506 #define  TGL_DE_PORT_AUX_DDIC		REG_BIT(2)
5507 #define  TGL_DE_PORT_AUX_DDIB		REG_BIT(1)
5508 #define  TGL_DE_PORT_AUX_DDIA		REG_BIT(0)
5509 
5510 #define GEN8_DE_MISC_ISR _MMIO(0x44460)
5511 #define GEN8_DE_MISC_IMR _MMIO(0x44464)
5512 #define GEN8_DE_MISC_IIR _MMIO(0x44468)
5513 #define GEN8_DE_MISC_IER _MMIO(0x4446c)
5514 #define  GEN8_DE_MISC_GSE		(1 << 27)
5515 #define  GEN8_DE_EDP_PSR		(1 << 19)
5516 
5517 #define GEN8_PCU_ISR _MMIO(0x444e0)
5518 #define GEN8_PCU_IMR _MMIO(0x444e4)
5519 #define GEN8_PCU_IIR _MMIO(0x444e8)
5520 #define GEN8_PCU_IER _MMIO(0x444ec)
5521 
5522 #define GEN11_GU_MISC_ISR	_MMIO(0x444f0)
5523 #define GEN11_GU_MISC_IMR	_MMIO(0x444f4)
5524 #define GEN11_GU_MISC_IIR	_MMIO(0x444f8)
5525 #define GEN11_GU_MISC_IER	_MMIO(0x444fc)
5526 #define  GEN11_GU_MISC_GSE	(1 << 27)
5527 
5528 #define GEN11_GFX_MSTR_IRQ		_MMIO(0x190010)
5529 #define  GEN11_MASTER_IRQ		(1 << 31)
5530 #define  GEN11_PCU_IRQ			(1 << 30)
5531 #define  GEN11_GU_MISC_IRQ		(1 << 29)
5532 #define  GEN11_DISPLAY_IRQ		(1 << 16)
5533 #define  GEN11_GT_DW_IRQ(x)		(1 << (x))
5534 #define  GEN11_GT_DW1_IRQ		(1 << 1)
5535 #define  GEN11_GT_DW0_IRQ		(1 << 0)
5536 
5537 #define DG1_MSTR_TILE_INTR		_MMIO(0x190008)
5538 #define   DG1_MSTR_IRQ			REG_BIT(31)
5539 #define   DG1_MSTR_TILE(t)		REG_BIT(t)
5540 
5541 #define GEN11_DISPLAY_INT_CTL		_MMIO(0x44200)
5542 #define  GEN11_DISPLAY_IRQ_ENABLE	(1 << 31)
5543 #define  GEN11_AUDIO_CODEC_IRQ		(1 << 24)
5544 #define  GEN11_DE_PCH_IRQ		(1 << 23)
5545 #define  GEN11_DE_MISC_IRQ		(1 << 22)
5546 #define  GEN11_DE_HPD_IRQ		(1 << 21)
5547 #define  GEN11_DE_PORT_IRQ		(1 << 20)
5548 #define  GEN11_DE_PIPE_C		(1 << 18)
5549 #define  GEN11_DE_PIPE_B		(1 << 17)
5550 #define  GEN11_DE_PIPE_A		(1 << 16)
5551 
5552 #define GEN11_DE_HPD_ISR		_MMIO(0x44470)
5553 #define GEN11_DE_HPD_IMR		_MMIO(0x44474)
5554 #define GEN11_DE_HPD_IIR		_MMIO(0x44478)
5555 #define GEN11_DE_HPD_IER		_MMIO(0x4447c)
5556 #define  GEN11_TC_HOTPLUG(hpd_pin)		REG_BIT(16 + _HPD_PIN_TC(hpd_pin))
5557 #define  GEN11_DE_TC_HOTPLUG_MASK		(GEN11_TC_HOTPLUG(HPD_PORT_TC6) | \
5558 						 GEN11_TC_HOTPLUG(HPD_PORT_TC5) | \
5559 						 GEN11_TC_HOTPLUG(HPD_PORT_TC4) | \
5560 						 GEN11_TC_HOTPLUG(HPD_PORT_TC3) | \
5561 						 GEN11_TC_HOTPLUG(HPD_PORT_TC2) | \
5562 						 GEN11_TC_HOTPLUG(HPD_PORT_TC1))
5563 #define  GEN11_TBT_HOTPLUG(hpd_pin)		REG_BIT(_HPD_PIN_TC(hpd_pin))
5564 #define  GEN11_DE_TBT_HOTPLUG_MASK		(GEN11_TBT_HOTPLUG(HPD_PORT_TC6) | \
5565 						 GEN11_TBT_HOTPLUG(HPD_PORT_TC5) | \
5566 						 GEN11_TBT_HOTPLUG(HPD_PORT_TC4) | \
5567 						 GEN11_TBT_HOTPLUG(HPD_PORT_TC3) | \
5568 						 GEN11_TBT_HOTPLUG(HPD_PORT_TC2) | \
5569 						 GEN11_TBT_HOTPLUG(HPD_PORT_TC1))
5570 
5571 #define GEN11_TBT_HOTPLUG_CTL				_MMIO(0x44030)
5572 #define GEN11_TC_HOTPLUG_CTL				_MMIO(0x44038)
5573 #define  GEN11_HOTPLUG_CTL_ENABLE(hpd_pin)		(8 << (_HPD_PIN_TC(hpd_pin) * 4))
5574 #define  GEN11_HOTPLUG_CTL_LONG_DETECT(hpd_pin)		(2 << (_HPD_PIN_TC(hpd_pin) * 4))
5575 #define  GEN11_HOTPLUG_CTL_SHORT_DETECT(hpd_pin)	(1 << (_HPD_PIN_TC(hpd_pin) * 4))
5576 #define  GEN11_HOTPLUG_CTL_NO_DETECT(hpd_pin)		(0 << (_HPD_PIN_TC(hpd_pin) * 4))
5577 
5578 #define ILK_DISPLAY_CHICKEN2	_MMIO(0x42004)
5579 /* Required on all Ironlake and Sandybridge according to the B-Spec. */
5580 #define  ILK_ELPIN_409_SELECT	(1 << 25)
5581 #define  ILK_DPARB_GATE	(1 << 22)
5582 #define  ILK_VSDPFD_FULL	(1 << 21)
5583 #define FUSE_STRAP			_MMIO(0x42014)
5584 #define  ILK_INTERNAL_GRAPHICS_DISABLE	(1 << 31)
5585 #define  ILK_INTERNAL_DISPLAY_DISABLE	(1 << 30)
5586 #define  ILK_DISPLAY_DEBUG_DISABLE	(1 << 29)
5587 #define  IVB_PIPE_C_DISABLE		(1 << 28)
5588 #define  ILK_HDCP_DISABLE		(1 << 25)
5589 #define  ILK_eDP_A_DISABLE		(1 << 24)
5590 #define  HSW_CDCLK_LIMIT		(1 << 24)
5591 #define  ILK_DESKTOP			(1 << 23)
5592 #define  HSW_CPU_SSC_ENABLE		(1 << 21)
5593 
5594 #define FUSE_STRAP3			_MMIO(0x42020)
5595 #define  HSW_REF_CLK_SELECT		(1 << 1)
5596 
5597 #define ILK_DSPCLK_GATE_D			_MMIO(0x42020)
5598 #define   ILK_VRHUNIT_CLOCK_GATE_DISABLE	(1 << 28)
5599 #define   ILK_DPFCUNIT_CLOCK_GATE_DISABLE	(1 << 9)
5600 #define   ILK_DPFCRUNIT_CLOCK_GATE_DISABLE	(1 << 8)
5601 #define   ILK_DPFDUNIT_CLOCK_GATE_ENABLE	(1 << 7)
5602 #define   ILK_DPARBUNIT_CLOCK_GATE_ENABLE	(1 << 5)
5603 
5604 #define IVB_CHICKEN3	_MMIO(0x4200c)
5605 # define CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE	(1 << 5)
5606 # define CHICKEN3_DGMG_DONE_FIX_DISABLE		(1 << 2)
5607 
5608 #define CHICKEN_PAR1_1			_MMIO(0x42080)
5609 #define  IGNORE_KVMR_PIPE_A		REG_BIT(23)
5610 #define  KBL_ARB_FILL_SPARE_22		REG_BIT(22)
5611 #define  DIS_RAM_BYPASS_PSR2_MAN_TRACK	(1 << 16)
5612 #define  SKL_DE_COMPRESSED_HASH_MODE	(1 << 15)
5613 #define  DPA_MASK_VBLANK_SRD		(1 << 15)
5614 #define  FORCE_ARB_IDLE_PLANES		(1 << 14)
5615 #define  SKL_EDP_PSR_FIX_RDWRAP		(1 << 3)
5616 #define  IGNORE_PSR2_HW_TRACKING	(1 << 1)
5617 
5618 #define CHICKEN_PAR2_1		_MMIO(0x42090)
5619 #define  KVM_CONFIG_CHANGE_NOTIFICATION_SELECT	(1 << 14)
5620 
5621 #define CHICKEN_MISC_2		_MMIO(0x42084)
5622 #define  KBL_ARB_FILL_SPARE_14	REG_BIT(14)
5623 #define  KBL_ARB_FILL_SPARE_13	REG_BIT(13)
5624 #define  GLK_CL2_PWR_DOWN	(1 << 12)
5625 #define  GLK_CL1_PWR_DOWN	(1 << 11)
5626 #define  GLK_CL0_PWR_DOWN	(1 << 10)
5627 
5628 #define CHICKEN_MISC_4		_MMIO(0x4208c)
5629 #define   CHICKEN_FBC_STRIDE_OVERRIDE	REG_BIT(13)
5630 #define   CHICKEN_FBC_STRIDE_MASK	REG_GENMASK(12, 0)
5631 #define   CHICKEN_FBC_STRIDE(x)		REG_FIELD_PREP(CHICKEN_FBC_STRIDE_MASK, (x))
5632 
5633 #define _CHICKEN_PIPESL_1_A	0x420b0
5634 #define _CHICKEN_PIPESL_1_B	0x420b4
5635 #define  HSW_PRI_STRETCH_MAX_MASK	REG_GENMASK(28, 27)
5636 #define  HSW_PRI_STRETCH_MAX_X8		REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 0)
5637 #define  HSW_PRI_STRETCH_MAX_X4		REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 1)
5638 #define  HSW_PRI_STRETCH_MAX_X2		REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 2)
5639 #define  HSW_PRI_STRETCH_MAX_X1		REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 3)
5640 #define  HSW_SPR_STRETCH_MAX_MASK	REG_GENMASK(26, 25)
5641 #define  HSW_SPR_STRETCH_MAX_X8		REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 0)
5642 #define  HSW_SPR_STRETCH_MAX_X4		REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 1)
5643 #define  HSW_SPR_STRETCH_MAX_X2		REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 2)
5644 #define  HSW_SPR_STRETCH_MAX_X1		REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 3)
5645 #define  HSW_FBCQ_DIS			(1 << 22)
5646 #define  BDW_DPRS_MASK_VBLANK_SRD	(1 << 0)
5647 #define  SKL_PLANE1_STRETCH_MAX_MASK	REG_GENMASK(1, 0)
5648 #define  SKL_PLANE1_STRETCH_MAX_X8	REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 0)
5649 #define  SKL_PLANE1_STRETCH_MAX_X4	REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 1)
5650 #define  SKL_PLANE1_STRETCH_MAX_X2	REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 2)
5651 #define  SKL_PLANE1_STRETCH_MAX_X1	REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 3)
5652 #define CHICKEN_PIPESL_1(pipe) _MMIO_PIPE(pipe, _CHICKEN_PIPESL_1_A, _CHICKEN_PIPESL_1_B)
5653 
5654 #define _CHICKEN_TRANS_A	0x420c0
5655 #define _CHICKEN_TRANS_B	0x420c4
5656 #define _CHICKEN_TRANS_C	0x420c8
5657 #define _CHICKEN_TRANS_EDP	0x420cc
5658 #define _CHICKEN_TRANS_D	0x420d8
5659 #define CHICKEN_TRANS(trans)	_MMIO(_PICK((trans), \
5660 					    [TRANSCODER_EDP] = _CHICKEN_TRANS_EDP, \
5661 					    [TRANSCODER_A] = _CHICKEN_TRANS_A, \
5662 					    [TRANSCODER_B] = _CHICKEN_TRANS_B, \
5663 					    [TRANSCODER_C] = _CHICKEN_TRANS_C, \
5664 					    [TRANSCODER_D] = _CHICKEN_TRANS_D))
5665 
5666 #define _MTL_CHICKEN_TRANS_A	0x604e0
5667 #define _MTL_CHICKEN_TRANS_B	0x614e0
5668 #define MTL_CHICKEN_TRANS(trans)	_MMIO_TRANS((trans), \
5669 						    _MTL_CHICKEN_TRANS_A, \
5670 						    _MTL_CHICKEN_TRANS_B)
5671 
5672 #define  HSW_FRAME_START_DELAY_MASK	REG_GENMASK(28, 27)
5673 #define  HSW_FRAME_START_DELAY(x)	REG_FIELD_PREP(HSW_FRAME_START_DELAY_MASK, x)
5674 #define  VSC_DATA_SEL_SOFTWARE_CONTROL	REG_BIT(25) /* GLK */
5675 #define  FECSTALL_DIS_DPTSTREAM_DPTTG	REG_BIT(23)
5676 #define  DDI_TRAINING_OVERRIDE_ENABLE	REG_BIT(19)
5677 #define  ADLP_1_BASED_X_GRANULARITY	REG_BIT(18)
5678 #define  DDI_TRAINING_OVERRIDE_VALUE	REG_BIT(18)
5679 #define  DDIE_TRAINING_OVERRIDE_ENABLE	REG_BIT(17) /* CHICKEN_TRANS_A only */
5680 #define  DDIE_TRAINING_OVERRIDE_VALUE	REG_BIT(16) /* CHICKEN_TRANS_A only */
5681 #define  PSR2_ADD_VERTICAL_LINE_COUNT	REG_BIT(15)
5682 #define  PSR2_VSC_ENABLE_PROG_HEADER	REG_BIT(12)
5683 
5684 #define DISP_ARB_CTL	_MMIO(0x45000)
5685 #define  DISP_FBC_MEMORY_WAKE		(1 << 31)
5686 #define  DISP_TILE_SURFACE_SWIZZLING	(1 << 13)
5687 #define  DISP_FBC_WM_DIS		(1 << 15)
5688 #define DISP_ARB_CTL2	_MMIO(0x45004)
5689 #define  DISP_DATA_PARTITION_5_6	(1 << 6)
5690 #define  DISP_IPC_ENABLE		(1 << 3)
5691 
5692 /*
5693  * The below are numbered starting from "S1" on gen11/gen12, but starting
5694  * with display 13, the bspec switches to a 0-based numbering scheme
5695  * (although the addresses stay the same so new S0 = old S1, new S1 = old S2).
5696  * We'll just use the 0-based numbering here for all platforms since it's the
5697  * way things will be named by the hardware team going forward, plus it's more
5698  * consistent with how most of the rest of our registers are named.
5699  */
5700 #define _DBUF_CTL_S0				0x45008
5701 #define _DBUF_CTL_S1				0x44FE8
5702 #define _DBUF_CTL_S2				0x44300
5703 #define _DBUF_CTL_S3				0x44304
5704 #define DBUF_CTL_S(slice)			_MMIO(_PICK(slice, \
5705 							    _DBUF_CTL_S0, \
5706 							    _DBUF_CTL_S1, \
5707 							    _DBUF_CTL_S2, \
5708 							    _DBUF_CTL_S3))
5709 #define  DBUF_POWER_REQUEST			REG_BIT(31)
5710 #define  DBUF_POWER_STATE			REG_BIT(30)
5711 #define  DBUF_TRACKER_STATE_SERVICE_MASK	REG_GENMASK(23, 19)
5712 #define  DBUF_TRACKER_STATE_SERVICE(x)		REG_FIELD_PREP(DBUF_TRACKER_STATE_SERVICE_MASK, x)
5713 #define  DBUF_MIN_TRACKER_STATE_SERVICE_MASK	REG_GENMASK(18, 16) /* ADL-P+ */
5714 #define  DBUF_MIN_TRACKER_STATE_SERVICE(x)		REG_FIELD_PREP(DBUF_MIN_TRACKER_STATE_SERVICE_MASK, x) /* ADL-P+ */
5715 
5716 #define GEN7_MSG_CTL	_MMIO(0x45010)
5717 #define  WAIT_FOR_PCH_RESET_ACK		(1 << 1)
5718 #define  WAIT_FOR_PCH_FLR_ACK		(1 << 0)
5719 
5720 #define _BW_BUDDY0_CTL			0x45130
5721 #define _BW_BUDDY1_CTL			0x45140
5722 #define BW_BUDDY_CTL(x)			_MMIO(_PICK_EVEN(x, \
5723 							 _BW_BUDDY0_CTL, \
5724 							 _BW_BUDDY1_CTL))
5725 #define   BW_BUDDY_DISABLE		REG_BIT(31)
5726 #define   BW_BUDDY_TLB_REQ_TIMER_MASK	REG_GENMASK(21, 16)
5727 #define   BW_BUDDY_TLB_REQ_TIMER(x)	REG_FIELD_PREP(BW_BUDDY_TLB_REQ_TIMER_MASK, x)
5728 
5729 #define _BW_BUDDY0_PAGE_MASK		0x45134
5730 #define _BW_BUDDY1_PAGE_MASK		0x45144
5731 #define BW_BUDDY_PAGE_MASK(x)		_MMIO(_PICK_EVEN(x, \
5732 							 _BW_BUDDY0_PAGE_MASK, \
5733 							 _BW_BUDDY1_PAGE_MASK))
5734 
5735 #define HSW_NDE_RSTWRN_OPT	_MMIO(0x46408)
5736 #define  MTL_RESET_PICA_HANDSHAKE_EN	REG_BIT(6)
5737 #define  RESET_PCH_HANDSHAKE_ENABLE	REG_BIT(4)
5738 
5739 #define GEN8_CHICKEN_DCPR_1			_MMIO(0x46430)
5740 #define   LATENCY_REPORTING_REMOVED_PIPE_D	REG_BIT(31)
5741 #define   SKL_SELECT_ALTERNATE_DC_EXIT		REG_BIT(30)
5742 #define   LATENCY_REPORTING_REMOVED_PIPE_C	REG_BIT(25)
5743 #define   LATENCY_REPORTING_REMOVED_PIPE_B	REG_BIT(24)
5744 #define   LATENCY_REPORTING_REMOVED_PIPE_A	REG_BIT(23)
5745 #define   ICL_DELAY_PMRSP			REG_BIT(22)
5746 #define   DISABLE_FLR_SRC			REG_BIT(15)
5747 #define   MASK_WAKEMEM				REG_BIT(13)
5748 #define   DDI_CLOCK_REG_ACCESS			REG_BIT(7)
5749 
5750 #define GEN11_CHICKEN_DCPR_2			_MMIO(0x46434)
5751 #define   DCPR_MASK_MAXLATENCY_MEMUP_CLR	REG_BIT(27)
5752 #define   DCPR_MASK_LPMODE			REG_BIT(26)
5753 #define   DCPR_SEND_RESP_IMM			REG_BIT(25)
5754 #define   DCPR_CLEAR_MEMSTAT_DIS		REG_BIT(24)
5755 
5756 #define SKL_DFSM			_MMIO(0x51000)
5757 #define   SKL_DFSM_DISPLAY_PM_DISABLE	(1 << 27)
5758 #define   SKL_DFSM_DISPLAY_HDCP_DISABLE	(1 << 25)
5759 #define   SKL_DFSM_CDCLK_LIMIT_MASK	(3 << 23)
5760 #define   SKL_DFSM_CDCLK_LIMIT_675	(0 << 23)
5761 #define   SKL_DFSM_CDCLK_LIMIT_540	(1 << 23)
5762 #define   SKL_DFSM_CDCLK_LIMIT_450	(2 << 23)
5763 #define   SKL_DFSM_CDCLK_LIMIT_337_5	(3 << 23)
5764 #define   ICL_DFSM_DMC_DISABLE		(1 << 23)
5765 #define   SKL_DFSM_PIPE_A_DISABLE	(1 << 30)
5766 #define   SKL_DFSM_PIPE_B_DISABLE	(1 << 21)
5767 #define   SKL_DFSM_PIPE_C_DISABLE	(1 << 28)
5768 #define   TGL_DFSM_PIPE_D_DISABLE	(1 << 22)
5769 #define   GLK_DFSM_DISPLAY_DSC_DISABLE	(1 << 7)
5770 
5771 #define SKL_DSSM				_MMIO(0x51004)
5772 #define ICL_DSSM_CDCLK_PLL_REFCLK_MASK		(7 << 29)
5773 #define ICL_DSSM_CDCLK_PLL_REFCLK_24MHz		(0 << 29)
5774 #define ICL_DSSM_CDCLK_PLL_REFCLK_19_2MHz	(1 << 29)
5775 #define ICL_DSSM_CDCLK_PLL_REFCLK_38_4MHz	(2 << 29)
5776 
5777 #define GMD_ID_DISPLAY				_MMIO(0x510a0)
5778 #define   GMD_ID_ARCH_MASK			REG_GENMASK(31, 22)
5779 #define   GMD_ID_RELEASE_MASK			REG_GENMASK(21, 14)
5780 #define   GMD_ID_STEP				REG_GENMASK(5, 0)
5781 
5782 /*GEN11 chicken */
5783 #define _PIPEA_CHICKEN				0x70038
5784 #define _PIPEB_CHICKEN				0x71038
5785 #define _PIPEC_CHICKEN				0x72038
5786 #define PIPE_CHICKEN(pipe)			_MMIO_PIPE(pipe, _PIPEA_CHICKEN,\
5787 							   _PIPEB_CHICKEN)
5788 #define   UNDERRUN_RECOVERY_DISABLE_ADLP	REG_BIT(30)
5789 #define   UNDERRUN_RECOVERY_ENABLE_DG2		REG_BIT(30)
5790 #define   PIXEL_ROUNDING_TRUNC_FB_PASSTHRU	REG_BIT(15)
5791 #define   DG2_RENDER_CCSTAG_4_3_EN		REG_BIT(12)
5792 #define   PER_PIXEL_ALPHA_BYPASS_EN		REG_BIT(7)
5793 
5794 /* PCH */
5795 
5796 #define PCH_DISPLAY_BASE	0xc0000u
5797 
5798 /* south display engine interrupt: IBX */
5799 #define SDE_AUDIO_POWER_D	(1 << 27)
5800 #define SDE_AUDIO_POWER_C	(1 << 26)
5801 #define SDE_AUDIO_POWER_B	(1 << 25)
5802 #define SDE_AUDIO_POWER_SHIFT	(25)
5803 #define SDE_AUDIO_POWER_MASK	(7 << SDE_AUDIO_POWER_SHIFT)
5804 #define SDE_GMBUS		(1 << 24)
5805 #define SDE_AUDIO_HDCP_TRANSB	(1 << 23)
5806 #define SDE_AUDIO_HDCP_TRANSA	(1 << 22)
5807 #define SDE_AUDIO_HDCP_MASK	(3 << 22)
5808 #define SDE_AUDIO_TRANSB	(1 << 21)
5809 #define SDE_AUDIO_TRANSA	(1 << 20)
5810 #define SDE_AUDIO_TRANS_MASK	(3 << 20)
5811 #define SDE_POISON		(1 << 19)
5812 /* 18 reserved */
5813 #define SDE_FDI_RXB		(1 << 17)
5814 #define SDE_FDI_RXA		(1 << 16)
5815 #define SDE_FDI_MASK		(3 << 16)
5816 #define SDE_AUXD		(1 << 15)
5817 #define SDE_AUXC		(1 << 14)
5818 #define SDE_AUXB		(1 << 13)
5819 #define SDE_AUX_MASK		(7 << 13)
5820 /* 12 reserved */
5821 #define SDE_CRT_HOTPLUG         (1 << 11)
5822 #define SDE_PORTD_HOTPLUG       (1 << 10)
5823 #define SDE_PORTC_HOTPLUG       (1 << 9)
5824 #define SDE_PORTB_HOTPLUG       (1 << 8)
5825 #define SDE_SDVOB_HOTPLUG       (1 << 6)
5826 #define SDE_HOTPLUG_MASK        (SDE_CRT_HOTPLUG | \
5827 				 SDE_SDVOB_HOTPLUG |	\
5828 				 SDE_PORTB_HOTPLUG |	\
5829 				 SDE_PORTC_HOTPLUG |	\
5830 				 SDE_PORTD_HOTPLUG)
5831 #define SDE_TRANSB_CRC_DONE	(1 << 5)
5832 #define SDE_TRANSB_CRC_ERR	(1 << 4)
5833 #define SDE_TRANSB_FIFO_UNDER	(1 << 3)
5834 #define SDE_TRANSA_CRC_DONE	(1 << 2)
5835 #define SDE_TRANSA_CRC_ERR	(1 << 1)
5836 #define SDE_TRANSA_FIFO_UNDER	(1 << 0)
5837 #define SDE_TRANS_MASK		(0x3f)
5838 
5839 /* south display engine interrupt: CPT - CNP */
5840 #define SDE_AUDIO_POWER_D_CPT	(1 << 31)
5841 #define SDE_AUDIO_POWER_C_CPT	(1 << 30)
5842 #define SDE_AUDIO_POWER_B_CPT	(1 << 29)
5843 #define SDE_AUDIO_POWER_SHIFT_CPT   29
5844 #define SDE_AUDIO_POWER_MASK_CPT    (7 << 29)
5845 #define SDE_AUXD_CPT		(1 << 27)
5846 #define SDE_AUXC_CPT		(1 << 26)
5847 #define SDE_AUXB_CPT		(1 << 25)
5848 #define SDE_AUX_MASK_CPT	(7 << 25)
5849 #define SDE_PORTE_HOTPLUG_SPT	(1 << 25)
5850 #define SDE_PORTA_HOTPLUG_SPT	(1 << 24)
5851 #define SDE_PORTD_HOTPLUG_CPT	(1 << 23)
5852 #define SDE_PORTC_HOTPLUG_CPT	(1 << 22)
5853 #define SDE_PORTB_HOTPLUG_CPT	(1 << 21)
5854 #define SDE_CRT_HOTPLUG_CPT	(1 << 19)
5855 #define SDE_SDVOB_HOTPLUG_CPT	(1 << 18)
5856 #define SDE_HOTPLUG_MASK_CPT	(SDE_CRT_HOTPLUG_CPT |		\
5857 				 SDE_SDVOB_HOTPLUG_CPT |	\
5858 				 SDE_PORTD_HOTPLUG_CPT |	\
5859 				 SDE_PORTC_HOTPLUG_CPT |	\
5860 				 SDE_PORTB_HOTPLUG_CPT)
5861 #define SDE_HOTPLUG_MASK_SPT	(SDE_PORTE_HOTPLUG_SPT |	\
5862 				 SDE_PORTD_HOTPLUG_CPT |	\
5863 				 SDE_PORTC_HOTPLUG_CPT |	\
5864 				 SDE_PORTB_HOTPLUG_CPT |	\
5865 				 SDE_PORTA_HOTPLUG_SPT)
5866 #define SDE_GMBUS_CPT		(1 << 17)
5867 #define SDE_ERROR_CPT		(1 << 16)
5868 #define SDE_AUDIO_CP_REQ_C_CPT	(1 << 10)
5869 #define SDE_AUDIO_CP_CHG_C_CPT	(1 << 9)
5870 #define SDE_FDI_RXC_CPT		(1 << 8)
5871 #define SDE_AUDIO_CP_REQ_B_CPT	(1 << 6)
5872 #define SDE_AUDIO_CP_CHG_B_CPT	(1 << 5)
5873 #define SDE_FDI_RXB_CPT		(1 << 4)
5874 #define SDE_AUDIO_CP_REQ_A_CPT	(1 << 2)
5875 #define SDE_AUDIO_CP_CHG_A_CPT	(1 << 1)
5876 #define SDE_FDI_RXA_CPT		(1 << 0)
5877 #define SDE_AUDIO_CP_REQ_CPT	(SDE_AUDIO_CP_REQ_C_CPT | \
5878 				 SDE_AUDIO_CP_REQ_B_CPT | \
5879 				 SDE_AUDIO_CP_REQ_A_CPT)
5880 #define SDE_AUDIO_CP_CHG_CPT	(SDE_AUDIO_CP_CHG_C_CPT | \
5881 				 SDE_AUDIO_CP_CHG_B_CPT | \
5882 				 SDE_AUDIO_CP_CHG_A_CPT)
5883 #define SDE_FDI_MASK_CPT	(SDE_FDI_RXC_CPT | \
5884 				 SDE_FDI_RXB_CPT | \
5885 				 SDE_FDI_RXA_CPT)
5886 
5887 /* south display engine interrupt: ICP/TGP */
5888 #define SDE_GMBUS_ICP			(1 << 23)
5889 #define SDE_TC_HOTPLUG_ICP(hpd_pin)	REG_BIT(24 + _HPD_PIN_TC(hpd_pin))
5890 #define SDE_TC_HOTPLUG_DG2(hpd_pin)	REG_BIT(25 + _HPD_PIN_TC(hpd_pin)) /* sigh */
5891 #define SDE_DDI_HOTPLUG_ICP(hpd_pin)	REG_BIT(16 + _HPD_PIN_DDI(hpd_pin))
5892 #define SDE_DDI_HOTPLUG_MASK_ICP	(SDE_DDI_HOTPLUG_ICP(HPD_PORT_D) | \
5893 					 SDE_DDI_HOTPLUG_ICP(HPD_PORT_C) | \
5894 					 SDE_DDI_HOTPLUG_ICP(HPD_PORT_B) | \
5895 					 SDE_DDI_HOTPLUG_ICP(HPD_PORT_A))
5896 #define SDE_TC_HOTPLUG_MASK_ICP		(SDE_TC_HOTPLUG_ICP(HPD_PORT_TC6) | \
5897 					 SDE_TC_HOTPLUG_ICP(HPD_PORT_TC5) | \
5898 					 SDE_TC_HOTPLUG_ICP(HPD_PORT_TC4) | \
5899 					 SDE_TC_HOTPLUG_ICP(HPD_PORT_TC3) | \
5900 					 SDE_TC_HOTPLUG_ICP(HPD_PORT_TC2) | \
5901 					 SDE_TC_HOTPLUG_ICP(HPD_PORT_TC1))
5902 
5903 #define SDEISR  _MMIO(0xc4000)
5904 #define SDEIMR  _MMIO(0xc4004)
5905 #define SDEIIR  _MMIO(0xc4008)
5906 #define SDEIER  _MMIO(0xc400c)
5907 
5908 #define SERR_INT			_MMIO(0xc4040)
5909 #define  SERR_INT_POISON		(1 << 31)
5910 #define  SERR_INT_TRANS_FIFO_UNDERRUN(pipe)	(1 << ((pipe) * 3))
5911 
5912 /* digital port hotplug */
5913 #define PCH_PORT_HOTPLUG		_MMIO(0xc4030)	/* SHOTPLUG_CTL */
5914 #define  PORTA_HOTPLUG_ENABLE		(1 << 28) /* LPT:LP+ & BXT */
5915 #define  BXT_DDIA_HPD_INVERT            (1 << 27)
5916 #define  PORTA_HOTPLUG_STATUS_MASK	(3 << 24) /* SPT+ & BXT */
5917 #define  PORTA_HOTPLUG_NO_DETECT	(0 << 24) /* SPT+ & BXT */
5918 #define  PORTA_HOTPLUG_SHORT_DETECT	(1 << 24) /* SPT+ & BXT */
5919 #define  PORTA_HOTPLUG_LONG_DETECT	(2 << 24) /* SPT+ & BXT */
5920 #define  PORTD_HOTPLUG_ENABLE		(1 << 20)
5921 #define  PORTD_PULSE_DURATION_2ms	(0 << 18) /* pre-LPT */
5922 #define  PORTD_PULSE_DURATION_4_5ms	(1 << 18) /* pre-LPT */
5923 #define  PORTD_PULSE_DURATION_6ms	(2 << 18) /* pre-LPT */
5924 #define  PORTD_PULSE_DURATION_100ms	(3 << 18) /* pre-LPT */
5925 #define  PORTD_PULSE_DURATION_MASK	(3 << 18) /* pre-LPT */
5926 #define  PORTD_HOTPLUG_STATUS_MASK	(3 << 16)
5927 #define  PORTD_HOTPLUG_NO_DETECT	(0 << 16)
5928 #define  PORTD_HOTPLUG_SHORT_DETECT	(1 << 16)
5929 #define  PORTD_HOTPLUG_LONG_DETECT	(2 << 16)
5930 #define  PORTC_HOTPLUG_ENABLE		(1 << 12)
5931 #define  BXT_DDIC_HPD_INVERT            (1 << 11)
5932 #define  PORTC_PULSE_DURATION_2ms	(0 << 10) /* pre-LPT */
5933 #define  PORTC_PULSE_DURATION_4_5ms	(1 << 10) /* pre-LPT */
5934 #define  PORTC_PULSE_DURATION_6ms	(2 << 10) /* pre-LPT */
5935 #define  PORTC_PULSE_DURATION_100ms	(3 << 10) /* pre-LPT */
5936 #define  PORTC_PULSE_DURATION_MASK	(3 << 10) /* pre-LPT */
5937 #define  PORTC_HOTPLUG_STATUS_MASK	(3 << 8)
5938 #define  PORTC_HOTPLUG_NO_DETECT	(0 << 8)
5939 #define  PORTC_HOTPLUG_SHORT_DETECT	(1 << 8)
5940 #define  PORTC_HOTPLUG_LONG_DETECT	(2 << 8)
5941 #define  PORTB_HOTPLUG_ENABLE		(1 << 4)
5942 #define  BXT_DDIB_HPD_INVERT            (1 << 3)
5943 #define  PORTB_PULSE_DURATION_2ms	(0 << 2) /* pre-LPT */
5944 #define  PORTB_PULSE_DURATION_4_5ms	(1 << 2) /* pre-LPT */
5945 #define  PORTB_PULSE_DURATION_6ms	(2 << 2) /* pre-LPT */
5946 #define  PORTB_PULSE_DURATION_100ms	(3 << 2) /* pre-LPT */
5947 #define  PORTB_PULSE_DURATION_MASK	(3 << 2) /* pre-LPT */
5948 #define  PORTB_HOTPLUG_STATUS_MASK	(3 << 0)
5949 #define  PORTB_HOTPLUG_NO_DETECT	(0 << 0)
5950 #define  PORTB_HOTPLUG_SHORT_DETECT	(1 << 0)
5951 #define  PORTB_HOTPLUG_LONG_DETECT	(2 << 0)
5952 #define  BXT_DDI_HPD_INVERT_MASK	(BXT_DDIA_HPD_INVERT | \
5953 					BXT_DDIB_HPD_INVERT | \
5954 					BXT_DDIC_HPD_INVERT)
5955 
5956 #define PCH_PORT_HOTPLUG2		_MMIO(0xc403C)	/* SHOTPLUG_CTL2 SPT+ */
5957 #define  PORTE_HOTPLUG_ENABLE		(1 << 4)
5958 #define  PORTE_HOTPLUG_STATUS_MASK	(3 << 0)
5959 #define  PORTE_HOTPLUG_NO_DETECT	(0 << 0)
5960 #define  PORTE_HOTPLUG_SHORT_DETECT	(1 << 0)
5961 #define  PORTE_HOTPLUG_LONG_DETECT	(2 << 0)
5962 
5963 /* This register is a reuse of PCH_PORT_HOTPLUG register. The
5964  * functionality covered in PCH_PORT_HOTPLUG is split into
5965  * SHOTPLUG_CTL_DDI and SHOTPLUG_CTL_TC.
5966  */
5967 
5968 #define SHOTPLUG_CTL_DDI				_MMIO(0xc4030)
5969 #define   SHOTPLUG_CTL_DDI_HPD_ENABLE(hpd_pin)			(0x8 << (_HPD_PIN_DDI(hpd_pin) * 4))
5970 #define   SHOTPLUG_CTL_DDI_HPD_OUTPUT_DATA(hpd_pin)		(0x4 << (_HPD_PIN_DDI(hpd_pin) * 4))
5971 #define   SHOTPLUG_CTL_DDI_HPD_STATUS_MASK(hpd_pin)		(0x3 << (_HPD_PIN_DDI(hpd_pin) * 4))
5972 #define   SHOTPLUG_CTL_DDI_HPD_NO_DETECT(hpd_pin)		(0x0 << (_HPD_PIN_DDI(hpd_pin) * 4))
5973 #define   SHOTPLUG_CTL_DDI_HPD_SHORT_DETECT(hpd_pin)		(0x1 << (_HPD_PIN_DDI(hpd_pin) * 4))
5974 #define   SHOTPLUG_CTL_DDI_HPD_LONG_DETECT(hpd_pin)		(0x2 << (_HPD_PIN_DDI(hpd_pin) * 4))
5975 #define   SHOTPLUG_CTL_DDI_HPD_SHORT_LONG_DETECT(hpd_pin)	(0x3 << (_HPD_PIN_DDI(hpd_pin) * 4))
5976 
5977 #define SHOTPLUG_CTL_TC				_MMIO(0xc4034)
5978 #define   ICP_TC_HPD_ENABLE(hpd_pin)		(8 << (_HPD_PIN_TC(hpd_pin) * 4))
5979 #define   ICP_TC_HPD_LONG_DETECT(hpd_pin)	(2 << (_HPD_PIN_TC(hpd_pin) * 4))
5980 #define   ICP_TC_HPD_SHORT_DETECT(hpd_pin)	(1 << (_HPD_PIN_TC(hpd_pin) * 4))
5981 
5982 #define SHPD_FILTER_CNT				_MMIO(0xc4038)
5983 #define   SHPD_FILTER_CNT_500_ADJ		0x001D9
5984 
5985 #define _PCH_DPLL_A              0xc6014
5986 #define _PCH_DPLL_B              0xc6018
5987 #define PCH_DPLL(pll) _MMIO((pll) == 0 ? _PCH_DPLL_A : _PCH_DPLL_B)
5988 
5989 #define _PCH_FPA0                0xc6040
5990 #define  FP_CB_TUNE		(0x3 << 22)
5991 #define _PCH_FPA1                0xc6044
5992 #define _PCH_FPB0                0xc6048
5993 #define _PCH_FPB1                0xc604c
5994 #define PCH_FP0(pll) _MMIO((pll) == 0 ? _PCH_FPA0 : _PCH_FPB0)
5995 #define PCH_FP1(pll) _MMIO((pll) == 0 ? _PCH_FPA1 : _PCH_FPB1)
5996 
5997 #define PCH_DPLL_TEST           _MMIO(0xc606c)
5998 
5999 #define PCH_DREF_CONTROL        _MMIO(0xC6200)
6000 #define  DREF_CONTROL_MASK      0x7fc3
6001 #define  DREF_CPU_SOURCE_OUTPUT_DISABLE         (0 << 13)
6002 #define  DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD      (2 << 13)
6003 #define  DREF_CPU_SOURCE_OUTPUT_NONSPREAD       (3 << 13)
6004 #define  DREF_CPU_SOURCE_OUTPUT_MASK		(3 << 13)
6005 #define  DREF_SSC_SOURCE_DISABLE                (0 << 11)
6006 #define  DREF_SSC_SOURCE_ENABLE                 (2 << 11)
6007 #define  DREF_SSC_SOURCE_MASK			(3 << 11)
6008 #define  DREF_NONSPREAD_SOURCE_DISABLE          (0 << 9)
6009 #define  DREF_NONSPREAD_CK505_ENABLE		(1 << 9)
6010 #define  DREF_NONSPREAD_SOURCE_ENABLE           (2 << 9)
6011 #define  DREF_NONSPREAD_SOURCE_MASK		(3 << 9)
6012 #define  DREF_SUPERSPREAD_SOURCE_DISABLE        (0 << 7)
6013 #define  DREF_SUPERSPREAD_SOURCE_ENABLE         (2 << 7)
6014 #define  DREF_SUPERSPREAD_SOURCE_MASK		(3 << 7)
6015 #define  DREF_SSC4_DOWNSPREAD                   (0 << 6)
6016 #define  DREF_SSC4_CENTERSPREAD                 (1 << 6)
6017 #define  DREF_SSC1_DISABLE                      (0 << 1)
6018 #define  DREF_SSC1_ENABLE                       (1 << 1)
6019 #define  DREF_SSC4_DISABLE                      (0)
6020 #define  DREF_SSC4_ENABLE                       (1)
6021 
6022 #define PCH_RAWCLK_FREQ         _MMIO(0xc6204)
6023 #define  FDL_TP1_TIMER_SHIFT    12
6024 #define  FDL_TP1_TIMER_MASK     (3 << 12)
6025 #define  FDL_TP2_TIMER_SHIFT    10
6026 #define  FDL_TP2_TIMER_MASK     (3 << 10)
6027 #define  RAWCLK_FREQ_MASK       0x3ff
6028 #define  CNP_RAWCLK_DIV_MASK	(0x3ff << 16)
6029 #define  CNP_RAWCLK_DIV(div)	((div) << 16)
6030 #define  CNP_RAWCLK_FRAC_MASK	(0xf << 26)
6031 #define  CNP_RAWCLK_DEN(den)	((den) << 26)
6032 #define  ICP_RAWCLK_NUM(num)	((num) << 11)
6033 
6034 #define PCH_DPLL_TMR_CFG        _MMIO(0xc6208)
6035 
6036 #define PCH_SSC4_PARMS          _MMIO(0xc6210)
6037 #define PCH_SSC4_AUX_PARMS      _MMIO(0xc6214)
6038 
6039 #define PCH_DPLL_SEL		_MMIO(0xc7000)
6040 #define	 TRANS_DPLLB_SEL(pipe)		(1 << ((pipe) * 4))
6041 #define	 TRANS_DPLLA_SEL(pipe)		0
6042 #define  TRANS_DPLL_ENABLE(pipe)	(1 << ((pipe) * 4 + 3))
6043 
6044 /* transcoder */
6045 
6046 #define _PCH_TRANS_HTOTAL_A		0xe0000
6047 #define  TRANS_HTOTAL_SHIFT		16
6048 #define  TRANS_HACTIVE_SHIFT		0
6049 #define _PCH_TRANS_HBLANK_A		0xe0004
6050 #define  TRANS_HBLANK_END_SHIFT		16
6051 #define  TRANS_HBLANK_START_SHIFT	0
6052 #define _PCH_TRANS_HSYNC_A		0xe0008
6053 #define  TRANS_HSYNC_END_SHIFT		16
6054 #define  TRANS_HSYNC_START_SHIFT	0
6055 #define _PCH_TRANS_VTOTAL_A		0xe000c
6056 #define  TRANS_VTOTAL_SHIFT		16
6057 #define  TRANS_VACTIVE_SHIFT		0
6058 #define _PCH_TRANS_VBLANK_A		0xe0010
6059 #define  TRANS_VBLANK_END_SHIFT		16
6060 #define  TRANS_VBLANK_START_SHIFT	0
6061 #define _PCH_TRANS_VSYNC_A		0xe0014
6062 #define  TRANS_VSYNC_END_SHIFT		16
6063 #define  TRANS_VSYNC_START_SHIFT	0
6064 #define _PCH_TRANS_VSYNCSHIFT_A		0xe0028
6065 
6066 #define _PCH_TRANSA_DATA_M1	0xe0030
6067 #define _PCH_TRANSA_DATA_N1	0xe0034
6068 #define _PCH_TRANSA_DATA_M2	0xe0038
6069 #define _PCH_TRANSA_DATA_N2	0xe003c
6070 #define _PCH_TRANSA_LINK_M1	0xe0040
6071 #define _PCH_TRANSA_LINK_N1	0xe0044
6072 #define _PCH_TRANSA_LINK_M2	0xe0048
6073 #define _PCH_TRANSA_LINK_N2	0xe004c
6074 
6075 /* Per-transcoder DIP controls (PCH) */
6076 #define _VIDEO_DIP_CTL_A         0xe0200
6077 #define _VIDEO_DIP_DATA_A        0xe0208
6078 #define _VIDEO_DIP_GCP_A         0xe0210
6079 #define  GCP_COLOR_INDICATION		(1 << 2)
6080 #define  GCP_DEFAULT_PHASE_ENABLE	(1 << 1)
6081 #define  GCP_AV_MUTE			(1 << 0)
6082 
6083 #define _VIDEO_DIP_CTL_B         0xe1200
6084 #define _VIDEO_DIP_DATA_B        0xe1208
6085 #define _VIDEO_DIP_GCP_B         0xe1210
6086 
6087 #define TVIDEO_DIP_CTL(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_CTL_A, _VIDEO_DIP_CTL_B)
6088 #define TVIDEO_DIP_DATA(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_DATA_A, _VIDEO_DIP_DATA_B)
6089 #define TVIDEO_DIP_GCP(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_GCP_A, _VIDEO_DIP_GCP_B)
6090 
6091 /* Per-transcoder DIP controls (VLV) */
6092 #define _VLV_VIDEO_DIP_CTL_A		(VLV_DISPLAY_BASE + 0x60200)
6093 #define _VLV_VIDEO_DIP_DATA_A		(VLV_DISPLAY_BASE + 0x60208)
6094 #define _VLV_VIDEO_DIP_GDCP_PAYLOAD_A	(VLV_DISPLAY_BASE + 0x60210)
6095 
6096 #define _VLV_VIDEO_DIP_CTL_B		(VLV_DISPLAY_BASE + 0x61170)
6097 #define _VLV_VIDEO_DIP_DATA_B		(VLV_DISPLAY_BASE + 0x61174)
6098 #define _VLV_VIDEO_DIP_GDCP_PAYLOAD_B	(VLV_DISPLAY_BASE + 0x61178)
6099 
6100 #define _CHV_VIDEO_DIP_CTL_C		(VLV_DISPLAY_BASE + 0x611f0)
6101 #define _CHV_VIDEO_DIP_DATA_C		(VLV_DISPLAY_BASE + 0x611f4)
6102 #define _CHV_VIDEO_DIP_GDCP_PAYLOAD_C	(VLV_DISPLAY_BASE + 0x611f8)
6103 
6104 #define VLV_TVIDEO_DIP_CTL(pipe) \
6105 	_MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_CTL_A, \
6106 	       _VLV_VIDEO_DIP_CTL_B, _CHV_VIDEO_DIP_CTL_C)
6107 #define VLV_TVIDEO_DIP_DATA(pipe) \
6108 	_MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_DATA_A, \
6109 	       _VLV_VIDEO_DIP_DATA_B, _CHV_VIDEO_DIP_DATA_C)
6110 #define VLV_TVIDEO_DIP_GCP(pipe) \
6111 	_MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_GDCP_PAYLOAD_A, \
6112 		_VLV_VIDEO_DIP_GDCP_PAYLOAD_B, _CHV_VIDEO_DIP_GDCP_PAYLOAD_C)
6113 
6114 /* Haswell DIP controls */
6115 
6116 #define _HSW_VIDEO_DIP_CTL_A		0x60200
6117 #define _HSW_VIDEO_DIP_AVI_DATA_A	0x60220
6118 #define _HSW_VIDEO_DIP_VS_DATA_A	0x60260
6119 #define _HSW_VIDEO_DIP_SPD_DATA_A	0x602A0
6120 #define _HSW_VIDEO_DIP_GMP_DATA_A	0x602E0
6121 #define _HSW_VIDEO_DIP_VSC_DATA_A	0x60320
6122 #define _GLK_VIDEO_DIP_DRM_DATA_A	0x60440
6123 #define _HSW_VIDEO_DIP_AVI_ECC_A	0x60240
6124 #define _HSW_VIDEO_DIP_VS_ECC_A		0x60280
6125 #define _HSW_VIDEO_DIP_SPD_ECC_A	0x602C0
6126 #define _HSW_VIDEO_DIP_GMP_ECC_A	0x60300
6127 #define _HSW_VIDEO_DIP_VSC_ECC_A	0x60344
6128 #define _HSW_VIDEO_DIP_GCP_A		0x60210
6129 
6130 #define _HSW_VIDEO_DIP_CTL_B		0x61200
6131 #define _HSW_VIDEO_DIP_AVI_DATA_B	0x61220
6132 #define _HSW_VIDEO_DIP_VS_DATA_B	0x61260
6133 #define _HSW_VIDEO_DIP_SPD_DATA_B	0x612A0
6134 #define _HSW_VIDEO_DIP_GMP_DATA_B	0x612E0
6135 #define _HSW_VIDEO_DIP_VSC_DATA_B	0x61320
6136 #define _GLK_VIDEO_DIP_DRM_DATA_B	0x61440
6137 #define _HSW_VIDEO_DIP_BVI_ECC_B	0x61240
6138 #define _HSW_VIDEO_DIP_VS_ECC_B		0x61280
6139 #define _HSW_VIDEO_DIP_SPD_ECC_B	0x612C0
6140 #define _HSW_VIDEO_DIP_GMP_ECC_B	0x61300
6141 #define _HSW_VIDEO_DIP_VSC_ECC_B	0x61344
6142 #define _HSW_VIDEO_DIP_GCP_B		0x61210
6143 
6144 /* Icelake PPS_DATA and _ECC DIP Registers.
6145  * These are available for transcoders B,C and eDP.
6146  * Adding the _A so as to reuse the _MMIO_TRANS2
6147  * definition, with which it offsets to the right location.
6148  */
6149 
6150 #define _ICL_VIDEO_DIP_PPS_DATA_A	0x60350
6151 #define _ICL_VIDEO_DIP_PPS_DATA_B	0x61350
6152 #define _ICL_VIDEO_DIP_PPS_ECC_A	0x603D4
6153 #define _ICL_VIDEO_DIP_PPS_ECC_B	0x613D4
6154 
6155 #define HSW_TVIDEO_DIP_CTL(trans)		_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_CTL_A)
6156 #define HSW_TVIDEO_DIP_GCP(trans)		_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GCP_A)
6157 #define HSW_TVIDEO_DIP_AVI_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_AVI_DATA_A + (i) * 4)
6158 #define HSW_TVIDEO_DIP_VS_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VS_DATA_A + (i) * 4)
6159 #define HSW_TVIDEO_DIP_SPD_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_SPD_DATA_A + (i) * 4)
6160 #define HSW_TVIDEO_DIP_GMP_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GMP_DATA_A + (i) * 4)
6161 #define HSW_TVIDEO_DIP_VSC_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VSC_DATA_A + (i) * 4)
6162 #define GLK_TVIDEO_DIP_DRM_DATA(trans, i)	_MMIO_TRANS2(trans, _GLK_VIDEO_DIP_DRM_DATA_A + (i) * 4)
6163 #define ICL_VIDEO_DIP_PPS_DATA(trans, i)	_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_DATA_A + (i) * 4)
6164 #define ICL_VIDEO_DIP_PPS_ECC(trans, i)		_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_ECC_A + (i) * 4)
6165 
6166 #define _HSW_STEREO_3D_CTL_A		0x70020
6167 #define   S3D_ENABLE			(1 << 31)
6168 #define _HSW_STEREO_3D_CTL_B		0x71020
6169 
6170 #define HSW_STEREO_3D_CTL(trans)	_MMIO_PIPE2(trans, _HSW_STEREO_3D_CTL_A)
6171 
6172 #define _PCH_TRANS_HTOTAL_B          0xe1000
6173 #define _PCH_TRANS_HBLANK_B          0xe1004
6174 #define _PCH_TRANS_HSYNC_B           0xe1008
6175 #define _PCH_TRANS_VTOTAL_B          0xe100c
6176 #define _PCH_TRANS_VBLANK_B          0xe1010
6177 #define _PCH_TRANS_VSYNC_B           0xe1014
6178 #define _PCH_TRANS_VSYNCSHIFT_B 0xe1028
6179 
6180 #define PCH_TRANS_HTOTAL(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_HTOTAL_A, _PCH_TRANS_HTOTAL_B)
6181 #define PCH_TRANS_HBLANK(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_HBLANK_A, _PCH_TRANS_HBLANK_B)
6182 #define PCH_TRANS_HSYNC(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_HSYNC_A, _PCH_TRANS_HSYNC_B)
6183 #define PCH_TRANS_VTOTAL(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_VTOTAL_A, _PCH_TRANS_VTOTAL_B)
6184 #define PCH_TRANS_VBLANK(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_VBLANK_A, _PCH_TRANS_VBLANK_B)
6185 #define PCH_TRANS_VSYNC(pipe)		_MMIO_PIPE(pipe, _PCH_TRANS_VSYNC_A, _PCH_TRANS_VSYNC_B)
6186 #define PCH_TRANS_VSYNCSHIFT(pipe)	_MMIO_PIPE(pipe, _PCH_TRANS_VSYNCSHIFT_A, _PCH_TRANS_VSYNCSHIFT_B)
6187 
6188 #define _PCH_TRANSB_DATA_M1	0xe1030
6189 #define _PCH_TRANSB_DATA_N1	0xe1034
6190 #define _PCH_TRANSB_DATA_M2	0xe1038
6191 #define _PCH_TRANSB_DATA_N2	0xe103c
6192 #define _PCH_TRANSB_LINK_M1	0xe1040
6193 #define _PCH_TRANSB_LINK_N1	0xe1044
6194 #define _PCH_TRANSB_LINK_M2	0xe1048
6195 #define _PCH_TRANSB_LINK_N2	0xe104c
6196 
6197 #define PCH_TRANS_DATA_M1(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_DATA_M1, _PCH_TRANSB_DATA_M1)
6198 #define PCH_TRANS_DATA_N1(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_DATA_N1, _PCH_TRANSB_DATA_N1)
6199 #define PCH_TRANS_DATA_M2(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_DATA_M2, _PCH_TRANSB_DATA_M2)
6200 #define PCH_TRANS_DATA_N2(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_DATA_N2, _PCH_TRANSB_DATA_N2)
6201 #define PCH_TRANS_LINK_M1(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_LINK_M1, _PCH_TRANSB_LINK_M1)
6202 #define PCH_TRANS_LINK_N1(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_LINK_N1, _PCH_TRANSB_LINK_N1)
6203 #define PCH_TRANS_LINK_M2(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_LINK_M2, _PCH_TRANSB_LINK_M2)
6204 #define PCH_TRANS_LINK_N2(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSA_LINK_N2, _PCH_TRANSB_LINK_N2)
6205 
6206 #define _PCH_TRANSACONF              0xf0008
6207 #define _PCH_TRANSBCONF              0xf1008
6208 #define PCH_TRANSCONF(pipe)	_MMIO_PIPE(pipe, _PCH_TRANSACONF, _PCH_TRANSBCONF)
6209 #define LPT_TRANSCONF		PCH_TRANSCONF(PIPE_A) /* lpt has only one transcoder */
6210 #define  TRANS_ENABLE			REG_BIT(31)
6211 #define  TRANS_STATE_ENABLE		REG_BIT(30)
6212 #define  TRANS_FRAME_START_DELAY_MASK	REG_GENMASK(28, 27) /* ibx */
6213 #define  TRANS_FRAME_START_DELAY(x)	REG_FIELD_PREP(TRANS_FRAME_START_DELAY_MASK, (x)) /* ibx: 0-3 */
6214 #define  TRANS_INTERLACE_MASK		REG_GENMASK(23, 21)
6215 #define  TRANS_INTERLACE_PROGRESSIVE	REG_FIELD_PREP(TRANS_INTERLACE_MASK, 0)
6216 #define  TRANS_INTERLACE_LEGACY_VSYNC_IBX	REG_FIELD_PREP(TRANS_INTERLACE_MASK, 2) /* ibx */
6217 #define  TRANS_INTERLACE_INTERLACED	REG_FIELD_PREP(TRANS_INTERLACE_MASK, 3)
6218 #define  TRANS_BPC_MASK			REG_GENMASK(7, 5) /* ibx */
6219 #define  TRANS_BPC_8			REG_FIELD_PREP(TRANS_BPC_MASK, 0)
6220 #define  TRANS_BPC_10			REG_FIELD_PREP(TRANS_BPC_MASK, 1)
6221 #define  TRANS_BPC_6			REG_FIELD_PREP(TRANS_BPC_MASK, 2)
6222 #define  TRANS_BPC_12			REG_FIELD_PREP(TRANS_BPC_MASK, 3)
6223 #define _TRANSA_CHICKEN1	 0xf0060
6224 #define _TRANSB_CHICKEN1	 0xf1060
6225 #define TRANS_CHICKEN1(pipe)	_MMIO_PIPE(pipe, _TRANSA_CHICKEN1, _TRANSB_CHICKEN1)
6226 #define  TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE	(1 << 10)
6227 #define  TRANS_CHICKEN1_DP0UNIT_GC_DISABLE	(1 << 4)
6228 #define _TRANSA_CHICKEN2	 0xf0064
6229 #define _TRANSB_CHICKEN2	 0xf1064
6230 #define TRANS_CHICKEN2(pipe)	_MMIO_PIPE(pipe, _TRANSA_CHICKEN2, _TRANSB_CHICKEN2)
6231 #define  TRANS_CHICKEN2_TIMING_OVERRIDE			(1 << 31)
6232 #define  TRANS_CHICKEN2_FDI_POLARITY_REVERSED		(1 << 29)
6233 #define  TRANS_CHICKEN2_FRAME_START_DELAY_MASK		(3 << 27)
6234 #define  TRANS_CHICKEN2_FRAME_START_DELAY(x)		((x) << 27) /* 0-3 */
6235 #define  TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER	(1 << 26)
6236 #define  TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH	(1 << 25)
6237 
6238 #define SOUTH_CHICKEN1		_MMIO(0xc2000)
6239 #define  FDIA_PHASE_SYNC_SHIFT_OVR	19
6240 #define  FDIA_PHASE_SYNC_SHIFT_EN	18
6241 #define  INVERT_DDID_HPD			(1 << 18)
6242 #define  INVERT_DDIC_HPD			(1 << 17)
6243 #define  INVERT_DDIB_HPD			(1 << 16)
6244 #define  INVERT_DDIA_HPD			(1 << 15)
6245 #define  FDI_PHASE_SYNC_OVR(pipe) (1 << (FDIA_PHASE_SYNC_SHIFT_OVR - ((pipe) * 2)))
6246 #define  FDI_PHASE_SYNC_EN(pipe) (1 << (FDIA_PHASE_SYNC_SHIFT_EN - ((pipe) * 2)))
6247 #define  FDI_BC_BIFURCATION_SELECT	(1 << 12)
6248 #define  CHASSIS_CLK_REQ_DURATION_MASK	(0xf << 8)
6249 #define  CHASSIS_CLK_REQ_DURATION(x)	((x) << 8)
6250 #define  SBCLK_RUN_REFCLK_DIS		(1 << 7)
6251 #define  ICP_SECOND_PPS_IO_SELECT	REG_BIT(2)
6252 #define  SPT_PWM_GRANULARITY		(1 << 0)
6253 #define SOUTH_CHICKEN2		_MMIO(0xc2004)
6254 #define  FDI_MPHY_IOSFSB_RESET_STATUS	(1 << 13)
6255 #define  FDI_MPHY_IOSFSB_RESET_CTL	(1 << 12)
6256 #define  LPT_PWM_GRANULARITY		(1 << 5)
6257 #define  DPLS_EDP_PPS_FIX_DIS		(1 << 0)
6258 
6259 #define _FDI_RXA_CHICKEN        0xc200c
6260 #define _FDI_RXB_CHICKEN        0xc2010
6261 #define  FDI_RX_PHASE_SYNC_POINTER_OVR	(1 << 1)
6262 #define  FDI_RX_PHASE_SYNC_POINTER_EN	(1 << 0)
6263 #define FDI_RX_CHICKEN(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_CHICKEN, _FDI_RXB_CHICKEN)
6264 
6265 #define SOUTH_DSPCLK_GATE_D	_MMIO(0xc2020)
6266 #define  PCH_GMBUSUNIT_CLOCK_GATE_DISABLE (1 << 31)
6267 #define  PCH_DPLUNIT_CLOCK_GATE_DISABLE (1 << 30)
6268 #define  PCH_DPLSUNIT_CLOCK_GATE_DISABLE (1 << 29)
6269 #define  PCH_DPMGUNIT_CLOCK_GATE_DISABLE (1 << 15)
6270 #define  PCH_CPUNIT_CLOCK_GATE_DISABLE (1 << 14)
6271 #define  CNP_PWM_CGE_GATING_DISABLE (1 << 13)
6272 #define  PCH_LP_PARTITION_LEVEL_DISABLE  (1 << 12)
6273 
6274 /* CPU: FDI_TX */
6275 #define _FDI_TXA_CTL            0x60100
6276 #define _FDI_TXB_CTL            0x61100
6277 #define FDI_TX_CTL(pipe)	_MMIO_PIPE(pipe, _FDI_TXA_CTL, _FDI_TXB_CTL)
6278 #define  FDI_TX_DISABLE         (0 << 31)
6279 #define  FDI_TX_ENABLE          (1 << 31)
6280 #define  FDI_LINK_TRAIN_PATTERN_1       (0 << 28)
6281 #define  FDI_LINK_TRAIN_PATTERN_2       (1 << 28)
6282 #define  FDI_LINK_TRAIN_PATTERN_IDLE    (2 << 28)
6283 #define  FDI_LINK_TRAIN_NONE            (3 << 28)
6284 #define  FDI_LINK_TRAIN_VOLTAGE_0_4V    (0 << 25)
6285 #define  FDI_LINK_TRAIN_VOLTAGE_0_6V    (1 << 25)
6286 #define  FDI_LINK_TRAIN_VOLTAGE_0_8V    (2 << 25)
6287 #define  FDI_LINK_TRAIN_VOLTAGE_1_2V    (3 << 25)
6288 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_NONE (0 << 22)
6289 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_1_5X (1 << 22)
6290 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_2X   (2 << 22)
6291 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_3X   (3 << 22)
6292 /* ILK always use 400mV 0dB for voltage swing and pre-emphasis level.
6293    SNB has different settings. */
6294 /* SNB A-stepping */
6295 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_A		(0x38 << 22)
6296 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_A		(0x02 << 22)
6297 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_A	(0x01 << 22)
6298 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_A		(0x0 << 22)
6299 /* SNB B-stepping */
6300 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_B		(0x0 << 22)
6301 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_B		(0x3a << 22)
6302 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_B	(0x39 << 22)
6303 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_B		(0x38 << 22)
6304 #define  FDI_LINK_TRAIN_VOL_EMP_MASK		(0x3f << 22)
6305 #define  FDI_DP_PORT_WIDTH_SHIFT		19
6306 #define  FDI_DP_PORT_WIDTH_MASK			(7 << FDI_DP_PORT_WIDTH_SHIFT)
6307 #define  FDI_DP_PORT_WIDTH(width)           (((width) - 1) << FDI_DP_PORT_WIDTH_SHIFT)
6308 #define  FDI_TX_ENHANCE_FRAME_ENABLE    (1 << 18)
6309 /* Ironlake: hardwired to 1 */
6310 #define  FDI_TX_PLL_ENABLE              (1 << 14)
6311 
6312 /* Ivybridge has different bits for lolz */
6313 #define  FDI_LINK_TRAIN_PATTERN_1_IVB       (0 << 8)
6314 #define  FDI_LINK_TRAIN_PATTERN_2_IVB       (1 << 8)
6315 #define  FDI_LINK_TRAIN_PATTERN_IDLE_IVB    (2 << 8)
6316 #define  FDI_LINK_TRAIN_NONE_IVB            (3 << 8)
6317 
6318 /* both Tx and Rx */
6319 #define  FDI_COMPOSITE_SYNC		(1 << 11)
6320 #define  FDI_LINK_TRAIN_AUTO		(1 << 10)
6321 #define  FDI_SCRAMBLING_ENABLE          (0 << 7)
6322 #define  FDI_SCRAMBLING_DISABLE         (1 << 7)
6323 
6324 /* FDI_RX, FDI_X is hard-wired to Transcoder_X */
6325 #define _FDI_RXA_CTL             0xf000c
6326 #define _FDI_RXB_CTL             0xf100c
6327 #define FDI_RX_CTL(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_CTL, _FDI_RXB_CTL)
6328 #define  FDI_RX_ENABLE          (1 << 31)
6329 /* train, dp width same as FDI_TX */
6330 #define  FDI_FS_ERRC_ENABLE		(1 << 27)
6331 #define  FDI_FE_ERRC_ENABLE		(1 << 26)
6332 #define  FDI_RX_POLARITY_REVERSED_LPT	(1 << 16)
6333 #define  FDI_8BPC                       (0 << 16)
6334 #define  FDI_10BPC                      (1 << 16)
6335 #define  FDI_6BPC                       (2 << 16)
6336 #define  FDI_12BPC                      (3 << 16)
6337 #define  FDI_RX_LINK_REVERSAL_OVERRIDE  (1 << 15)
6338 #define  FDI_DMI_LINK_REVERSE_MASK      (1 << 14)
6339 #define  FDI_RX_PLL_ENABLE              (1 << 13)
6340 #define  FDI_FS_ERR_CORRECT_ENABLE      (1 << 11)
6341 #define  FDI_FE_ERR_CORRECT_ENABLE      (1 << 10)
6342 #define  FDI_FS_ERR_REPORT_ENABLE       (1 << 9)
6343 #define  FDI_FE_ERR_REPORT_ENABLE       (1 << 8)
6344 #define  FDI_RX_ENHANCE_FRAME_ENABLE    (1 << 6)
6345 #define  FDI_PCDCLK	                (1 << 4)
6346 /* CPT */
6347 #define  FDI_AUTO_TRAINING			(1 << 10)
6348 #define  FDI_LINK_TRAIN_PATTERN_1_CPT		(0 << 8)
6349 #define  FDI_LINK_TRAIN_PATTERN_2_CPT		(1 << 8)
6350 #define  FDI_LINK_TRAIN_PATTERN_IDLE_CPT	(2 << 8)
6351 #define  FDI_LINK_TRAIN_NORMAL_CPT		(3 << 8)
6352 #define  FDI_LINK_TRAIN_PATTERN_MASK_CPT	(3 << 8)
6353 
6354 #define _FDI_RXA_MISC			0xf0010
6355 #define _FDI_RXB_MISC			0xf1010
6356 #define  FDI_RX_PWRDN_LANE1_MASK	(3 << 26)
6357 #define  FDI_RX_PWRDN_LANE1_VAL(x)	((x) << 26)
6358 #define  FDI_RX_PWRDN_LANE0_MASK	(3 << 24)
6359 #define  FDI_RX_PWRDN_LANE0_VAL(x)	((x) << 24)
6360 #define  FDI_RX_TP1_TO_TP2_48		(2 << 20)
6361 #define  FDI_RX_TP1_TO_TP2_64		(3 << 20)
6362 #define  FDI_RX_FDI_DELAY_90		(0x90 << 0)
6363 #define FDI_RX_MISC(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_MISC, _FDI_RXB_MISC)
6364 
6365 #define _FDI_RXA_TUSIZE1        0xf0030
6366 #define _FDI_RXA_TUSIZE2        0xf0038
6367 #define _FDI_RXB_TUSIZE1        0xf1030
6368 #define _FDI_RXB_TUSIZE2        0xf1038
6369 #define FDI_RX_TUSIZE1(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_TUSIZE1, _FDI_RXB_TUSIZE1)
6370 #define FDI_RX_TUSIZE2(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_TUSIZE2, _FDI_RXB_TUSIZE2)
6371 
6372 /* FDI_RX interrupt register format */
6373 #define FDI_RX_INTER_LANE_ALIGN         (1 << 10)
6374 #define FDI_RX_SYMBOL_LOCK              (1 << 9) /* train 2 */
6375 #define FDI_RX_BIT_LOCK                 (1 << 8) /* train 1 */
6376 #define FDI_RX_TRAIN_PATTERN_2_FAIL     (1 << 7)
6377 #define FDI_RX_FS_CODE_ERR              (1 << 6)
6378 #define FDI_RX_FE_CODE_ERR              (1 << 5)
6379 #define FDI_RX_SYMBOL_ERR_RATE_ABOVE    (1 << 4)
6380 #define FDI_RX_HDCP_LINK_FAIL           (1 << 3)
6381 #define FDI_RX_PIXEL_FIFO_OVERFLOW      (1 << 2)
6382 #define FDI_RX_CROSS_CLOCK_OVERFLOW     (1 << 1)
6383 #define FDI_RX_SYMBOL_QUEUE_OVERFLOW    (1 << 0)
6384 
6385 #define _FDI_RXA_IIR            0xf0014
6386 #define _FDI_RXA_IMR            0xf0018
6387 #define _FDI_RXB_IIR            0xf1014
6388 #define _FDI_RXB_IMR            0xf1018
6389 #define FDI_RX_IIR(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_IIR, _FDI_RXB_IIR)
6390 #define FDI_RX_IMR(pipe)	_MMIO_PIPE(pipe, _FDI_RXA_IMR, _FDI_RXB_IMR)
6391 
6392 #define FDI_PLL_CTL_1           _MMIO(0xfe000)
6393 #define FDI_PLL_CTL_2           _MMIO(0xfe004)
6394 
6395 #define PCH_LVDS	_MMIO(0xe1180)
6396 #define  LVDS_DETECTED	(1 << 1)
6397 
6398 #define _PCH_DP_B		0xe4100
6399 #define PCH_DP_B		_MMIO(_PCH_DP_B)
6400 #define _PCH_DPB_AUX_CH_CTL	0xe4110
6401 #define _PCH_DPB_AUX_CH_DATA1	0xe4114
6402 #define _PCH_DPB_AUX_CH_DATA2	0xe4118
6403 #define _PCH_DPB_AUX_CH_DATA3	0xe411c
6404 #define _PCH_DPB_AUX_CH_DATA4	0xe4120
6405 #define _PCH_DPB_AUX_CH_DATA5	0xe4124
6406 
6407 #define _PCH_DP_C		0xe4200
6408 #define PCH_DP_C		_MMIO(_PCH_DP_C)
6409 #define _PCH_DPC_AUX_CH_CTL	0xe4210
6410 #define _PCH_DPC_AUX_CH_DATA1	0xe4214
6411 #define _PCH_DPC_AUX_CH_DATA2	0xe4218
6412 #define _PCH_DPC_AUX_CH_DATA3	0xe421c
6413 #define _PCH_DPC_AUX_CH_DATA4	0xe4220
6414 #define _PCH_DPC_AUX_CH_DATA5	0xe4224
6415 
6416 #define _PCH_DP_D		0xe4300
6417 #define PCH_DP_D		_MMIO(_PCH_DP_D)
6418 #define _PCH_DPD_AUX_CH_CTL	0xe4310
6419 #define _PCH_DPD_AUX_CH_DATA1	0xe4314
6420 #define _PCH_DPD_AUX_CH_DATA2	0xe4318
6421 #define _PCH_DPD_AUX_CH_DATA3	0xe431c
6422 #define _PCH_DPD_AUX_CH_DATA4	0xe4320
6423 #define _PCH_DPD_AUX_CH_DATA5	0xe4324
6424 
6425 #define PCH_DP_AUX_CH_CTL(aux_ch)		_MMIO_PORT((aux_ch) - AUX_CH_B, _PCH_DPB_AUX_CH_CTL, _PCH_DPC_AUX_CH_CTL)
6426 #define PCH_DP_AUX_CH_DATA(aux_ch, i)	_MMIO(_PORT((aux_ch) - AUX_CH_B, _PCH_DPB_AUX_CH_DATA1, _PCH_DPC_AUX_CH_DATA1) + (i) * 4) /* 5 registers */
6427 
6428 /* CPT */
6429 #define _TRANS_DP_CTL_A		0xe0300
6430 #define _TRANS_DP_CTL_B		0xe1300
6431 #define _TRANS_DP_CTL_C		0xe2300
6432 #define TRANS_DP_CTL(pipe)	_MMIO_PIPE(pipe, _TRANS_DP_CTL_A, _TRANS_DP_CTL_B)
6433 #define  TRANS_DP_OUTPUT_ENABLE		REG_BIT(31)
6434 #define  TRANS_DP_PORT_SEL_MASK		REG_GENMASK(30, 29)
6435 #define  TRANS_DP_PORT_SEL_NONE		REG_FIELD_PREP(TRANS_DP_PORT_SEL_MASK, 3)
6436 #define  TRANS_DP_PORT_SEL(port)	REG_FIELD_PREP(TRANS_DP_PORT_SEL_MASK, (port) - PORT_B)
6437 #define  TRANS_DP_AUDIO_ONLY		REG_BIT(26)
6438 #define  TRANS_DP_ENH_FRAMING		REG_BIT(18)
6439 #define  TRANS_DP_BPC_MASK		REG_GENMASK(10, 9)
6440 #define  TRANS_DP_BPC_8			REG_FIELD_PREP(TRANS_DP_BPC_MASK, 0)
6441 #define  TRANS_DP_BPC_10		REG_FIELD_PREP(TRANS_DP_BPC_MASK, 1)
6442 #define  TRANS_DP_BPC_6			REG_FIELD_PREP(TRANS_DP_BPC_MASK, 2)
6443 #define  TRANS_DP_BPC_12		REG_FIELD_PREP(TRANS_DP_BPC_MASK, 3)
6444 #define  TRANS_DP_VSYNC_ACTIVE_HIGH	REG_BIT(4)
6445 #define  TRANS_DP_HSYNC_ACTIVE_HIGH	REG_BIT(3)
6446 
6447 #define _TRANS_DP2_CTL_A			0x600a0
6448 #define _TRANS_DP2_CTL_B			0x610a0
6449 #define _TRANS_DP2_CTL_C			0x620a0
6450 #define _TRANS_DP2_CTL_D			0x630a0
6451 #define TRANS_DP2_CTL(trans)			_MMIO_TRANS(trans, _TRANS_DP2_CTL_A, _TRANS_DP2_CTL_B)
6452 #define  TRANS_DP2_128B132B_CHANNEL_CODING	REG_BIT(31)
6453 #define  TRANS_DP2_PANEL_REPLAY_ENABLE		REG_BIT(30)
6454 #define  TRANS_DP2_DEBUG_ENABLE			REG_BIT(23)
6455 
6456 #define _TRANS_DP2_VFREQHIGH_A			0x600a4
6457 #define _TRANS_DP2_VFREQHIGH_B			0x610a4
6458 #define _TRANS_DP2_VFREQHIGH_C			0x620a4
6459 #define _TRANS_DP2_VFREQHIGH_D			0x630a4
6460 #define TRANS_DP2_VFREQHIGH(trans)		_MMIO_TRANS(trans, _TRANS_DP2_VFREQHIGH_A, _TRANS_DP2_VFREQHIGH_B)
6461 #define  TRANS_DP2_VFREQ_PIXEL_CLOCK_MASK	REG_GENMASK(31, 8)
6462 #define  TRANS_DP2_VFREQ_PIXEL_CLOCK(clk_hz)	REG_FIELD_PREP(TRANS_DP2_VFREQ_PIXEL_CLOCK_MASK, (clk_hz))
6463 
6464 #define _TRANS_DP2_VFREQLOW_A			0x600a8
6465 #define _TRANS_DP2_VFREQLOW_B			0x610a8
6466 #define _TRANS_DP2_VFREQLOW_C			0x620a8
6467 #define _TRANS_DP2_VFREQLOW_D			0x630a8
6468 #define TRANS_DP2_VFREQLOW(trans)		_MMIO_TRANS(trans, _TRANS_DP2_VFREQLOW_A, _TRANS_DP2_VFREQLOW_B)
6469 
6470 /* SNB eDP training params */
6471 /* SNB A-stepping */
6472 #define  EDP_LINK_TRAIN_400MV_0DB_SNB_A		(0x38 << 22)
6473 #define  EDP_LINK_TRAIN_400MV_6DB_SNB_A		(0x02 << 22)
6474 #define  EDP_LINK_TRAIN_600MV_3_5DB_SNB_A	(0x01 << 22)
6475 #define  EDP_LINK_TRAIN_800MV_0DB_SNB_A		(0x0 << 22)
6476 /* SNB B-stepping */
6477 #define  EDP_LINK_TRAIN_400_600MV_0DB_SNB_B	(0x0 << 22)
6478 #define  EDP_LINK_TRAIN_400MV_3_5DB_SNB_B	(0x1 << 22)
6479 #define  EDP_LINK_TRAIN_400_600MV_6DB_SNB_B	(0x3a << 22)
6480 #define  EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B	(0x39 << 22)
6481 #define  EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B	(0x38 << 22)
6482 #define  EDP_LINK_TRAIN_VOL_EMP_MASK_SNB	(0x3f << 22)
6483 
6484 /* IVB */
6485 #define EDP_LINK_TRAIN_400MV_0DB_IVB		(0x24 << 22)
6486 #define EDP_LINK_TRAIN_400MV_3_5DB_IVB		(0x2a << 22)
6487 #define EDP_LINK_TRAIN_400MV_6DB_IVB		(0x2f << 22)
6488 #define EDP_LINK_TRAIN_600MV_0DB_IVB		(0x30 << 22)
6489 #define EDP_LINK_TRAIN_600MV_3_5DB_IVB		(0x36 << 22)
6490 #define EDP_LINK_TRAIN_800MV_0DB_IVB		(0x38 << 22)
6491 #define EDP_LINK_TRAIN_800MV_3_5DB_IVB		(0x3e << 22)
6492 
6493 /* legacy values */
6494 #define EDP_LINK_TRAIN_500MV_0DB_IVB		(0x00 << 22)
6495 #define EDP_LINK_TRAIN_1000MV_0DB_IVB		(0x20 << 22)
6496 #define EDP_LINK_TRAIN_500MV_3_5DB_IVB		(0x02 << 22)
6497 #define EDP_LINK_TRAIN_1000MV_3_5DB_IVB		(0x22 << 22)
6498 #define EDP_LINK_TRAIN_1000MV_6DB_IVB		(0x23 << 22)
6499 
6500 #define  EDP_LINK_TRAIN_VOL_EMP_MASK_IVB	(0x3f << 22)
6501 
6502 #define  VLV_PMWGICZ				_MMIO(0x1300a4)
6503 
6504 #define  HSW_EDRAM_CAP				_MMIO(0x120010)
6505 #define    EDRAM_ENABLED			0x1
6506 #define    EDRAM_NUM_BANKS(cap)			(((cap) >> 1) & 0xf)
6507 #define    EDRAM_WAYS_IDX(cap)			(((cap) >> 5) & 0x7)
6508 #define    EDRAM_SETS_IDX(cap)			(((cap) >> 8) & 0x3)
6509 
6510 #define VLV_CHICKEN_3				_MMIO(VLV_DISPLAY_BASE + 0x7040C)
6511 #define  PIXEL_OVERLAP_CNT_MASK			(3 << 30)
6512 #define  PIXEL_OVERLAP_CNT_SHIFT		30
6513 
6514 #define GEN6_PCODE_MAILBOX			_MMIO(0x138124)
6515 #define   GEN6_PCODE_READY			(1 << 31)
6516 #define   GEN6_PCODE_MB_PARAM2			REG_GENMASK(23, 16)
6517 #define   GEN6_PCODE_MB_PARAM1			REG_GENMASK(15, 8)
6518 #define   GEN6_PCODE_MB_COMMAND			REG_GENMASK(7, 0)
6519 #define   GEN6_PCODE_ERROR_MASK			0xFF
6520 #define     GEN6_PCODE_SUCCESS			0x0
6521 #define     GEN6_PCODE_ILLEGAL_CMD		0x1
6522 #define     GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x2
6523 #define     GEN6_PCODE_TIMEOUT			0x3
6524 #define     GEN6_PCODE_UNIMPLEMENTED_CMD	0xFF
6525 #define     GEN7_PCODE_TIMEOUT			0x2
6526 #define     GEN7_PCODE_ILLEGAL_DATA		0x3
6527 #define     GEN11_PCODE_ILLEGAL_SUBCOMMAND	0x4
6528 #define     GEN11_PCODE_LOCKED			0x6
6529 #define     GEN11_PCODE_REJECTED		0x11
6530 #define     GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x10
6531 #define   GEN6_PCODE_WRITE_RC6VIDS		0x4
6532 #define   GEN6_PCODE_READ_RC6VIDS		0x5
6533 #define     GEN6_ENCODE_RC6_VID(mv)		(((mv) - 245) / 5)
6534 #define     GEN6_DECODE_RC6_VID(vids)		(((vids) * 5) + 245)
6535 #define   BDW_PCODE_DISPLAY_FREQ_CHANGE_REQ	0x18
6536 #define   GEN9_PCODE_READ_MEM_LATENCY		0x6
6537 #define     GEN9_MEM_LATENCY_LEVEL_3_7_MASK	REG_GENMASK(31, 24)
6538 #define     GEN9_MEM_LATENCY_LEVEL_2_6_MASK	REG_GENMASK(23, 16)
6539 #define     GEN9_MEM_LATENCY_LEVEL_1_5_MASK	REG_GENMASK(15, 8)
6540 #define     GEN9_MEM_LATENCY_LEVEL_0_4_MASK	REG_GENMASK(7, 0)
6541 #define   SKL_PCODE_LOAD_HDCP_KEYS		0x5
6542 #define   SKL_PCODE_CDCLK_CONTROL		0x7
6543 #define     SKL_CDCLK_PREPARE_FOR_CHANGE	0x3
6544 #define     SKL_CDCLK_READY_FOR_CHANGE		0x1
6545 #define   GEN6_PCODE_WRITE_MIN_FREQ_TABLE	0x8
6546 #define   GEN6_PCODE_READ_MIN_FREQ_TABLE	0x9
6547 #define   GEN6_READ_OC_PARAMS			0xc
6548 #define   ICL_PCODE_MEM_SUBSYSYSTEM_INFO	0xd
6549 #define     ICL_PCODE_MEM_SS_READ_GLOBAL_INFO	(0x0 << 8)
6550 #define     ICL_PCODE_MEM_SS_READ_QGV_POINT_INFO(point)	(((point) << 16) | (0x1 << 8))
6551 #define     ADL_PCODE_MEM_SS_READ_PSF_GV_INFO	((0) | (0x2 << 8))
6552 #define   ICL_PCODE_SAGV_DE_MEM_SS_CONFIG	0xe
6553 #define     ICL_PCODE_REP_QGV_MASK		REG_GENMASK(1, 0)
6554 #define     ICL_PCODE_REP_QGV_SAFE		REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 0)
6555 #define     ICL_PCODE_REP_QGV_POLL		REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 1)
6556 #define     ICL_PCODE_REP_QGV_REJECTED		REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 2)
6557 #define     ADLS_PCODE_REP_PSF_MASK		REG_GENMASK(3, 2)
6558 #define     ADLS_PCODE_REP_PSF_SAFE		REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 0)
6559 #define     ADLS_PCODE_REP_PSF_POLL		REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 1)
6560 #define     ADLS_PCODE_REP_PSF_REJECTED		REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 2)
6561 #define     ICL_PCODE_REQ_QGV_PT_MASK		REG_GENMASK(7, 0)
6562 #define     ICL_PCODE_REQ_QGV_PT(x)		REG_FIELD_PREP(ICL_PCODE_REQ_QGV_PT_MASK, (x))
6563 #define     ADLS_PCODE_REQ_PSF_PT_MASK		REG_GENMASK(10, 8)
6564 #define     ADLS_PCODE_REQ_PSF_PT(x)		REG_FIELD_PREP(ADLS_PCODE_REQ_PSF_PT_MASK, (x))
6565 #define   GEN6_PCODE_READ_D_COMP		0x10
6566 #define   GEN6_PCODE_WRITE_D_COMP		0x11
6567 #define   ICL_PCODE_EXIT_TCCOLD			0x12
6568 #define   HSW_PCODE_DE_WRITE_FREQ_REQ		0x17
6569 #define   DISPLAY_IPS_CONTROL			0x19
6570 #define   TGL_PCODE_TCCOLD			0x26
6571 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_EXIT_FAILED	REG_BIT(0)
6572 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_BLOCK_REQ	0
6573 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_UNBLOCK_REQ	REG_BIT(0)
6574             /* See also IPS_CTL */
6575 #define     IPS_PCODE_CONTROL			(1 << 30)
6576 #define   HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL	0x1A
6577 #define   GEN9_PCODE_SAGV_CONTROL		0x21
6578 #define     GEN9_SAGV_DISABLE			0x0
6579 #define     GEN9_SAGV_IS_DISABLED		0x1
6580 #define     GEN9_SAGV_ENABLE			0x3
6581 #define   DG1_PCODE_STATUS			0x7E
6582 #define     DG1_UNCORE_GET_INIT_STATUS		0x0
6583 #define     DG1_UNCORE_INIT_STATUS_COMPLETE	0x1
6584 #define   PCODE_POWER_SETUP			0x7C
6585 #define     POWER_SETUP_SUBCOMMAND_READ_I1	0x4
6586 #define     POWER_SETUP_SUBCOMMAND_WRITE_I1	0x5
6587 #define	    POWER_SETUP_I1_WATTS		REG_BIT(31)
6588 #define	    POWER_SETUP_I1_SHIFT		6	/* 10.6 fixed point format */
6589 #define	    POWER_SETUP_I1_DATA_MASK		REG_GENMASK(15, 0)
6590 #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US	0x23
6591 #define   XEHP_PCODE_FREQUENCY_CONFIG		0x6e	/* xehpsdv, pvc */
6592 /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
6593 #define     PCODE_MBOX_FC_SC_READ_FUSED_P0	0x0
6594 #define     PCODE_MBOX_FC_SC_READ_FUSED_PN	0x1
6595 /* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
6596 /*   XEHP_PCODE_FREQUENCY_CONFIG param2 */
6597 #define     PCODE_MBOX_DOMAIN_NONE		0x0
6598 #define     PCODE_MBOX_DOMAIN_MEDIAFF		0x3
6599 
6600 /* Wa_14017210380: mtl */
6601 #define   PCODE_MBOX_GT_STATE			0x50
6602 /* sub-commands (param1) */
6603 #define     PCODE_MBOX_GT_STATE_MEDIA_BUSY	0x1
6604 #define     PCODE_MBOX_GT_STATE_MEDIA_NOT_BUSY	0x2
6605 /* param2 */
6606 #define     PCODE_MBOX_GT_STATE_DOMAIN_MEDIA	0x1
6607 
6608 #define GEN6_PCODE_DATA				_MMIO(0x138128)
6609 #define   GEN6_PCODE_FREQ_IA_RATIO_SHIFT	8
6610 #define   GEN6_PCODE_FREQ_RING_RATIO_SHIFT	16
6611 #define GEN6_PCODE_DATA1			_MMIO(0x13812C)
6612 
6613 /* IVYBRIDGE DPF */
6614 #define GEN7_L3CDERRST1(slice)		_MMIO(0xB008 + (slice) * 0x200) /* L3CD Error Status 1 */
6615 #define   GEN7_L3CDERRST1_ROW_MASK	(0x7ff << 14)
6616 #define   GEN7_PARITY_ERROR_VALID	(1 << 13)
6617 #define   GEN7_L3CDERRST1_BANK_MASK	(3 << 11)
6618 #define   GEN7_L3CDERRST1_SUBBANK_MASK	(7 << 8)
6619 #define GEN7_PARITY_ERROR_ROW(reg) \
6620 		(((reg) & GEN7_L3CDERRST1_ROW_MASK) >> 14)
6621 #define GEN7_PARITY_ERROR_BANK(reg) \
6622 		(((reg) & GEN7_L3CDERRST1_BANK_MASK) >> 11)
6623 #define GEN7_PARITY_ERROR_SUBBANK(reg) \
6624 		(((reg) & GEN7_L3CDERRST1_SUBBANK_MASK) >> 8)
6625 #define   GEN7_L3CDERRST1_ENABLE	(1 << 7)
6626 
6627 /* These are the 4 32-bit write offset registers for each stream
6628  * output buffer.  It determines the offset from the
6629  * 3DSTATE_SO_BUFFERs that the next streamed vertex output goes to.
6630  */
6631 #define GEN7_SO_WRITE_OFFSET(n)		_MMIO(0x5280 + (n) * 4)
6632 
6633 /*
6634  * HSW - ICL power wells
6635  *
6636  * Platforms have up to 3 power well control register sets, each set
6637  * controlling up to 16 power wells via a request/status HW flag tuple:
6638  * - main (HSW_PWR_WELL_CTL[1-4])
6639  * - AUX  (ICL_PWR_WELL_CTL_AUX[1-4])
6640  * - DDI  (ICL_PWR_WELL_CTL_DDI[1-4])
6641  * Each control register set consists of up to 4 registers used by different
6642  * sources that can request a power well to be enabled:
6643  * - BIOS   (HSW_PWR_WELL_CTL1/ICL_PWR_WELL_CTL_AUX1/ICL_PWR_WELL_CTL_DDI1)
6644  * - DRIVER (HSW_PWR_WELL_CTL2/ICL_PWR_WELL_CTL_AUX2/ICL_PWR_WELL_CTL_DDI2)
6645  * - KVMR   (HSW_PWR_WELL_CTL3)   (only in the main register set)
6646  * - DEBUG  (HSW_PWR_WELL_CTL4/ICL_PWR_WELL_CTL_AUX4/ICL_PWR_WELL_CTL_DDI4)
6647  */
6648 #define HSW_PWR_WELL_CTL1			_MMIO(0x45400)
6649 #define HSW_PWR_WELL_CTL2			_MMIO(0x45404)
6650 #define HSW_PWR_WELL_CTL3			_MMIO(0x45408)
6651 #define HSW_PWR_WELL_CTL4			_MMIO(0x4540C)
6652 #define   HSW_PWR_WELL_CTL_REQ(pw_idx)		(0x2 << ((pw_idx) * 2))
6653 #define   HSW_PWR_WELL_CTL_STATE(pw_idx)	(0x1 << ((pw_idx) * 2))
6654 
6655 /* HSW/BDW power well */
6656 #define   HSW_PW_CTL_IDX_GLOBAL			15
6657 
6658 /* SKL/BXT/GLK power wells */
6659 #define   SKL_PW_CTL_IDX_PW_2			15
6660 #define   SKL_PW_CTL_IDX_PW_1			14
6661 #define   GLK_PW_CTL_IDX_AUX_C			10
6662 #define   GLK_PW_CTL_IDX_AUX_B			9
6663 #define   GLK_PW_CTL_IDX_AUX_A			8
6664 #define   SKL_PW_CTL_IDX_DDI_D			4
6665 #define   SKL_PW_CTL_IDX_DDI_C			3
6666 #define   SKL_PW_CTL_IDX_DDI_B			2
6667 #define   SKL_PW_CTL_IDX_DDI_A_E		1
6668 #define   GLK_PW_CTL_IDX_DDI_A			1
6669 #define   SKL_PW_CTL_IDX_MISC_IO		0
6670 
6671 /* ICL/TGL - power wells */
6672 #define   TGL_PW_CTL_IDX_PW_5			4
6673 #define   ICL_PW_CTL_IDX_PW_4			3
6674 #define   ICL_PW_CTL_IDX_PW_3			2
6675 #define   ICL_PW_CTL_IDX_PW_2			1
6676 #define   ICL_PW_CTL_IDX_PW_1			0
6677 
6678 /* XE_LPD - power wells */
6679 #define   XELPD_PW_CTL_IDX_PW_D			8
6680 #define   XELPD_PW_CTL_IDX_PW_C			7
6681 #define   XELPD_PW_CTL_IDX_PW_B			6
6682 #define   XELPD_PW_CTL_IDX_PW_A			5
6683 
6684 #define ICL_PWR_WELL_CTL_AUX1			_MMIO(0x45440)
6685 #define ICL_PWR_WELL_CTL_AUX2			_MMIO(0x45444)
6686 #define ICL_PWR_WELL_CTL_AUX4			_MMIO(0x4544C)
6687 #define   TGL_PW_CTL_IDX_AUX_TBT6		14
6688 #define   TGL_PW_CTL_IDX_AUX_TBT5		13
6689 #define   TGL_PW_CTL_IDX_AUX_TBT4		12
6690 #define   ICL_PW_CTL_IDX_AUX_TBT4		11
6691 #define   TGL_PW_CTL_IDX_AUX_TBT3		11
6692 #define   ICL_PW_CTL_IDX_AUX_TBT3		10
6693 #define   TGL_PW_CTL_IDX_AUX_TBT2		10
6694 #define   ICL_PW_CTL_IDX_AUX_TBT2		9
6695 #define   TGL_PW_CTL_IDX_AUX_TBT1		9
6696 #define   ICL_PW_CTL_IDX_AUX_TBT1		8
6697 #define   TGL_PW_CTL_IDX_AUX_TC6		8
6698 #define   XELPD_PW_CTL_IDX_AUX_E			8
6699 #define   TGL_PW_CTL_IDX_AUX_TC5		7
6700 #define   XELPD_PW_CTL_IDX_AUX_D			7
6701 #define   TGL_PW_CTL_IDX_AUX_TC4		6
6702 #define   ICL_PW_CTL_IDX_AUX_F			5
6703 #define   TGL_PW_CTL_IDX_AUX_TC3		5
6704 #define   ICL_PW_CTL_IDX_AUX_E			4
6705 #define   TGL_PW_CTL_IDX_AUX_TC2		4
6706 #define   ICL_PW_CTL_IDX_AUX_D			3
6707 #define   TGL_PW_CTL_IDX_AUX_TC1		3
6708 #define   ICL_PW_CTL_IDX_AUX_C			2
6709 #define   ICL_PW_CTL_IDX_AUX_B			1
6710 #define   ICL_PW_CTL_IDX_AUX_A			0
6711 
6712 #define ICL_PWR_WELL_CTL_DDI1			_MMIO(0x45450)
6713 #define ICL_PWR_WELL_CTL_DDI2			_MMIO(0x45454)
6714 #define ICL_PWR_WELL_CTL_DDI4			_MMIO(0x4545C)
6715 #define   XELPD_PW_CTL_IDX_DDI_E			8
6716 #define   TGL_PW_CTL_IDX_DDI_TC6		8
6717 #define   XELPD_PW_CTL_IDX_DDI_D			7
6718 #define   TGL_PW_CTL_IDX_DDI_TC5		7
6719 #define   TGL_PW_CTL_IDX_DDI_TC4		6
6720 #define   ICL_PW_CTL_IDX_DDI_F			5
6721 #define   TGL_PW_CTL_IDX_DDI_TC3		5
6722 #define   ICL_PW_CTL_IDX_DDI_E			4
6723 #define   TGL_PW_CTL_IDX_DDI_TC2		4
6724 #define   ICL_PW_CTL_IDX_DDI_D			3
6725 #define   TGL_PW_CTL_IDX_DDI_TC1		3
6726 #define   ICL_PW_CTL_IDX_DDI_C			2
6727 #define   ICL_PW_CTL_IDX_DDI_B			1
6728 #define   ICL_PW_CTL_IDX_DDI_A			0
6729 
6730 /* HSW - power well misc debug registers */
6731 #define HSW_PWR_WELL_CTL5			_MMIO(0x45410)
6732 #define   HSW_PWR_WELL_ENABLE_SINGLE_STEP	(1 << 31)
6733 #define   HSW_PWR_WELL_PWR_GATE_OVERRIDE	(1 << 20)
6734 #define   HSW_PWR_WELL_FORCE_ON			(1 << 19)
6735 #define HSW_PWR_WELL_CTL6			_MMIO(0x45414)
6736 
6737 /* SKL Fuse Status */
6738 enum skl_power_gate {
6739 	SKL_PG0,
6740 	SKL_PG1,
6741 	SKL_PG2,
6742 	ICL_PG3,
6743 	ICL_PG4,
6744 };
6745 
6746 #define SKL_FUSE_STATUS				_MMIO(0x42000)
6747 #define  SKL_FUSE_DOWNLOAD_STATUS		(1 << 31)
6748 /*
6749  * PG0 is HW controlled, so doesn't have a corresponding power well control knob
6750  * SKL_DISP_PW1_IDX..SKL_DISP_PW2_IDX -> PG1..PG2
6751  */
6752 #define  SKL_PW_CTL_IDX_TO_PG(pw_idx)		\
6753 	((pw_idx) - SKL_PW_CTL_IDX_PW_1 + SKL_PG1)
6754 /*
6755  * PG0 is HW controlled, so doesn't have a corresponding power well control knob
6756  * ICL_DISP_PW1_IDX..ICL_DISP_PW4_IDX -> PG1..PG4
6757  */
6758 #define  ICL_PW_CTL_IDX_TO_PG(pw_idx)		\
6759 	((pw_idx) - ICL_PW_CTL_IDX_PW_1 + SKL_PG1)
6760 #define  SKL_FUSE_PG_DIST_STATUS(pg)		(1 << (27 - (pg)))
6761 
6762 #define _ICL_AUX_REG_IDX(pw_idx)	((pw_idx) - ICL_PW_CTL_IDX_AUX_A)
6763 #define _ICL_AUX_ANAOVRD1_A		0x162398
6764 #define _ICL_AUX_ANAOVRD1_B		0x6C398
6765 #define ICL_AUX_ANAOVRD1(pw_idx)	_MMIO(_PICK(_ICL_AUX_REG_IDX(pw_idx), \
6766 						    _ICL_AUX_ANAOVRD1_A, \
6767 						    _ICL_AUX_ANAOVRD1_B))
6768 #define   ICL_AUX_ANAOVRD1_LDO_BYPASS	(1 << 7)
6769 #define   ICL_AUX_ANAOVRD1_ENABLE	(1 << 0)
6770 
6771 /* Per-pipe DDI Function Control */
6772 #define _TRANS_DDI_FUNC_CTL_A		0x60400
6773 #define _TRANS_DDI_FUNC_CTL_B		0x61400
6774 #define _TRANS_DDI_FUNC_CTL_C		0x62400
6775 #define _TRANS_DDI_FUNC_CTL_D		0x63400
6776 #define _TRANS_DDI_FUNC_CTL_EDP		0x6F400
6777 #define _TRANS_DDI_FUNC_CTL_DSI0	0x6b400
6778 #define _TRANS_DDI_FUNC_CTL_DSI1	0x6bc00
6779 #define TRANS_DDI_FUNC_CTL(tran) _MMIO_TRANS2(tran, _TRANS_DDI_FUNC_CTL_A)
6780 
6781 #define  TRANS_DDI_FUNC_ENABLE		(1 << 31)
6782 /* Those bits are ignored by pipe EDP since it can only connect to DDI A */
6783 #define  TRANS_DDI_PORT_SHIFT		28
6784 #define  TGL_TRANS_DDI_PORT_SHIFT	27
6785 #define  TRANS_DDI_PORT_MASK		(7 << TRANS_DDI_PORT_SHIFT)
6786 #define  TGL_TRANS_DDI_PORT_MASK	(0xf << TGL_TRANS_DDI_PORT_SHIFT)
6787 #define  TRANS_DDI_SELECT_PORT(x)	((x) << TRANS_DDI_PORT_SHIFT)
6788 #define  TGL_TRANS_DDI_SELECT_PORT(x)	(((x) + 1) << TGL_TRANS_DDI_PORT_SHIFT)
6789 #define  TRANS_DDI_MODE_SELECT_MASK	(7 << 24)
6790 #define  TRANS_DDI_MODE_SELECT_HDMI	(0 << 24)
6791 #define  TRANS_DDI_MODE_SELECT_DVI	(1 << 24)
6792 #define  TRANS_DDI_MODE_SELECT_DP_SST	(2 << 24)
6793 #define  TRANS_DDI_MODE_SELECT_DP_MST	(3 << 24)
6794 #define  TRANS_DDI_MODE_SELECT_FDI_OR_128B132B	(4 << 24)
6795 #define  TRANS_DDI_BPC_MASK		(7 << 20)
6796 #define  TRANS_DDI_BPC_8		(0 << 20)
6797 #define  TRANS_DDI_BPC_10		(1 << 20)
6798 #define  TRANS_DDI_BPC_6		(2 << 20)
6799 #define  TRANS_DDI_BPC_12		(3 << 20)
6800 #define  TRANS_DDI_PORT_SYNC_MASTER_SELECT_MASK	REG_GENMASK(19, 18)
6801 #define  TRANS_DDI_PORT_SYNC_MASTER_SELECT(x)	REG_FIELD_PREP(TRANS_DDI_PORT_SYNC_MASTER_SELECT_MASK, (x))
6802 #define  TRANS_DDI_PVSYNC		(1 << 17)
6803 #define  TRANS_DDI_PHSYNC		(1 << 16)
6804 #define  TRANS_DDI_PORT_SYNC_ENABLE	REG_BIT(15)
6805 #define  TRANS_DDI_EDP_INPUT_MASK	(7 << 12)
6806 #define  TRANS_DDI_EDP_INPUT_A_ON	(0 << 12)
6807 #define  TRANS_DDI_EDP_INPUT_A_ONOFF	(4 << 12)
6808 #define  TRANS_DDI_EDP_INPUT_B_ONOFF	(5 << 12)
6809 #define  TRANS_DDI_EDP_INPUT_C_ONOFF	(6 << 12)
6810 #define  TRANS_DDI_EDP_INPUT_D_ONOFF	(7 << 12)
6811 #define  TRANS_DDI_MST_TRANSPORT_SELECT_MASK	REG_GENMASK(11, 10)
6812 #define  TRANS_DDI_MST_TRANSPORT_SELECT(trans)	\
6813 	REG_FIELD_PREP(TRANS_DDI_MST_TRANSPORT_SELECT_MASK, trans)
6814 #define  TRANS_DDI_HDCP_SIGNALLING	(1 << 9)
6815 #define  TRANS_DDI_DP_VC_PAYLOAD_ALLOC	(1 << 8)
6816 #define  TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE (1 << 7)
6817 #define  TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ (1 << 6)
6818 #define  TRANS_DDI_HDCP_SELECT		REG_BIT(5)
6819 #define  TRANS_DDI_BFI_ENABLE		(1 << 4)
6820 #define  TRANS_DDI_HIGH_TMDS_CHAR_RATE	(1 << 4)
6821 #define  TRANS_DDI_HDMI_SCRAMBLING	(1 << 0)
6822 #define  TRANS_DDI_HDMI_SCRAMBLING_MASK (TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE \
6823 					| TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ \
6824 					| TRANS_DDI_HDMI_SCRAMBLING)
6825 
6826 #define _TRANS_DDI_FUNC_CTL2_A		0x60404
6827 #define _TRANS_DDI_FUNC_CTL2_B		0x61404
6828 #define _TRANS_DDI_FUNC_CTL2_C		0x62404
6829 #define _TRANS_DDI_FUNC_CTL2_EDP	0x6f404
6830 #define _TRANS_DDI_FUNC_CTL2_DSI0	0x6b404
6831 #define _TRANS_DDI_FUNC_CTL2_DSI1	0x6bc04
6832 #define TRANS_DDI_FUNC_CTL2(tran)	_MMIO_TRANS2(tran, _TRANS_DDI_FUNC_CTL2_A)
6833 #define  PORT_SYNC_MODE_ENABLE			REG_BIT(4)
6834 #define  PORT_SYNC_MODE_MASTER_SELECT_MASK	REG_GENMASK(2, 0)
6835 #define  PORT_SYNC_MODE_MASTER_SELECT(x)	REG_FIELD_PREP(PORT_SYNC_MODE_MASTER_SELECT_MASK, (x))
6836 
6837 #define TRANS_CMTG_CHICKEN		_MMIO(0x6fa90)
6838 #define  DISABLE_DPT_CLK_GATING		REG_BIT(1)
6839 
6840 /* DisplayPort Transport Control */
6841 #define _DP_TP_CTL_A			0x64040
6842 #define _DP_TP_CTL_B			0x64140
6843 #define _TGL_DP_TP_CTL_A		0x60540
6844 #define DP_TP_CTL(port) _MMIO_PORT(port, _DP_TP_CTL_A, _DP_TP_CTL_B)
6845 #define TGL_DP_TP_CTL(tran) _MMIO_TRANS2((tran), _TGL_DP_TP_CTL_A)
6846 #define  DP_TP_CTL_ENABLE			(1 << 31)
6847 #define  DP_TP_CTL_FEC_ENABLE			(1 << 30)
6848 #define  DP_TP_CTL_MODE_SST			(0 << 27)
6849 #define  DP_TP_CTL_MODE_MST			(1 << 27)
6850 #define  DP_TP_CTL_FORCE_ACT			(1 << 25)
6851 #define  DP_TP_CTL_ENHANCED_FRAME_ENABLE	(1 << 18)
6852 #define  DP_TP_CTL_FDI_AUTOTRAIN		(1 << 15)
6853 #define  DP_TP_CTL_LINK_TRAIN_MASK		(7 << 8)
6854 #define  DP_TP_CTL_LINK_TRAIN_PAT1		(0 << 8)
6855 #define  DP_TP_CTL_LINK_TRAIN_PAT2		(1 << 8)
6856 #define  DP_TP_CTL_LINK_TRAIN_PAT3		(4 << 8)
6857 #define  DP_TP_CTL_LINK_TRAIN_PAT4		(5 << 8)
6858 #define  DP_TP_CTL_LINK_TRAIN_IDLE		(2 << 8)
6859 #define  DP_TP_CTL_LINK_TRAIN_NORMAL		(3 << 8)
6860 #define  DP_TP_CTL_SCRAMBLE_DISABLE		(1 << 7)
6861 
6862 /* DisplayPort Transport Status */
6863 #define _DP_TP_STATUS_A			0x64044
6864 #define _DP_TP_STATUS_B			0x64144
6865 #define _TGL_DP_TP_STATUS_A		0x60544
6866 #define DP_TP_STATUS(port) _MMIO_PORT(port, _DP_TP_STATUS_A, _DP_TP_STATUS_B)
6867 #define TGL_DP_TP_STATUS(tran) _MMIO_TRANS2((tran), _TGL_DP_TP_STATUS_A)
6868 #define  DP_TP_STATUS_FEC_ENABLE_LIVE		(1 << 28)
6869 #define  DP_TP_STATUS_IDLE_DONE			(1 << 25)
6870 #define  DP_TP_STATUS_ACT_SENT			(1 << 24)
6871 #define  DP_TP_STATUS_MODE_STATUS_MST		(1 << 23)
6872 #define  DP_TP_STATUS_AUTOTRAIN_DONE		(1 << 12)
6873 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC2	(3 << 8)
6874 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC1	(3 << 4)
6875 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC0	(3 << 0)
6876 
6877 /* DDI Buffer Control */
6878 #define _DDI_BUF_CTL_A				0x64000
6879 #define _DDI_BUF_CTL_B				0x64100
6880 #define DDI_BUF_CTL(port) _MMIO_PORT(port, _DDI_BUF_CTL_A, _DDI_BUF_CTL_B)
6881 #define  DDI_BUF_CTL_ENABLE			(1 << 31)
6882 #define  DDI_BUF_TRANS_SELECT(n)	((n) << 24)
6883 #define  DDI_BUF_EMP_MASK			(0xf << 24)
6884 #define  DDI_BUF_PHY_LINK_RATE(r)		((r) << 20)
6885 #define  DDI_BUF_PORT_REVERSAL			(1 << 16)
6886 #define  DDI_BUF_IS_IDLE			(1 << 7)
6887 #define  DDI_BUF_CTL_TC_PHY_OWNERSHIP		REG_BIT(6)
6888 #define  DDI_A_4_LANES				(1 << 4)
6889 #define  DDI_PORT_WIDTH(width)			(((width) - 1) << 1)
6890 #define  DDI_PORT_WIDTH_MASK			(7 << 1)
6891 #define  DDI_PORT_WIDTH_SHIFT			1
6892 #define  DDI_INIT_DISPLAY_DETECTED		(1 << 0)
6893 
6894 /* DDI Buffer Translations */
6895 #define _DDI_BUF_TRANS_A		0x64E00
6896 #define _DDI_BUF_TRANS_B		0x64E60
6897 #define DDI_BUF_TRANS_LO(port, i)	_MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8)
6898 #define  DDI_BUF_BALANCE_LEG_ENABLE	(1 << 31)
6899 #define DDI_BUF_TRANS_HI(port, i)	_MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8 + 4)
6900 
6901 /* DDI DP Compliance Control */
6902 #define _DDI_DP_COMP_CTL_A			0x605F0
6903 #define _DDI_DP_COMP_CTL_B			0x615F0
6904 #define DDI_DP_COMP_CTL(pipe)			_MMIO_PIPE(pipe, _DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)
6905 #define   DDI_DP_COMP_CTL_ENABLE		(1 << 31)
6906 #define   DDI_DP_COMP_CTL_D10_2			(0 << 28)
6907 #define   DDI_DP_COMP_CTL_SCRAMBLED_0		(1 << 28)
6908 #define   DDI_DP_COMP_CTL_PRBS7			(2 << 28)
6909 #define   DDI_DP_COMP_CTL_CUSTOM80		(3 << 28)
6910 #define   DDI_DP_COMP_CTL_HBR2			(4 << 28)
6911 #define   DDI_DP_COMP_CTL_SCRAMBLED_1		(5 << 28)
6912 #define   DDI_DP_COMP_CTL_HBR2_RESET		(0xFC << 0)
6913 
6914 /* DDI DP Compliance Pattern */
6915 #define _DDI_DP_COMP_PAT_A			0x605F4
6916 #define _DDI_DP_COMP_PAT_B			0x615F4
6917 #define DDI_DP_COMP_PAT(pipe, i)		_MMIO(_PIPE(pipe, _DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)
6918 
6919 /* Sideband Interface (SBI) is programmed indirectly, via
6920  * SBI_ADDR, which contains the register offset; and SBI_DATA,
6921  * which contains the payload */
6922 #define SBI_ADDR			_MMIO(0xC6000)
6923 #define SBI_DATA			_MMIO(0xC6004)
6924 #define SBI_CTL_STAT			_MMIO(0xC6008)
6925 #define  SBI_CTL_DEST_ICLK		(0x0 << 16)
6926 #define  SBI_CTL_DEST_MPHY		(0x1 << 16)
6927 #define  SBI_CTL_OP_IORD		(0x2 << 8)
6928 #define  SBI_CTL_OP_IOWR		(0x3 << 8)
6929 #define  SBI_CTL_OP_CRRD		(0x6 << 8)
6930 #define  SBI_CTL_OP_CRWR		(0x7 << 8)
6931 #define  SBI_RESPONSE_FAIL		(0x1 << 1)
6932 #define  SBI_RESPONSE_SUCCESS		(0x0 << 1)
6933 #define  SBI_BUSY			(0x1 << 0)
6934 #define  SBI_READY			(0x0 << 0)
6935 
6936 /* SBI offsets */
6937 #define  SBI_SSCDIVINTPHASE			0x0200
6938 #define  SBI_SSCDIVINTPHASE6			0x0600
6939 #define   SBI_SSCDIVINTPHASE_DIVSEL_SHIFT	1
6940 #define   SBI_SSCDIVINTPHASE_DIVSEL_MASK	(0x7f << 1)
6941 #define   SBI_SSCDIVINTPHASE_DIVSEL(x)		((x) << 1)
6942 #define   SBI_SSCDIVINTPHASE_INCVAL_SHIFT	8
6943 #define   SBI_SSCDIVINTPHASE_INCVAL_MASK	(0x7f << 8)
6944 #define   SBI_SSCDIVINTPHASE_INCVAL(x)		((x) << 8)
6945 #define   SBI_SSCDIVINTPHASE_DIR(x)		((x) << 15)
6946 #define   SBI_SSCDIVINTPHASE_PROPAGATE		(1 << 0)
6947 #define  SBI_SSCDITHPHASE			0x0204
6948 #define  SBI_SSCCTL				0x020c
6949 #define  SBI_SSCCTL6				0x060C
6950 #define   SBI_SSCCTL_PATHALT			(1 << 3)
6951 #define   SBI_SSCCTL_DISABLE			(1 << 0)
6952 #define  SBI_SSCAUXDIV6				0x0610
6953 #define   SBI_SSCAUXDIV_FINALDIV2SEL_SHIFT	4
6954 #define   SBI_SSCAUXDIV_FINALDIV2SEL_MASK	(1 << 4)
6955 #define   SBI_SSCAUXDIV_FINALDIV2SEL(x)		((x) << 4)
6956 #define  SBI_DBUFF0				0x2a00
6957 #define  SBI_GEN0				0x1f00
6958 #define   SBI_GEN0_CFG_BUFFENABLE_DISABLE	(1 << 0)
6959 
6960 /* LPT PIXCLK_GATE */
6961 #define PIXCLK_GATE			_MMIO(0xC6020)
6962 #define  PIXCLK_GATE_UNGATE		(1 << 0)
6963 #define  PIXCLK_GATE_GATE		(0 << 0)
6964 
6965 /* SPLL */
6966 #define SPLL_CTL			_MMIO(0x46020)
6967 #define  SPLL_PLL_ENABLE		(1 << 31)
6968 #define  SPLL_REF_BCLK			(0 << 28)
6969 #define  SPLL_REF_MUXED_SSC		(1 << 28) /* CPU SSC if fused enabled, PCH SSC otherwise */
6970 #define  SPLL_REF_NON_SSC_HSW		(2 << 28)
6971 #define  SPLL_REF_PCH_SSC_BDW		(2 << 28)
6972 #define  SPLL_REF_LCPLL			(3 << 28)
6973 #define  SPLL_REF_MASK			(3 << 28)
6974 #define  SPLL_FREQ_810MHz		(0 << 26)
6975 #define  SPLL_FREQ_1350MHz		(1 << 26)
6976 #define  SPLL_FREQ_2700MHz		(2 << 26)
6977 #define  SPLL_FREQ_MASK			(3 << 26)
6978 
6979 /* WRPLL */
6980 #define _WRPLL_CTL1			0x46040
6981 #define _WRPLL_CTL2			0x46060
6982 #define WRPLL_CTL(pll)			_MMIO_PIPE(pll, _WRPLL_CTL1, _WRPLL_CTL2)
6983 #define  WRPLL_PLL_ENABLE		(1 << 31)
6984 #define  WRPLL_REF_BCLK			(0 << 28)
6985 #define  WRPLL_REF_PCH_SSC		(1 << 28)
6986 #define  WRPLL_REF_MUXED_SSC_BDW	(2 << 28) /* CPU SSC if fused enabled, PCH SSC otherwise */
6987 #define  WRPLL_REF_SPECIAL_HSW		(2 << 28) /* muxed SSC (ULT), non-SSC (non-ULT) */
6988 #define  WRPLL_REF_LCPLL		(3 << 28)
6989 #define  WRPLL_REF_MASK			(3 << 28)
6990 /* WRPLL divider programming */
6991 #define  WRPLL_DIVIDER_REFERENCE(x)	((x) << 0)
6992 #define  WRPLL_DIVIDER_REF_MASK		(0xff)
6993 #define  WRPLL_DIVIDER_POST(x)		((x) << 8)
6994 #define  WRPLL_DIVIDER_POST_MASK	(0x3f << 8)
6995 #define  WRPLL_DIVIDER_POST_SHIFT	8
6996 #define  WRPLL_DIVIDER_FEEDBACK(x)	((x) << 16)
6997 #define  WRPLL_DIVIDER_FB_SHIFT		16
6998 #define  WRPLL_DIVIDER_FB_MASK		(0xff << 16)
6999 
7000 /* Port clock selection */
7001 #define _PORT_CLK_SEL_A			0x46100
7002 #define _PORT_CLK_SEL_B			0x46104
7003 #define PORT_CLK_SEL(port) _MMIO_PORT(port, _PORT_CLK_SEL_A, _PORT_CLK_SEL_B)
7004 #define  PORT_CLK_SEL_MASK		REG_GENMASK(31, 29)
7005 #define  PORT_CLK_SEL_LCPLL_2700	REG_FIELD_PREP(PORT_CLK_SEL_MASK, 0)
7006 #define  PORT_CLK_SEL_LCPLL_1350	REG_FIELD_PREP(PORT_CLK_SEL_MASK, 1)
7007 #define  PORT_CLK_SEL_LCPLL_810		REG_FIELD_PREP(PORT_CLK_SEL_MASK, 2)
7008 #define  PORT_CLK_SEL_SPLL		REG_FIELD_PREP(PORT_CLK_SEL_MASK, 3)
7009 #define  PORT_CLK_SEL_WRPLL(pll)	REG_FIELD_PREP(PORT_CLK_SEL_MASK, 4 + (pll))
7010 #define  PORT_CLK_SEL_WRPLL1		REG_FIELD_PREP(PORT_CLK_SEL_MASK, 4)
7011 #define  PORT_CLK_SEL_WRPLL2		REG_FIELD_PREP(PORT_CLK_SEL_MASK, 5)
7012 #define  PORT_CLK_SEL_NONE		REG_FIELD_PREP(PORT_CLK_SEL_MASK, 7)
7013 
7014 /* On ICL+ this is the same as PORT_CLK_SEL, but all bits change. */
7015 #define DDI_CLK_SEL(port)		PORT_CLK_SEL(port)
7016 #define  DDI_CLK_SEL_MASK		REG_GENMASK(31, 28)
7017 #define  DDI_CLK_SEL_NONE		REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0x0)
7018 #define  DDI_CLK_SEL_MG			REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0x8)
7019 #define  DDI_CLK_SEL_TBT_162		REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xC)
7020 #define  DDI_CLK_SEL_TBT_270		REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xD)
7021 #define  DDI_CLK_SEL_TBT_540		REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xE)
7022 #define  DDI_CLK_SEL_TBT_810		REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xF)
7023 
7024 /* Transcoder clock selection */
7025 #define _TRANS_CLK_SEL_A		0x46140
7026 #define _TRANS_CLK_SEL_B		0x46144
7027 #define TRANS_CLK_SEL(tran) _MMIO_TRANS(tran, _TRANS_CLK_SEL_A, _TRANS_CLK_SEL_B)
7028 /* For each transcoder, we need to select the corresponding port clock */
7029 #define  TRANS_CLK_SEL_DISABLED		(0x0 << 29)
7030 #define  TRANS_CLK_SEL_PORT(x)		(((x) + 1) << 29)
7031 #define  TGL_TRANS_CLK_SEL_DISABLED	(0x0 << 28)
7032 #define  TGL_TRANS_CLK_SEL_PORT(x)	(((x) + 1) << 28)
7033 
7034 
7035 #define CDCLK_FREQ			_MMIO(0x46200)
7036 
7037 #define _TRANSA_MSA_MISC		0x60410
7038 #define _TRANSB_MSA_MISC		0x61410
7039 #define _TRANSC_MSA_MISC		0x62410
7040 #define _TRANS_EDP_MSA_MISC		0x6f410
7041 #define TRANS_MSA_MISC(tran) _MMIO_TRANS2(tran, _TRANSA_MSA_MISC)
7042 /* See DP_MSA_MISC_* for the bit definitions */
7043 
7044 #define _TRANS_A_SET_CONTEXT_LATENCY		0x6007C
7045 #define _TRANS_B_SET_CONTEXT_LATENCY		0x6107C
7046 #define _TRANS_C_SET_CONTEXT_LATENCY		0x6207C
7047 #define _TRANS_D_SET_CONTEXT_LATENCY		0x6307C
7048 #define TRANS_SET_CONTEXT_LATENCY(tran)		_MMIO_TRANS2(tran, _TRANS_A_SET_CONTEXT_LATENCY)
7049 #define  TRANS_SET_CONTEXT_LATENCY_MASK		REG_GENMASK(15, 0)
7050 #define  TRANS_SET_CONTEXT_LATENCY_VALUE(x)	REG_FIELD_PREP(TRANS_SET_CONTEXT_LATENCY_MASK, (x))
7051 
7052 /* LCPLL Control */
7053 #define LCPLL_CTL			_MMIO(0x130040)
7054 #define  LCPLL_PLL_DISABLE		(1 << 31)
7055 #define  LCPLL_PLL_LOCK			(1 << 30)
7056 #define  LCPLL_REF_NON_SSC		(0 << 28)
7057 #define  LCPLL_REF_BCLK			(2 << 28)
7058 #define  LCPLL_REF_PCH_SSC		(3 << 28)
7059 #define  LCPLL_REF_MASK			(3 << 28)
7060 #define  LCPLL_CLK_FREQ_MASK		(3 << 26)
7061 #define  LCPLL_CLK_FREQ_450		(0 << 26)
7062 #define  LCPLL_CLK_FREQ_54O_BDW		(1 << 26)
7063 #define  LCPLL_CLK_FREQ_337_5_BDW	(2 << 26)
7064 #define  LCPLL_CLK_FREQ_675_BDW		(3 << 26)
7065 #define  LCPLL_CD_CLOCK_DISABLE		(1 << 25)
7066 #define  LCPLL_ROOT_CD_CLOCK_DISABLE	(1 << 24)
7067 #define  LCPLL_CD2X_CLOCK_DISABLE	(1 << 23)
7068 #define  LCPLL_POWER_DOWN_ALLOW		(1 << 22)
7069 #define  LCPLL_CD_SOURCE_FCLK		(1 << 21)
7070 #define  LCPLL_CD_SOURCE_FCLK_DONE	(1 << 19)
7071 
7072 /*
7073  * SKL Clocks
7074  */
7075 
7076 /* CDCLK_CTL */
7077 #define CDCLK_CTL			_MMIO(0x46000)
7078 #define  CDCLK_FREQ_SEL_MASK		REG_GENMASK(27, 26)
7079 #define  CDCLK_FREQ_450_432		REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 0)
7080 #define  CDCLK_FREQ_540		REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 1)
7081 #define  CDCLK_FREQ_337_308		REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 2)
7082 #define  CDCLK_FREQ_675_617		REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 3)
7083 #define  BXT_CDCLK_CD2X_DIV_SEL_MASK	REG_GENMASK(23, 22)
7084 #define  BXT_CDCLK_CD2X_DIV_SEL_1	REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 0)
7085 #define  BXT_CDCLK_CD2X_DIV_SEL_1_5	REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 1)
7086 #define  BXT_CDCLK_CD2X_DIV_SEL_2	REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 2)
7087 #define  BXT_CDCLK_CD2X_DIV_SEL_4	REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 3)
7088 #define  BXT_CDCLK_CD2X_PIPE(pipe)	((pipe) << 20)
7089 #define  CDCLK_DIVMUX_CD_OVERRIDE	(1 << 19)
7090 #define  BXT_CDCLK_CD2X_PIPE_NONE	BXT_CDCLK_CD2X_PIPE(3)
7091 #define  ICL_CDCLK_CD2X_PIPE(pipe)	(_PICK(pipe, 0, 2, 6) << 19)
7092 #define  ICL_CDCLK_CD2X_PIPE_NONE	(7 << 19)
7093 #define  TGL_CDCLK_CD2X_PIPE(pipe)	BXT_CDCLK_CD2X_PIPE(pipe)
7094 #define  TGL_CDCLK_CD2X_PIPE_NONE	ICL_CDCLK_CD2X_PIPE_NONE
7095 #define  BXT_CDCLK_SSA_PRECHARGE_ENABLE	(1 << 16)
7096 #define  CDCLK_FREQ_DECIMAL_MASK	(0x7ff)
7097 
7098 /* CDCLK_SQUASH_CTL */
7099 #define CDCLK_SQUASH_CTL		_MMIO(0x46008)
7100 #define  CDCLK_SQUASH_ENABLE		REG_BIT(31)
7101 #define  CDCLK_SQUASH_WINDOW_SIZE_MASK	REG_GENMASK(27, 24)
7102 #define  CDCLK_SQUASH_WINDOW_SIZE(x)	REG_FIELD_PREP(CDCLK_SQUASH_WINDOW_SIZE_MASK, (x))
7103 #define  CDCLK_SQUASH_WAVEFORM_MASK	REG_GENMASK(15, 0)
7104 #define  CDCLK_SQUASH_WAVEFORM(x)	REG_FIELD_PREP(CDCLK_SQUASH_WAVEFORM_MASK, (x))
7105 
7106 /* LCPLL_CTL */
7107 #define LCPLL1_CTL		_MMIO(0x46010)
7108 #define LCPLL2_CTL		_MMIO(0x46014)
7109 #define  LCPLL_PLL_ENABLE	(1 << 31)
7110 
7111 /* DPLL control1 */
7112 #define DPLL_CTRL1		_MMIO(0x6C058)
7113 #define  DPLL_CTRL1_HDMI_MODE(id)		(1 << ((id) * 6 + 5))
7114 #define  DPLL_CTRL1_SSC(id)			(1 << ((id) * 6 + 4))
7115 #define  DPLL_CTRL1_LINK_RATE_MASK(id)		(7 << ((id) * 6 + 1))
7116 #define  DPLL_CTRL1_LINK_RATE_SHIFT(id)		((id) * 6 + 1)
7117 #define  DPLL_CTRL1_LINK_RATE(linkrate, id)	((linkrate) << ((id) * 6 + 1))
7118 #define  DPLL_CTRL1_OVERRIDE(id)		(1 << ((id) * 6))
7119 #define  DPLL_CTRL1_LINK_RATE_2700		0
7120 #define  DPLL_CTRL1_LINK_RATE_1350		1
7121 #define  DPLL_CTRL1_LINK_RATE_810		2
7122 #define  DPLL_CTRL1_LINK_RATE_1620		3
7123 #define  DPLL_CTRL1_LINK_RATE_1080		4
7124 #define  DPLL_CTRL1_LINK_RATE_2160		5
7125 
7126 /* DPLL control2 */
7127 #define DPLL_CTRL2				_MMIO(0x6C05C)
7128 #define  DPLL_CTRL2_DDI_CLK_OFF(port)		(1 << ((port) + 15))
7129 #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)	(3 << ((port) * 3 + 1))
7130 #define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    ((port) * 3 + 1)
7131 #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)	((clk) << ((port) * 3 + 1))
7132 #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1 << ((port) * 3))
7133 
7134 /* DPLL Status */
7135 #define DPLL_STATUS	_MMIO(0x6C060)
7136 #define  DPLL_LOCK(id) (1 << ((id) * 8))
7137 
7138 /* DPLL cfg */
7139 #define _DPLL1_CFGCR1	0x6C040
7140 #define _DPLL2_CFGCR1	0x6C048
7141 #define _DPLL3_CFGCR1	0x6C050
7142 #define  DPLL_CFGCR1_FREQ_ENABLE	(1 << 31)
7143 #define  DPLL_CFGCR1_DCO_FRACTION_MASK	(0x7fff << 9)
7144 #define  DPLL_CFGCR1_DCO_FRACTION(x)	((x) << 9)
7145 #define  DPLL_CFGCR1_DCO_INTEGER_MASK	(0x1ff)
7146 
7147 #define _DPLL1_CFGCR2	0x6C044
7148 #define _DPLL2_CFGCR2	0x6C04C
7149 #define _DPLL3_CFGCR2	0x6C054
7150 #define  DPLL_CFGCR2_QDIV_RATIO_MASK	(0xff << 8)
7151 #define  DPLL_CFGCR2_QDIV_RATIO(x)	((x) << 8)
7152 #define  DPLL_CFGCR2_QDIV_MODE(x)	((x) << 7)
7153 #define  DPLL_CFGCR2_KDIV_MASK		(3 << 5)
7154 #define  DPLL_CFGCR2_KDIV(x)		((x) << 5)
7155 #define  DPLL_CFGCR2_KDIV_5 (0 << 5)
7156 #define  DPLL_CFGCR2_KDIV_2 (1 << 5)
7157 #define  DPLL_CFGCR2_KDIV_3 (2 << 5)
7158 #define  DPLL_CFGCR2_KDIV_1 (3 << 5)
7159 #define  DPLL_CFGCR2_PDIV_MASK		(7 << 2)
7160 #define  DPLL_CFGCR2_PDIV(x)		((x) << 2)
7161 #define  DPLL_CFGCR2_PDIV_1 (0 << 2)
7162 #define  DPLL_CFGCR2_PDIV_2 (1 << 2)
7163 #define  DPLL_CFGCR2_PDIV_3 (2 << 2)
7164 #define  DPLL_CFGCR2_PDIV_7 (4 << 2)
7165 #define  DPLL_CFGCR2_PDIV_7_INVALID	(5 << 2)
7166 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK	(3)
7167 
7168 #define DPLL_CFGCR1(id)	_MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR1)
7169 #define DPLL_CFGCR2(id)	_MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR2, _DPLL2_CFGCR2)
7170 
7171 /* ICL Clocks */
7172 #define ICL_DPCLKA_CFGCR0			_MMIO(0x164280)
7173 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)	(1 << _PICK(phy, 10, 11, 24, 4, 5))
7174 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)	REG_BIT((phy) + 10)
7175 #define  ICL_DPCLKA_CFGCR0_TC_CLK_OFF(tc_port)	(1 << ((tc_port) < TC_PORT_4 ? \
7176 						       (tc_port) + 12 : \
7177 						       (tc_port) - TC_PORT_4 + 21))
7178 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)	((phy) * 2)
7179 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy)	(3 << ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7180 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy)	((pll) << ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7181 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)	_PICK(phy, 0, 2, 4, 27)
7182 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy) \
7183 	(3 << RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7184 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy) \
7185 	((pll) << RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7186 
7187 /*
7188  * DG1 Clocks
7189  * First registers controls the first A and B, while the second register
7190  * controls the phy C and D. The bits on these registers are the
7191  * same, but refer to different phys
7192  */
7193 #define _DG1_DPCLKA_CFGCR0				0x164280
7194 #define _DG1_DPCLKA1_CFGCR0				0x16C280
7195 #define _DG1_DPCLKA_PHY_IDX(phy)			((phy) % 2)
7196 #define _DG1_DPCLKA_PLL_IDX(pll)			((pll) % 2)
7197 #define DG1_DPCLKA_CFGCR0(phy)				_MMIO_PHY((phy) / 2, \
7198 								  _DG1_DPCLKA_CFGCR0, \
7199 								  _DG1_DPCLKA1_CFGCR0)
7200 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)		REG_BIT(_DG1_DPCLKA_PHY_IDX(phy) + 10)
7201 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)	(_DG1_DPCLKA_PHY_IDX(phy) * 2)
7202 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy)	(_DG1_DPCLKA_PLL_IDX(pll) << DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7203 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy)	(0x3 << DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7204 
7205 /* ADLS Clocks */
7206 #define _ADLS_DPCLKA_CFGCR0			0x164280
7207 #define _ADLS_DPCLKA_CFGCR1			0x1642BC
7208 #define ADLS_DPCLKA_CFGCR(phy)			_MMIO_PHY((phy) / 3, \
7209 							  _ADLS_DPCLKA_CFGCR0, \
7210 							  _ADLS_DPCLKA_CFGCR1)
7211 #define  ADLS_DPCLKA_CFGCR_DDI_SHIFT(phy)		(((phy) % 3) * 2)
7212 /* ADLS DPCLKA_CFGCR0 DDI mask */
7213 #define  ADLS_DPCLKA_DDII_SEL_MASK			REG_GENMASK(5, 4)
7214 #define  ADLS_DPCLKA_DDIB_SEL_MASK			REG_GENMASK(3, 2)
7215 #define  ADLS_DPCLKA_DDIA_SEL_MASK			REG_GENMASK(1, 0)
7216 /* ADLS DPCLKA_CFGCR1 DDI mask */
7217 #define  ADLS_DPCLKA_DDIK_SEL_MASK			REG_GENMASK(3, 2)
7218 #define  ADLS_DPCLKA_DDIJ_SEL_MASK			REG_GENMASK(1, 0)
7219 #define  ADLS_DPCLKA_CFGCR_DDI_CLK_SEL_MASK(phy)	_PICK((phy), \
7220 							ADLS_DPCLKA_DDIA_SEL_MASK, \
7221 							ADLS_DPCLKA_DDIB_SEL_MASK, \
7222 							ADLS_DPCLKA_DDII_SEL_MASK, \
7223 							ADLS_DPCLKA_DDIJ_SEL_MASK, \
7224 							ADLS_DPCLKA_DDIK_SEL_MASK)
7225 
7226 /* ICL PLL */
7227 #define DPLL0_ENABLE		0x46010
7228 #define DPLL1_ENABLE		0x46014
7229 #define _ADLS_DPLL2_ENABLE	0x46018
7230 #define _ADLS_DPLL3_ENABLE	0x46030
7231 #define  PLL_ENABLE		(1 << 31)
7232 #define  PLL_LOCK		(1 << 30)
7233 #define  PLL_POWER_ENABLE	(1 << 27)
7234 #define  PLL_POWER_STATE	(1 << 26)
7235 #define ICL_DPLL_ENABLE(pll)	_MMIO_PLL3(pll, DPLL0_ENABLE, DPLL1_ENABLE, \
7236 					   _ADLS_DPLL2_ENABLE, _ADLS_DPLL3_ENABLE)
7237 
7238 #define _DG2_PLL3_ENABLE	0x4601C
7239 
7240 #define DG2_PLL_ENABLE(pll) _MMIO_PLL3(pll, DPLL0_ENABLE, DPLL1_ENABLE, \
7241 				       _ADLS_DPLL2_ENABLE, _DG2_PLL3_ENABLE)
7242 
7243 #define TBT_PLL_ENABLE		_MMIO(0x46020)
7244 
7245 #define _MG_PLL1_ENABLE		0x46030
7246 #define _MG_PLL2_ENABLE		0x46034
7247 #define _MG_PLL3_ENABLE		0x46038
7248 #define _MG_PLL4_ENABLE		0x4603C
7249 /* Bits are the same as DPLL0_ENABLE */
7250 #define MG_PLL_ENABLE(tc_port)	_MMIO_PORT((tc_port), _MG_PLL1_ENABLE, \
7251 					   _MG_PLL2_ENABLE)
7252 
7253 /* DG1 PLL */
7254 #define DG1_DPLL_ENABLE(pll)    _MMIO_PLL3(pll, DPLL0_ENABLE, DPLL1_ENABLE, \
7255 					   _MG_PLL1_ENABLE, _MG_PLL2_ENABLE)
7256 
7257 /* ADL-P Type C PLL */
7258 #define PORTTC1_PLL_ENABLE	0x46038
7259 #define PORTTC2_PLL_ENABLE	0x46040
7260 
7261 #define ADLP_PORTTC_PLL_ENABLE(tc_port)		_MMIO_PORT((tc_port), \
7262 							    PORTTC1_PLL_ENABLE, \
7263 							    PORTTC2_PLL_ENABLE)
7264 
7265 #define _ICL_DPLL0_CFGCR0		0x164000
7266 #define _ICL_DPLL1_CFGCR0		0x164080
7267 #define ICL_DPLL_CFGCR0(pll)		_MMIO_PLL(pll, _ICL_DPLL0_CFGCR0, \
7268 						  _ICL_DPLL1_CFGCR0)
7269 #define   DPLL_CFGCR0_HDMI_MODE		(1 << 30)
7270 #define   DPLL_CFGCR0_SSC_ENABLE	(1 << 29)
7271 #define   DPLL_CFGCR0_SSC_ENABLE_ICL	(1 << 25)
7272 #define   DPLL_CFGCR0_LINK_RATE_MASK	(0xf << 25)
7273 #define   DPLL_CFGCR0_LINK_RATE_2700	(0 << 25)
7274 #define   DPLL_CFGCR0_LINK_RATE_1350	(1 << 25)
7275 #define   DPLL_CFGCR0_LINK_RATE_810	(2 << 25)
7276 #define   DPLL_CFGCR0_LINK_RATE_1620	(3 << 25)
7277 #define   DPLL_CFGCR0_LINK_RATE_1080	(4 << 25)
7278 #define   DPLL_CFGCR0_LINK_RATE_2160	(5 << 25)
7279 #define   DPLL_CFGCR0_LINK_RATE_3240	(6 << 25)
7280 #define   DPLL_CFGCR0_LINK_RATE_4050	(7 << 25)
7281 #define   DPLL_CFGCR0_DCO_FRACTION_MASK	(0x7fff << 10)
7282 #define   DPLL_CFGCR0_DCO_FRACTION_SHIFT	(10)
7283 #define   DPLL_CFGCR0_DCO_FRACTION(x)	((x) << 10)
7284 #define   DPLL_CFGCR0_DCO_INTEGER_MASK	(0x3ff)
7285 
7286 #define _ICL_DPLL0_CFGCR1		0x164004
7287 #define _ICL_DPLL1_CFGCR1		0x164084
7288 #define ICL_DPLL_CFGCR1(pll)		_MMIO_PLL(pll, _ICL_DPLL0_CFGCR1, \
7289 						  _ICL_DPLL1_CFGCR1)
7290 #define   DPLL_CFGCR1_QDIV_RATIO_MASK	(0xff << 10)
7291 #define   DPLL_CFGCR1_QDIV_RATIO_SHIFT	(10)
7292 #define   DPLL_CFGCR1_QDIV_RATIO(x)	((x) << 10)
7293 #define   DPLL_CFGCR1_QDIV_MODE_SHIFT	(9)
7294 #define   DPLL_CFGCR1_QDIV_MODE(x)	((x) << 9)
7295 #define   DPLL_CFGCR1_KDIV_MASK		(7 << 6)
7296 #define   DPLL_CFGCR1_KDIV_SHIFT		(6)
7297 #define   DPLL_CFGCR1_KDIV(x)		((x) << 6)
7298 #define   DPLL_CFGCR1_KDIV_1		(1 << 6)
7299 #define   DPLL_CFGCR1_KDIV_2		(2 << 6)
7300 #define   DPLL_CFGCR1_KDIV_3		(4 << 6)
7301 #define   DPLL_CFGCR1_PDIV_MASK		(0xf << 2)
7302 #define   DPLL_CFGCR1_PDIV_SHIFT		(2)
7303 #define   DPLL_CFGCR1_PDIV(x)		((x) << 2)
7304 #define   DPLL_CFGCR1_PDIV_2		(1 << 2)
7305 #define   DPLL_CFGCR1_PDIV_3		(2 << 2)
7306 #define   DPLL_CFGCR1_PDIV_5		(4 << 2)
7307 #define   DPLL_CFGCR1_PDIV_7		(8 << 2)
7308 #define   DPLL_CFGCR1_CENTRAL_FREQ	(3 << 0)
7309 #define   DPLL_CFGCR1_CENTRAL_FREQ_8400	(3 << 0)
7310 #define   TGL_DPLL_CFGCR1_CFSELOVRD_NORMAL_XTAL	(0 << 0)
7311 
7312 #define _TGL_DPLL0_CFGCR0		0x164284
7313 #define _TGL_DPLL1_CFGCR0		0x16428C
7314 #define _TGL_TBTPLL_CFGCR0		0x16429C
7315 #define TGL_DPLL_CFGCR0(pll)		_MMIO_PLL3(pll, _TGL_DPLL0_CFGCR0, \
7316 						  _TGL_DPLL1_CFGCR0, \
7317 						  _TGL_TBTPLL_CFGCR0)
7318 #define RKL_DPLL_CFGCR0(pll)		_MMIO_PLL(pll, _TGL_DPLL0_CFGCR0, \
7319 						  _TGL_DPLL1_CFGCR0)
7320 
7321 #define _TGL_DPLL0_DIV0					0x164B00
7322 #define _TGL_DPLL1_DIV0					0x164C00
7323 #define TGL_DPLL0_DIV0(pll)				_MMIO_PLL(pll, _TGL_DPLL0_DIV0, _TGL_DPLL1_DIV0)
7324 #define   TGL_DPLL0_DIV0_AFC_STARTUP_MASK		REG_GENMASK(27, 25)
7325 #define   TGL_DPLL0_DIV0_AFC_STARTUP(val)		REG_FIELD_PREP(TGL_DPLL0_DIV0_AFC_STARTUP_MASK, (val))
7326 
7327 #define _TGL_DPLL0_CFGCR1		0x164288
7328 #define _TGL_DPLL1_CFGCR1		0x164290
7329 #define _TGL_TBTPLL_CFGCR1		0x1642A0
7330 #define TGL_DPLL_CFGCR1(pll)		_MMIO_PLL3(pll, _TGL_DPLL0_CFGCR1, \
7331 						   _TGL_DPLL1_CFGCR1, \
7332 						   _TGL_TBTPLL_CFGCR1)
7333 #define RKL_DPLL_CFGCR1(pll)		_MMIO_PLL(pll, _TGL_DPLL0_CFGCR1, \
7334 						  _TGL_DPLL1_CFGCR1)
7335 
7336 #define _DG1_DPLL2_CFGCR0		0x16C284
7337 #define _DG1_DPLL3_CFGCR0		0x16C28C
7338 #define DG1_DPLL_CFGCR0(pll)		_MMIO_PLL3(pll, _TGL_DPLL0_CFGCR0, \
7339 						   _TGL_DPLL1_CFGCR0, \
7340 						   _DG1_DPLL2_CFGCR0, \
7341 						   _DG1_DPLL3_CFGCR0)
7342 
7343 #define _DG1_DPLL2_CFGCR1               0x16C288
7344 #define _DG1_DPLL3_CFGCR1               0x16C290
7345 #define DG1_DPLL_CFGCR1(pll)            _MMIO_PLL3(pll, _TGL_DPLL0_CFGCR1, \
7346 						   _TGL_DPLL1_CFGCR1, \
7347 						   _DG1_DPLL2_CFGCR1, \
7348 						   _DG1_DPLL3_CFGCR1)
7349 
7350 /* For ADL-S DPLL4_CFGCR0/1 are used to control DPLL2 */
7351 #define _ADLS_DPLL3_CFGCR0		0x1642C0
7352 #define _ADLS_DPLL4_CFGCR0		0x164294
7353 #define ADLS_DPLL_CFGCR0(pll)		_MMIO_PLL3(pll, _TGL_DPLL0_CFGCR0, \
7354 						   _TGL_DPLL1_CFGCR0, \
7355 						   _ADLS_DPLL4_CFGCR0, \
7356 						   _ADLS_DPLL3_CFGCR0)
7357 
7358 #define _ADLS_DPLL3_CFGCR1		0x1642C4
7359 #define _ADLS_DPLL4_CFGCR1		0x164298
7360 #define ADLS_DPLL_CFGCR1(pll)		_MMIO_PLL3(pll, _TGL_DPLL0_CFGCR1, \
7361 						   _TGL_DPLL1_CFGCR1, \
7362 						   _ADLS_DPLL4_CFGCR1, \
7363 						   _ADLS_DPLL3_CFGCR1)
7364 
7365 /* BXT display engine PLL */
7366 #define BXT_DE_PLL_CTL			_MMIO(0x6d000)
7367 #define   BXT_DE_PLL_RATIO(x)		(x)	/* {60,65,100} * 19.2MHz */
7368 #define   BXT_DE_PLL_RATIO_MASK		0xff
7369 
7370 #define BXT_DE_PLL_ENABLE		_MMIO(0x46070)
7371 #define   BXT_DE_PLL_PLL_ENABLE		(1 << 31)
7372 #define   BXT_DE_PLL_LOCK		(1 << 30)
7373 #define   BXT_DE_PLL_FREQ_REQ		(1 << 23)
7374 #define   BXT_DE_PLL_FREQ_REQ_ACK	(1 << 22)
7375 #define   ICL_CDCLK_PLL_RATIO(x)	(x)
7376 #define   ICL_CDCLK_PLL_RATIO_MASK	0xff
7377 
7378 /* GEN9 DC */
7379 #define DC_STATE_EN			_MMIO(0x45504)
7380 #define  DC_STATE_DISABLE		0
7381 #define  DC_STATE_EN_DC3CO		REG_BIT(30)
7382 #define  DC_STATE_DC3CO_STATUS		REG_BIT(29)
7383 #define  DC_STATE_EN_UPTO_DC5		(1 << 0)
7384 #define  DC_STATE_EN_DC9		(1 << 3)
7385 #define  DC_STATE_EN_UPTO_DC6		(2 << 0)
7386 #define  DC_STATE_EN_UPTO_DC5_DC6_MASK   0x3
7387 
7388 #define  DC_STATE_DEBUG                  _MMIO(0x45520)
7389 #define  DC_STATE_DEBUG_MASK_CORES	(1 << 0)
7390 #define  DC_STATE_DEBUG_MASK_MEMORY_UP	(1 << 1)
7391 
7392 #define D_COMP_BDW			_MMIO(0x138144)
7393 
7394 /* Pipe WM_LINETIME - watermark line time */
7395 #define _WM_LINETIME_A		0x45270
7396 #define _WM_LINETIME_B		0x45274
7397 #define WM_LINETIME(pipe) _MMIO_PIPE(pipe, _WM_LINETIME_A, _WM_LINETIME_B)
7398 #define  HSW_LINETIME_MASK	REG_GENMASK(8, 0)
7399 #define  HSW_LINETIME(x)	REG_FIELD_PREP(HSW_LINETIME_MASK, (x))
7400 #define  HSW_IPS_LINETIME_MASK	REG_GENMASK(24, 16)
7401 #define  HSW_IPS_LINETIME(x)	REG_FIELD_PREP(HSW_IPS_LINETIME_MASK, (x))
7402 
7403 /* SFUSE_STRAP */
7404 #define SFUSE_STRAP			_MMIO(0xc2014)
7405 #define  SFUSE_STRAP_FUSE_LOCK		(1 << 13)
7406 #define  SFUSE_STRAP_RAW_FREQUENCY	(1 << 8)
7407 #define  SFUSE_STRAP_DISPLAY_DISABLED	(1 << 7)
7408 #define  SFUSE_STRAP_CRT_DISABLED	(1 << 6)
7409 #define  SFUSE_STRAP_DDIF_DETECTED	(1 << 3)
7410 #define  SFUSE_STRAP_DDIB_DETECTED	(1 << 2)
7411 #define  SFUSE_STRAP_DDIC_DETECTED	(1 << 1)
7412 #define  SFUSE_STRAP_DDID_DETECTED	(1 << 0)
7413 
7414 #define WM_MISC				_MMIO(0x45260)
7415 #define  WM_MISC_DATA_PARTITION_5_6	(1 << 0)
7416 
7417 #define WM_DBG				_MMIO(0x45280)
7418 #define  WM_DBG_DISALLOW_MULTIPLE_LP	(1 << 0)
7419 #define  WM_DBG_DISALLOW_MAXFIFO	(1 << 1)
7420 #define  WM_DBG_DISALLOW_SPRITE		(1 << 2)
7421 
7422 /* pipe CSC */
7423 #define _PIPE_A_CSC_COEFF_RY_GY	0x49010
7424 #define _PIPE_A_CSC_COEFF_BY	0x49014
7425 #define _PIPE_A_CSC_COEFF_RU_GU	0x49018
7426 #define _PIPE_A_CSC_COEFF_BU	0x4901c
7427 #define _PIPE_A_CSC_COEFF_RV_GV	0x49020
7428 #define _PIPE_A_CSC_COEFF_BV	0x49024
7429 
7430 #define _PIPE_A_CSC_MODE	0x49028
7431 #define  ICL_CSC_ENABLE			(1 << 31) /* icl+ */
7432 #define  ICL_OUTPUT_CSC_ENABLE		(1 << 30) /* icl+ */
7433 #define  CSC_BLACK_SCREEN_OFFSET	(1 << 2) /* ilk/snb */
7434 #define  CSC_POSITION_BEFORE_GAMMA	(1 << 1) /* pre-glk */
7435 #define  CSC_MODE_YUV_TO_RGB		(1 << 0) /* ilk/snb */
7436 
7437 #define _PIPE_A_CSC_PREOFF_HI	0x49030
7438 #define _PIPE_A_CSC_PREOFF_ME	0x49034
7439 #define _PIPE_A_CSC_PREOFF_LO	0x49038
7440 #define _PIPE_A_CSC_POSTOFF_HI	0x49040
7441 #define _PIPE_A_CSC_POSTOFF_ME	0x49044
7442 #define _PIPE_A_CSC_POSTOFF_LO	0x49048
7443 
7444 #define _PIPE_B_CSC_COEFF_RY_GY	0x49110
7445 #define _PIPE_B_CSC_COEFF_BY	0x49114
7446 #define _PIPE_B_CSC_COEFF_RU_GU	0x49118
7447 #define _PIPE_B_CSC_COEFF_BU	0x4911c
7448 #define _PIPE_B_CSC_COEFF_RV_GV	0x49120
7449 #define _PIPE_B_CSC_COEFF_BV	0x49124
7450 #define _PIPE_B_CSC_MODE	0x49128
7451 #define _PIPE_B_CSC_PREOFF_HI	0x49130
7452 #define _PIPE_B_CSC_PREOFF_ME	0x49134
7453 #define _PIPE_B_CSC_PREOFF_LO	0x49138
7454 #define _PIPE_B_CSC_POSTOFF_HI	0x49140
7455 #define _PIPE_B_CSC_POSTOFF_ME	0x49144
7456 #define _PIPE_B_CSC_POSTOFF_LO	0x49148
7457 
7458 #define PIPE_CSC_COEFF_RY_GY(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RY_GY, _PIPE_B_CSC_COEFF_RY_GY)
7459 #define PIPE_CSC_COEFF_BY(pipe)		_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BY, _PIPE_B_CSC_COEFF_BY)
7460 #define PIPE_CSC_COEFF_RU_GU(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RU_GU, _PIPE_B_CSC_COEFF_RU_GU)
7461 #define PIPE_CSC_COEFF_BU(pipe)		_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BU, _PIPE_B_CSC_COEFF_BU)
7462 #define PIPE_CSC_COEFF_RV_GV(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RV_GV, _PIPE_B_CSC_COEFF_RV_GV)
7463 #define PIPE_CSC_COEFF_BV(pipe)		_MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BV, _PIPE_B_CSC_COEFF_BV)
7464 #define PIPE_CSC_MODE(pipe)		_MMIO_PIPE(pipe, _PIPE_A_CSC_MODE, _PIPE_B_CSC_MODE)
7465 #define PIPE_CSC_PREOFF_HI(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_HI, _PIPE_B_CSC_PREOFF_HI)
7466 #define PIPE_CSC_PREOFF_ME(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_ME, _PIPE_B_CSC_PREOFF_ME)
7467 #define PIPE_CSC_PREOFF_LO(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_LO, _PIPE_B_CSC_PREOFF_LO)
7468 #define PIPE_CSC_POSTOFF_HI(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_HI, _PIPE_B_CSC_POSTOFF_HI)
7469 #define PIPE_CSC_POSTOFF_ME(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_ME, _PIPE_B_CSC_POSTOFF_ME)
7470 #define PIPE_CSC_POSTOFF_LO(pipe)	_MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_LO, _PIPE_B_CSC_POSTOFF_LO)
7471 
7472 /* Pipe Output CSC */
7473 #define _PIPE_A_OUTPUT_CSC_COEFF_RY_GY	0x49050
7474 #define _PIPE_A_OUTPUT_CSC_COEFF_BY	0x49054
7475 #define _PIPE_A_OUTPUT_CSC_COEFF_RU_GU	0x49058
7476 #define _PIPE_A_OUTPUT_CSC_COEFF_BU	0x4905c
7477 #define _PIPE_A_OUTPUT_CSC_COEFF_RV_GV	0x49060
7478 #define _PIPE_A_OUTPUT_CSC_COEFF_BV	0x49064
7479 #define _PIPE_A_OUTPUT_CSC_PREOFF_HI	0x49068
7480 #define _PIPE_A_OUTPUT_CSC_PREOFF_ME	0x4906c
7481 #define _PIPE_A_OUTPUT_CSC_PREOFF_LO	0x49070
7482 #define _PIPE_A_OUTPUT_CSC_POSTOFF_HI	0x49074
7483 #define _PIPE_A_OUTPUT_CSC_POSTOFF_ME	0x49078
7484 #define _PIPE_A_OUTPUT_CSC_POSTOFF_LO	0x4907c
7485 
7486 #define _PIPE_B_OUTPUT_CSC_COEFF_RY_GY	0x49150
7487 #define _PIPE_B_OUTPUT_CSC_COEFF_BY	0x49154
7488 #define _PIPE_B_OUTPUT_CSC_COEFF_RU_GU	0x49158
7489 #define _PIPE_B_OUTPUT_CSC_COEFF_BU	0x4915c
7490 #define _PIPE_B_OUTPUT_CSC_COEFF_RV_GV	0x49160
7491 #define _PIPE_B_OUTPUT_CSC_COEFF_BV	0x49164
7492 #define _PIPE_B_OUTPUT_CSC_PREOFF_HI	0x49168
7493 #define _PIPE_B_OUTPUT_CSC_PREOFF_ME	0x4916c
7494 #define _PIPE_B_OUTPUT_CSC_PREOFF_LO	0x49170
7495 #define _PIPE_B_OUTPUT_CSC_POSTOFF_HI	0x49174
7496 #define _PIPE_B_OUTPUT_CSC_POSTOFF_ME	0x49178
7497 #define _PIPE_B_OUTPUT_CSC_POSTOFF_LO	0x4917c
7498 
7499 #define PIPE_CSC_OUTPUT_COEFF_RY_GY(pipe)	_MMIO_PIPE(pipe,\
7500 							   _PIPE_A_OUTPUT_CSC_COEFF_RY_GY,\
7501 							   _PIPE_B_OUTPUT_CSC_COEFF_RY_GY)
7502 #define PIPE_CSC_OUTPUT_COEFF_BY(pipe)		_MMIO_PIPE(pipe, \
7503 							   _PIPE_A_OUTPUT_CSC_COEFF_BY, \
7504 							   _PIPE_B_OUTPUT_CSC_COEFF_BY)
7505 #define PIPE_CSC_OUTPUT_COEFF_RU_GU(pipe)	_MMIO_PIPE(pipe, \
7506 							   _PIPE_A_OUTPUT_CSC_COEFF_RU_GU, \
7507 							   _PIPE_B_OUTPUT_CSC_COEFF_RU_GU)
7508 #define PIPE_CSC_OUTPUT_COEFF_BU(pipe)		_MMIO_PIPE(pipe, \
7509 							   _PIPE_A_OUTPUT_CSC_COEFF_BU, \
7510 							   _PIPE_B_OUTPUT_CSC_COEFF_BU)
7511 #define PIPE_CSC_OUTPUT_COEFF_RV_GV(pipe)	_MMIO_PIPE(pipe, \
7512 							   _PIPE_A_OUTPUT_CSC_COEFF_RV_GV, \
7513 							   _PIPE_B_OUTPUT_CSC_COEFF_RV_GV)
7514 #define PIPE_CSC_OUTPUT_COEFF_BV(pipe)		_MMIO_PIPE(pipe, \
7515 							   _PIPE_A_OUTPUT_CSC_COEFF_BV, \
7516 							   _PIPE_B_OUTPUT_CSC_COEFF_BV)
7517 #define PIPE_CSC_OUTPUT_PREOFF_HI(pipe)		_MMIO_PIPE(pipe, \
7518 							   _PIPE_A_OUTPUT_CSC_PREOFF_HI, \
7519 							   _PIPE_B_OUTPUT_CSC_PREOFF_HI)
7520 #define PIPE_CSC_OUTPUT_PREOFF_ME(pipe)		_MMIO_PIPE(pipe, \
7521 							   _PIPE_A_OUTPUT_CSC_PREOFF_ME, \
7522 							   _PIPE_B_OUTPUT_CSC_PREOFF_ME)
7523 #define PIPE_CSC_OUTPUT_PREOFF_LO(pipe)		_MMIO_PIPE(pipe, \
7524 							   _PIPE_A_OUTPUT_CSC_PREOFF_LO, \
7525 							   _PIPE_B_OUTPUT_CSC_PREOFF_LO)
7526 #define PIPE_CSC_OUTPUT_POSTOFF_HI(pipe)	_MMIO_PIPE(pipe, \
7527 							   _PIPE_A_OUTPUT_CSC_POSTOFF_HI, \
7528 							   _PIPE_B_OUTPUT_CSC_POSTOFF_HI)
7529 #define PIPE_CSC_OUTPUT_POSTOFF_ME(pipe)	_MMIO_PIPE(pipe, \
7530 							   _PIPE_A_OUTPUT_CSC_POSTOFF_ME, \
7531 							   _PIPE_B_OUTPUT_CSC_POSTOFF_ME)
7532 #define PIPE_CSC_OUTPUT_POSTOFF_LO(pipe)	_MMIO_PIPE(pipe, \
7533 							   _PIPE_A_OUTPUT_CSC_POSTOFF_LO, \
7534 							   _PIPE_B_OUTPUT_CSC_POSTOFF_LO)
7535 
7536 /* pipe degamma/gamma LUTs on IVB+ */
7537 #define _PAL_PREC_INDEX_A	0x4A400
7538 #define _PAL_PREC_INDEX_B	0x4AC00
7539 #define _PAL_PREC_INDEX_C	0x4B400
7540 #define   PAL_PREC_SPLIT_MODE		REG_BIT(31)
7541 #define   PAL_PREC_AUTO_INCREMENT	REG_BIT(15)
7542 #define   PAL_PREC_INDEX_VALUE_MASK	REG_GENMASK(9, 0)
7543 #define   PAL_PREC_INDEX_VALUE(x)	REG_FIELD_PREP(PAL_PREC_INDEX_VALUE_MASK, (x))
7544 #define _PAL_PREC_DATA_A	0x4A404
7545 #define _PAL_PREC_DATA_B	0x4AC04
7546 #define _PAL_PREC_DATA_C	0x4B404
7547 /* see PREC_PALETTE_* for the bits */
7548 #define _PAL_PREC_GC_MAX_A	0x4A410
7549 #define _PAL_PREC_GC_MAX_B	0x4AC10
7550 #define _PAL_PREC_GC_MAX_C	0x4B410
7551 #define _PAL_PREC_EXT_GC_MAX_A	0x4A420
7552 #define _PAL_PREC_EXT_GC_MAX_B	0x4AC20
7553 #define _PAL_PREC_EXT_GC_MAX_C	0x4B420
7554 #define _PAL_PREC_EXT2_GC_MAX_A	0x4A430
7555 #define _PAL_PREC_EXT2_GC_MAX_B	0x4AC30
7556 #define _PAL_PREC_EXT2_GC_MAX_C	0x4B430
7557 
7558 #define PREC_PAL_INDEX(pipe)		_MMIO_PIPE(pipe, _PAL_PREC_INDEX_A, _PAL_PREC_INDEX_B)
7559 #define PREC_PAL_DATA(pipe)		_MMIO_PIPE(pipe, _PAL_PREC_DATA_A, _PAL_PREC_DATA_B)
7560 #define PREC_PAL_GC_MAX(pipe, i)	_MMIO(_PIPE(pipe, _PAL_PREC_GC_MAX_A, _PAL_PREC_GC_MAX_B) + (i) * 4) /* u1.16 */
7561 #define PREC_PAL_EXT_GC_MAX(pipe, i)	_MMIO(_PIPE(pipe, _PAL_PREC_EXT_GC_MAX_A, _PAL_PREC_EXT_GC_MAX_B) + (i) * 4) /* u3.16 */
7562 #define PREC_PAL_EXT2_GC_MAX(pipe, i)	_MMIO(_PIPE(pipe, _PAL_PREC_EXT2_GC_MAX_A, _PAL_PREC_EXT2_GC_MAX_B) + (i) * 4) /* glk+, u3.16 */
7563 
7564 #define _PRE_CSC_GAMC_INDEX_A	0x4A484
7565 #define _PRE_CSC_GAMC_INDEX_B	0x4AC84
7566 #define _PRE_CSC_GAMC_INDEX_C	0x4B484
7567 #define   PRE_CSC_GAMC_AUTO_INCREMENT	REG_BIT(10)
7568 #define   PRE_CSC_GAMC_INDEX_VALUE_MASK	REG_GENMASK(7, 0)
7569 #define   PRE_CSC_GAMC_INDEX_VALUE(x)	REG_FIELD_PREP(PRE_CSC_GAMC_INDEX_VALUE_MASK, (x))
7570 #define _PRE_CSC_GAMC_DATA_A	0x4A488
7571 #define _PRE_CSC_GAMC_DATA_B	0x4AC88
7572 #define _PRE_CSC_GAMC_DATA_C	0x4B488
7573 
7574 #define PRE_CSC_GAMC_INDEX(pipe)	_MMIO_PIPE(pipe, _PRE_CSC_GAMC_INDEX_A, _PRE_CSC_GAMC_INDEX_B)
7575 #define PRE_CSC_GAMC_DATA(pipe)		_MMIO_PIPE(pipe, _PRE_CSC_GAMC_DATA_A, _PRE_CSC_GAMC_DATA_B)
7576 
7577 /* ICL Multi segmented gamma */
7578 #define _PAL_PREC_MULTI_SEG_INDEX_A	0x4A408
7579 #define _PAL_PREC_MULTI_SEG_INDEX_B	0x4AC08
7580 #define   PAL_PREC_MULTI_SEG_AUTO_INCREMENT	REG_BIT(15)
7581 #define   PAL_PREC_MULTI_SEG_INDEX_VALUE_MASK	REG_GENMASK(4, 0)
7582 #define   PAL_PREC_MULTI_SEG_INDEX_VALUE(x)	REG_FIELD_PREP(PAL_PREC_MULTI_SEG_INDEX_VALUE_MASK, (x))
7583 
7584 #define _PAL_PREC_MULTI_SEG_DATA_A	0x4A40C
7585 #define _PAL_PREC_MULTI_SEG_DATA_B	0x4AC0C
7586 /* see PREC_PALETTE_12P4_* for the bits */
7587 
7588 #define PREC_PAL_MULTI_SEG_INDEX(pipe)	_MMIO_PIPE(pipe, \
7589 					_PAL_PREC_MULTI_SEG_INDEX_A, \
7590 					_PAL_PREC_MULTI_SEG_INDEX_B)
7591 #define PREC_PAL_MULTI_SEG_DATA(pipe)	_MMIO_PIPE(pipe, \
7592 					_PAL_PREC_MULTI_SEG_DATA_A, \
7593 					_PAL_PREC_MULTI_SEG_DATA_B)
7594 
7595 #define _MMIO_PLANE_GAMC(plane, i, a, b)  _MMIO(_PIPE(plane, a, b) + (i) * 4)
7596 
7597 /* Plane CSC Registers */
7598 #define _PLANE_CSC_RY_GY_1_A	0x70210
7599 #define _PLANE_CSC_RY_GY_2_A	0x70310
7600 
7601 #define _PLANE_CSC_RY_GY_1_B	0x71210
7602 #define _PLANE_CSC_RY_GY_2_B	0x71310
7603 
7604 #define _PLANE_CSC_RY_GY_1(pipe)	_PIPE(pipe, _PLANE_CSC_RY_GY_1_A, \
7605 					      _PLANE_CSC_RY_GY_1_B)
7606 #define _PLANE_CSC_RY_GY_2(pipe)	_PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_2_A, \
7607 					      _PLANE_INPUT_CSC_RY_GY_2_B)
7608 #define PLANE_CSC_COEFF(pipe, plane, index)	_MMIO_PLANE(plane, \
7609 							    _PLANE_CSC_RY_GY_1(pipe) +  (index) * 4, \
7610 							    _PLANE_CSC_RY_GY_2(pipe) + (index) * 4)
7611 
7612 #define _PLANE_CSC_PREOFF_HI_1_A		0x70228
7613 #define _PLANE_CSC_PREOFF_HI_2_A		0x70328
7614 
7615 #define _PLANE_CSC_PREOFF_HI_1_B		0x71228
7616 #define _PLANE_CSC_PREOFF_HI_2_B		0x71328
7617 
7618 #define _PLANE_CSC_PREOFF_HI_1(pipe)	_PIPE(pipe, _PLANE_CSC_PREOFF_HI_1_A, \
7619 					      _PLANE_CSC_PREOFF_HI_1_B)
7620 #define _PLANE_CSC_PREOFF_HI_2(pipe)	_PIPE(pipe, _PLANE_CSC_PREOFF_HI_2_A, \
7621 					      _PLANE_CSC_PREOFF_HI_2_B)
7622 #define PLANE_CSC_PREOFF(pipe, plane, index)	_MMIO_PLANE(plane, _PLANE_CSC_PREOFF_HI_1(pipe) + \
7623 							    (index) * 4, _PLANE_CSC_PREOFF_HI_2(pipe) + \
7624 							    (index) * 4)
7625 
7626 #define _PLANE_CSC_POSTOFF_HI_1_A		0x70234
7627 #define _PLANE_CSC_POSTOFF_HI_2_A		0x70334
7628 
7629 #define _PLANE_CSC_POSTOFF_HI_1_B		0x71234
7630 #define _PLANE_CSC_POSTOFF_HI_2_B		0x71334
7631 
7632 #define _PLANE_CSC_POSTOFF_HI_1(pipe)	_PIPE(pipe, _PLANE_CSC_POSTOFF_HI_1_A, \
7633 					      _PLANE_CSC_POSTOFF_HI_1_B)
7634 #define _PLANE_CSC_POSTOFF_HI_2(pipe)	_PIPE(pipe, _PLANE_CSC_POSTOFF_HI_2_A, \
7635 					      _PLANE_CSC_POSTOFF_HI_2_B)
7636 #define PLANE_CSC_POSTOFF(pipe, plane, index)	_MMIO_PLANE(plane, _PLANE_CSC_POSTOFF_HI_1(pipe) + \
7637 							    (index) * 4, _PLANE_CSC_POSTOFF_HI_2(pipe) + \
7638 							    (index) * 4)
7639 
7640 /* pipe CSC & degamma/gamma LUTs on CHV */
7641 #define _CGM_PIPE_A_CSC_COEFF01	(VLV_DISPLAY_BASE + 0x67900)
7642 #define _CGM_PIPE_A_CSC_COEFF23	(VLV_DISPLAY_BASE + 0x67904)
7643 #define _CGM_PIPE_A_CSC_COEFF45	(VLV_DISPLAY_BASE + 0x67908)
7644 #define _CGM_PIPE_A_CSC_COEFF67	(VLV_DISPLAY_BASE + 0x6790C)
7645 #define _CGM_PIPE_A_CSC_COEFF8	(VLV_DISPLAY_BASE + 0x67910)
7646 #define _CGM_PIPE_A_DEGAMMA	(VLV_DISPLAY_BASE + 0x66000)
7647 /* cgm degamma ldw */
7648 #define   CGM_PIPE_DEGAMMA_GREEN_LDW_MASK	REG_GENMASK(29, 16)
7649 #define   CGM_PIPE_DEGAMMA_BLUE_LDW_MASK	REG_GENMASK(13, 0)
7650 /* cgm degamma udw */
7651 #define   CGM_PIPE_DEGAMMA_RED_UDW_MASK		REG_GENMASK(13, 0)
7652 #define _CGM_PIPE_A_GAMMA	(VLV_DISPLAY_BASE + 0x67000)
7653 /* cgm gamma ldw */
7654 #define   CGM_PIPE_GAMMA_GREEN_LDW_MASK		REG_GENMASK(25, 16)
7655 #define   CGM_PIPE_GAMMA_BLUE_LDW_MASK		REG_GENMASK(9, 0)
7656 /* cgm gamma udw */
7657 #define   CGM_PIPE_GAMMA_RED_UDW_MASK		REG_GENMASK(9, 0)
7658 #define _CGM_PIPE_A_MODE	(VLV_DISPLAY_BASE + 0x67A00)
7659 #define   CGM_PIPE_MODE_GAMMA	(1 << 2)
7660 #define   CGM_PIPE_MODE_CSC	(1 << 1)
7661 #define   CGM_PIPE_MODE_DEGAMMA	(1 << 0)
7662 
7663 #define _CGM_PIPE_B_CSC_COEFF01	(VLV_DISPLAY_BASE + 0x69900)
7664 #define _CGM_PIPE_B_CSC_COEFF23	(VLV_DISPLAY_BASE + 0x69904)
7665 #define _CGM_PIPE_B_CSC_COEFF45	(VLV_DISPLAY_BASE + 0x69908)
7666 #define _CGM_PIPE_B_CSC_COEFF67	(VLV_DISPLAY_BASE + 0x6990C)
7667 #define _CGM_PIPE_B_CSC_COEFF8	(VLV_DISPLAY_BASE + 0x69910)
7668 #define _CGM_PIPE_B_DEGAMMA	(VLV_DISPLAY_BASE + 0x68000)
7669 #define _CGM_PIPE_B_GAMMA	(VLV_DISPLAY_BASE + 0x69000)
7670 #define _CGM_PIPE_B_MODE	(VLV_DISPLAY_BASE + 0x69A00)
7671 
7672 #define CGM_PIPE_CSC_COEFF01(pipe)	_MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF01, _CGM_PIPE_B_CSC_COEFF01)
7673 #define CGM_PIPE_CSC_COEFF23(pipe)	_MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF23, _CGM_PIPE_B_CSC_COEFF23)
7674 #define CGM_PIPE_CSC_COEFF45(pipe)	_MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF45, _CGM_PIPE_B_CSC_COEFF45)
7675 #define CGM_PIPE_CSC_COEFF67(pipe)	_MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF67, _CGM_PIPE_B_CSC_COEFF67)
7676 #define CGM_PIPE_CSC_COEFF8(pipe)	_MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF8, _CGM_PIPE_B_CSC_COEFF8)
7677 #define CGM_PIPE_DEGAMMA(pipe, i, w)	_MMIO(_PIPE(pipe, _CGM_PIPE_A_DEGAMMA, _CGM_PIPE_B_DEGAMMA) + (i) * 8 + (w) * 4)
7678 #define CGM_PIPE_GAMMA(pipe, i, w)	_MMIO(_PIPE(pipe, _CGM_PIPE_A_GAMMA, _CGM_PIPE_B_GAMMA) + (i) * 8 + (w) * 4)
7679 #define CGM_PIPE_MODE(pipe)		_MMIO_PIPE(pipe, _CGM_PIPE_A_MODE, _CGM_PIPE_B_MODE)
7680 
7681 /* Gen4+ Timestamp and Pipe Frame time stamp registers */
7682 #define GEN4_TIMESTAMP		_MMIO(0x2358)
7683 #define ILK_TIMESTAMP_HI	_MMIO(0x70070)
7684 #define IVB_TIMESTAMP_CTR	_MMIO(0x44070)
7685 
7686 #define GEN9_TIMESTAMP_OVERRIDE				_MMIO(0x44074)
7687 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_SHIFT	0
7688 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK	0x3ff
7689 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_SHIFT	12
7690 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK	(0xf << 12)
7691 
7692 #define _PIPE_FRMTMSTMP_A		0x70048
7693 #define PIPE_FRMTMSTMP(pipe)		\
7694 			_MMIO_PIPE2(pipe, _PIPE_FRMTMSTMP_A)
7695 
7696 /* Display Stream Splitter Control */
7697 #define DSS_CTL1				_MMIO(0x67400)
7698 #define  SPLITTER_ENABLE			(1 << 31)
7699 #define  JOINER_ENABLE				(1 << 30)
7700 #define  DUAL_LINK_MODE_INTERLEAVE		(1 << 24)
7701 #define  DUAL_LINK_MODE_FRONTBACK		(0 << 24)
7702 #define  OVERLAP_PIXELS_MASK			(0xf << 16)
7703 #define  OVERLAP_PIXELS(pixels)			((pixels) << 16)
7704 #define  LEFT_DL_BUF_TARGET_DEPTH_MASK		(0xfff << 0)
7705 #define  LEFT_DL_BUF_TARGET_DEPTH(pixels)	((pixels) << 0)
7706 #define  MAX_DL_BUFFER_TARGET_DEPTH		0x5a0
7707 
7708 #define DSS_CTL2				_MMIO(0x67404)
7709 #define  LEFT_BRANCH_VDSC_ENABLE		(1 << 31)
7710 #define  RIGHT_BRANCH_VDSC_ENABLE		(1 << 15)
7711 #define  RIGHT_DL_BUF_TARGET_DEPTH_MASK		(0xfff << 0)
7712 #define  RIGHT_DL_BUF_TARGET_DEPTH(pixels)	((pixels) << 0)
7713 
7714 #define _ICL_PIPE_DSS_CTL1_PB			0x78200
7715 #define _ICL_PIPE_DSS_CTL1_PC			0x78400
7716 #define ICL_PIPE_DSS_CTL1(pipe)			_MMIO_PIPE((pipe) - PIPE_B, \
7717 							   _ICL_PIPE_DSS_CTL1_PB, \
7718 							   _ICL_PIPE_DSS_CTL1_PC)
7719 #define  BIG_JOINER_ENABLE			(1 << 29)
7720 #define  MASTER_BIG_JOINER_ENABLE		(1 << 28)
7721 #define  VGA_CENTERING_ENABLE			(1 << 27)
7722 #define  SPLITTER_CONFIGURATION_MASK		REG_GENMASK(26, 25)
7723 #define  SPLITTER_CONFIGURATION_2_SEGMENT	REG_FIELD_PREP(SPLITTER_CONFIGURATION_MASK, 0)
7724 #define  SPLITTER_CONFIGURATION_4_SEGMENT	REG_FIELD_PREP(SPLITTER_CONFIGURATION_MASK, 1)
7725 #define  UNCOMPRESSED_JOINER_MASTER		(1 << 21)
7726 #define  UNCOMPRESSED_JOINER_SLAVE		(1 << 20)
7727 
7728 #define _ICL_PIPE_DSS_CTL2_PB			0x78204
7729 #define _ICL_PIPE_DSS_CTL2_PC			0x78404
7730 #define ICL_PIPE_DSS_CTL2(pipe)			_MMIO_PIPE((pipe) - PIPE_B, \
7731 							   _ICL_PIPE_DSS_CTL2_PB, \
7732 							   _ICL_PIPE_DSS_CTL2_PC)
7733 
7734 #define GGC				_MMIO(0x108040)
7735 #define   GMS_MASK			REG_GENMASK(15, 8)
7736 #define   GGMS_MASK			REG_GENMASK(7, 6)
7737 
7738 #define GEN12_GSMBASE			_MMIO(0x108100)
7739 #define GEN12_DSMBASE			_MMIO(0x1080C0)
7740 #define   GEN12_BDSM_MASK		REG_GENMASK64(63, 20)
7741 
7742 #define XEHP_CLOCK_GATE_DIS		_MMIO(0x101014)
7743 #define   SGSI_SIDECLK_DIS		REG_BIT(17)
7744 #define   SGGI_DIS			REG_BIT(15)
7745 #define   SGR_DIS			REG_BIT(13)
7746 
7747 #define _ICL_PHY_MISC_A		0x64C00
7748 #define _ICL_PHY_MISC_B		0x64C04
7749 #define _DG2_PHY_MISC_TC1	0x64C14 /* TC1="PHY E" but offset as if "PHY F" */
7750 #define ICL_PHY_MISC(port)	_MMIO_PORT(port, _ICL_PHY_MISC_A, _ICL_PHY_MISC_B)
7751 #define DG2_PHY_MISC(port)	((port) == PHY_E ? _MMIO(_DG2_PHY_MISC_TC1) : \
7752 				 ICL_PHY_MISC(port))
7753 #define  ICL_PHY_MISC_MUX_DDID			(1 << 28)
7754 #define  ICL_PHY_MISC_DE_IO_COMP_PWR_DOWN	(1 << 23)
7755 #define  DG2_PHY_DP_TX_ACK_MASK			REG_GENMASK(23, 20)
7756 
7757 /* Icelake Display Stream Compression Registers */
7758 #define DSCA_PICTURE_PARAMETER_SET_0		_MMIO(0x6B200)
7759 #define DSCC_PICTURE_PARAMETER_SET_0		_MMIO(0x6BA00)
7760 #define _ICL_DSC0_PICTURE_PARAMETER_SET_0_PB	0x78270
7761 #define _ICL_DSC1_PICTURE_PARAMETER_SET_0_PB	0x78370
7762 #define _ICL_DSC0_PICTURE_PARAMETER_SET_0_PC	0x78470
7763 #define _ICL_DSC1_PICTURE_PARAMETER_SET_0_PC	0x78570
7764 #define ICL_DSC0_PICTURE_PARAMETER_SET_0(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7765 							   _ICL_DSC0_PICTURE_PARAMETER_SET_0_PB, \
7766 							   _ICL_DSC0_PICTURE_PARAMETER_SET_0_PC)
7767 #define ICL_DSC1_PICTURE_PARAMETER_SET_0(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7768 							   _ICL_DSC1_PICTURE_PARAMETER_SET_0_PB, \
7769 							   _ICL_DSC1_PICTURE_PARAMETER_SET_0_PC)
7770 #define  DSC_ALT_ICH_SEL		(1 << 20)
7771 #define  DSC_VBR_ENABLE			(1 << 19)
7772 #define  DSC_422_ENABLE			(1 << 18)
7773 #define  DSC_COLOR_SPACE_CONVERSION	(1 << 17)
7774 #define  DSC_BLOCK_PREDICTION		(1 << 16)
7775 #define  DSC_LINE_BUF_DEPTH_SHIFT	12
7776 #define  DSC_BPC_SHIFT			8
7777 #define  DSC_VER_MIN_SHIFT		4
7778 #define  DSC_VER_MAJ			(0x1 << 0)
7779 
7780 #define DSCA_PICTURE_PARAMETER_SET_1		_MMIO(0x6B204)
7781 #define DSCC_PICTURE_PARAMETER_SET_1		_MMIO(0x6BA04)
7782 #define _ICL_DSC0_PICTURE_PARAMETER_SET_1_PB	0x78274
7783 #define _ICL_DSC1_PICTURE_PARAMETER_SET_1_PB	0x78374
7784 #define _ICL_DSC0_PICTURE_PARAMETER_SET_1_PC	0x78474
7785 #define _ICL_DSC1_PICTURE_PARAMETER_SET_1_PC	0x78574
7786 #define ICL_DSC0_PICTURE_PARAMETER_SET_1(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7787 							   _ICL_DSC0_PICTURE_PARAMETER_SET_1_PB, \
7788 							   _ICL_DSC0_PICTURE_PARAMETER_SET_1_PC)
7789 #define ICL_DSC1_PICTURE_PARAMETER_SET_1(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7790 							   _ICL_DSC1_PICTURE_PARAMETER_SET_1_PB, \
7791 							   _ICL_DSC1_PICTURE_PARAMETER_SET_1_PC)
7792 #define  DSC_BPP(bpp)				((bpp) << 0)
7793 
7794 #define DSCA_PICTURE_PARAMETER_SET_2		_MMIO(0x6B208)
7795 #define DSCC_PICTURE_PARAMETER_SET_2		_MMIO(0x6BA08)
7796 #define _ICL_DSC0_PICTURE_PARAMETER_SET_2_PB	0x78278
7797 #define _ICL_DSC1_PICTURE_PARAMETER_SET_2_PB	0x78378
7798 #define _ICL_DSC0_PICTURE_PARAMETER_SET_2_PC	0x78478
7799 #define _ICL_DSC1_PICTURE_PARAMETER_SET_2_PC	0x78578
7800 #define ICL_DSC0_PICTURE_PARAMETER_SET_2(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7801 							   _ICL_DSC0_PICTURE_PARAMETER_SET_2_PB, \
7802 							   _ICL_DSC0_PICTURE_PARAMETER_SET_2_PC)
7803 #define ICL_DSC1_PICTURE_PARAMETER_SET_2(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7804 					    _ICL_DSC1_PICTURE_PARAMETER_SET_2_PB, \
7805 					    _ICL_DSC1_PICTURE_PARAMETER_SET_2_PC)
7806 #define  DSC_PIC_WIDTH(pic_width)	((pic_width) << 16)
7807 #define  DSC_PIC_HEIGHT(pic_height)	((pic_height) << 0)
7808 
7809 #define DSCA_PICTURE_PARAMETER_SET_3		_MMIO(0x6B20C)
7810 #define DSCC_PICTURE_PARAMETER_SET_3		_MMIO(0x6BA0C)
7811 #define _ICL_DSC0_PICTURE_PARAMETER_SET_3_PB	0x7827C
7812 #define _ICL_DSC1_PICTURE_PARAMETER_SET_3_PB	0x7837C
7813 #define _ICL_DSC0_PICTURE_PARAMETER_SET_3_PC	0x7847C
7814 #define _ICL_DSC1_PICTURE_PARAMETER_SET_3_PC	0x7857C
7815 #define ICL_DSC0_PICTURE_PARAMETER_SET_3(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7816 							   _ICL_DSC0_PICTURE_PARAMETER_SET_3_PB, \
7817 							   _ICL_DSC0_PICTURE_PARAMETER_SET_3_PC)
7818 #define ICL_DSC1_PICTURE_PARAMETER_SET_3(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7819 							   _ICL_DSC1_PICTURE_PARAMETER_SET_3_PB, \
7820 							   _ICL_DSC1_PICTURE_PARAMETER_SET_3_PC)
7821 #define  DSC_SLICE_WIDTH(slice_width)   ((slice_width) << 16)
7822 #define  DSC_SLICE_HEIGHT(slice_height) ((slice_height) << 0)
7823 
7824 #define DSCA_PICTURE_PARAMETER_SET_4		_MMIO(0x6B210)
7825 #define DSCC_PICTURE_PARAMETER_SET_4		_MMIO(0x6BA10)
7826 #define _ICL_DSC0_PICTURE_PARAMETER_SET_4_PB	0x78280
7827 #define _ICL_DSC1_PICTURE_PARAMETER_SET_4_PB	0x78380
7828 #define _ICL_DSC0_PICTURE_PARAMETER_SET_4_PC	0x78480
7829 #define _ICL_DSC1_PICTURE_PARAMETER_SET_4_PC	0x78580
7830 #define ICL_DSC0_PICTURE_PARAMETER_SET_4(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7831 							   _ICL_DSC0_PICTURE_PARAMETER_SET_4_PB, \
7832 							   _ICL_DSC0_PICTURE_PARAMETER_SET_4_PC)
7833 #define ICL_DSC1_PICTURE_PARAMETER_SET_4(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7834 							   _ICL_DSC1_PICTURE_PARAMETER_SET_4_PB, \
7835 							   _ICL_DSC1_PICTURE_PARAMETER_SET_4_PC)
7836 #define  DSC_INITIAL_DEC_DELAY(dec_delay)       ((dec_delay) << 16)
7837 #define  DSC_INITIAL_XMIT_DELAY(xmit_delay)     ((xmit_delay) << 0)
7838 
7839 #define DSCA_PICTURE_PARAMETER_SET_5		_MMIO(0x6B214)
7840 #define DSCC_PICTURE_PARAMETER_SET_5		_MMIO(0x6BA14)
7841 #define _ICL_DSC0_PICTURE_PARAMETER_SET_5_PB	0x78284
7842 #define _ICL_DSC1_PICTURE_PARAMETER_SET_5_PB	0x78384
7843 #define _ICL_DSC0_PICTURE_PARAMETER_SET_5_PC	0x78484
7844 #define _ICL_DSC1_PICTURE_PARAMETER_SET_5_PC	0x78584
7845 #define ICL_DSC0_PICTURE_PARAMETER_SET_5(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7846 							   _ICL_DSC0_PICTURE_PARAMETER_SET_5_PB, \
7847 							   _ICL_DSC0_PICTURE_PARAMETER_SET_5_PC)
7848 #define ICL_DSC1_PICTURE_PARAMETER_SET_5(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7849 							   _ICL_DSC1_PICTURE_PARAMETER_SET_5_PB, \
7850 							   _ICL_DSC1_PICTURE_PARAMETER_SET_5_PC)
7851 #define  DSC_SCALE_DEC_INT(scale_dec)	((scale_dec) << 16)
7852 #define  DSC_SCALE_INC_INT(scale_inc)		((scale_inc) << 0)
7853 
7854 #define DSCA_PICTURE_PARAMETER_SET_6		_MMIO(0x6B218)
7855 #define DSCC_PICTURE_PARAMETER_SET_6		_MMIO(0x6BA18)
7856 #define _ICL_DSC0_PICTURE_PARAMETER_SET_6_PB	0x78288
7857 #define _ICL_DSC1_PICTURE_PARAMETER_SET_6_PB	0x78388
7858 #define _ICL_DSC0_PICTURE_PARAMETER_SET_6_PC	0x78488
7859 #define _ICL_DSC1_PICTURE_PARAMETER_SET_6_PC	0x78588
7860 #define ICL_DSC0_PICTURE_PARAMETER_SET_6(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7861 							   _ICL_DSC0_PICTURE_PARAMETER_SET_6_PB, \
7862 							   _ICL_DSC0_PICTURE_PARAMETER_SET_6_PC)
7863 #define ICL_DSC1_PICTURE_PARAMETER_SET_6(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7864 							   _ICL_DSC1_PICTURE_PARAMETER_SET_6_PB, \
7865 							   _ICL_DSC1_PICTURE_PARAMETER_SET_6_PC)
7866 #define  DSC_FLATNESS_MAX_QP(max_qp)		((max_qp) << 24)
7867 #define  DSC_FLATNESS_MIN_QP(min_qp)		((min_qp) << 16)
7868 #define  DSC_FIRST_LINE_BPG_OFFSET(offset)	((offset) << 8)
7869 #define  DSC_INITIAL_SCALE_VALUE(value)		((value) << 0)
7870 
7871 #define DSCA_PICTURE_PARAMETER_SET_7		_MMIO(0x6B21C)
7872 #define DSCC_PICTURE_PARAMETER_SET_7		_MMIO(0x6BA1C)
7873 #define _ICL_DSC0_PICTURE_PARAMETER_SET_7_PB	0x7828C
7874 #define _ICL_DSC1_PICTURE_PARAMETER_SET_7_PB	0x7838C
7875 #define _ICL_DSC0_PICTURE_PARAMETER_SET_7_PC	0x7848C
7876 #define _ICL_DSC1_PICTURE_PARAMETER_SET_7_PC	0x7858C
7877 #define ICL_DSC0_PICTURE_PARAMETER_SET_7(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7878 							    _ICL_DSC0_PICTURE_PARAMETER_SET_7_PB, \
7879 							    _ICL_DSC0_PICTURE_PARAMETER_SET_7_PC)
7880 #define ICL_DSC1_PICTURE_PARAMETER_SET_7(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7881 							    _ICL_DSC1_PICTURE_PARAMETER_SET_7_PB, \
7882 							    _ICL_DSC1_PICTURE_PARAMETER_SET_7_PC)
7883 #define  DSC_NFL_BPG_OFFSET(bpg_offset)		((bpg_offset) << 16)
7884 #define  DSC_SLICE_BPG_OFFSET(bpg_offset)	((bpg_offset) << 0)
7885 
7886 #define DSCA_PICTURE_PARAMETER_SET_8		_MMIO(0x6B220)
7887 #define DSCC_PICTURE_PARAMETER_SET_8		_MMIO(0x6BA20)
7888 #define _ICL_DSC0_PICTURE_PARAMETER_SET_8_PB	0x78290
7889 #define _ICL_DSC1_PICTURE_PARAMETER_SET_8_PB	0x78390
7890 #define _ICL_DSC0_PICTURE_PARAMETER_SET_8_PC	0x78490
7891 #define _ICL_DSC1_PICTURE_PARAMETER_SET_8_PC	0x78590
7892 #define ICL_DSC0_PICTURE_PARAMETER_SET_8(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7893 							   _ICL_DSC0_PICTURE_PARAMETER_SET_8_PB, \
7894 							   _ICL_DSC0_PICTURE_PARAMETER_SET_8_PC)
7895 #define ICL_DSC1_PICTURE_PARAMETER_SET_8(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7896 							   _ICL_DSC1_PICTURE_PARAMETER_SET_8_PB, \
7897 							   _ICL_DSC1_PICTURE_PARAMETER_SET_8_PC)
7898 #define  DSC_INITIAL_OFFSET(initial_offset)		((initial_offset) << 16)
7899 #define  DSC_FINAL_OFFSET(final_offset)			((final_offset) << 0)
7900 
7901 #define DSCA_PICTURE_PARAMETER_SET_9		_MMIO(0x6B224)
7902 #define DSCC_PICTURE_PARAMETER_SET_9		_MMIO(0x6BA24)
7903 #define _ICL_DSC0_PICTURE_PARAMETER_SET_9_PB	0x78294
7904 #define _ICL_DSC1_PICTURE_PARAMETER_SET_9_PB	0x78394
7905 #define _ICL_DSC0_PICTURE_PARAMETER_SET_9_PC	0x78494
7906 #define _ICL_DSC1_PICTURE_PARAMETER_SET_9_PC	0x78594
7907 #define ICL_DSC0_PICTURE_PARAMETER_SET_9(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7908 							   _ICL_DSC0_PICTURE_PARAMETER_SET_9_PB, \
7909 							   _ICL_DSC0_PICTURE_PARAMETER_SET_9_PC)
7910 #define ICL_DSC1_PICTURE_PARAMETER_SET_9(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7911 							   _ICL_DSC1_PICTURE_PARAMETER_SET_9_PB, \
7912 							   _ICL_DSC1_PICTURE_PARAMETER_SET_9_PC)
7913 #define  DSC_RC_EDGE_FACTOR(rc_edge_fact)	((rc_edge_fact) << 16)
7914 #define  DSC_RC_MODEL_SIZE(rc_model_size)	((rc_model_size) << 0)
7915 
7916 #define DSCA_PICTURE_PARAMETER_SET_10		_MMIO(0x6B228)
7917 #define DSCC_PICTURE_PARAMETER_SET_10		_MMIO(0x6BA28)
7918 #define _ICL_DSC0_PICTURE_PARAMETER_SET_10_PB	0x78298
7919 #define _ICL_DSC1_PICTURE_PARAMETER_SET_10_PB	0x78398
7920 #define _ICL_DSC0_PICTURE_PARAMETER_SET_10_PC	0x78498
7921 #define _ICL_DSC1_PICTURE_PARAMETER_SET_10_PC	0x78598
7922 #define ICL_DSC0_PICTURE_PARAMETER_SET_10(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7923 							   _ICL_DSC0_PICTURE_PARAMETER_SET_10_PB, \
7924 							   _ICL_DSC0_PICTURE_PARAMETER_SET_10_PC)
7925 #define ICL_DSC1_PICTURE_PARAMETER_SET_10(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7926 							   _ICL_DSC1_PICTURE_PARAMETER_SET_10_PB, \
7927 							   _ICL_DSC1_PICTURE_PARAMETER_SET_10_PC)
7928 #define  DSC_RC_TARGET_OFF_LOW(rc_tgt_off_low)		((rc_tgt_off_low) << 20)
7929 #define  DSC_RC_TARGET_OFF_HIGH(rc_tgt_off_high)	((rc_tgt_off_high) << 16)
7930 #define  DSC_RC_QUANT_INC_LIMIT1(lim)			((lim) << 8)
7931 #define  DSC_RC_QUANT_INC_LIMIT0(lim)			((lim) << 0)
7932 
7933 #define DSCA_PICTURE_PARAMETER_SET_11		_MMIO(0x6B22C)
7934 #define DSCC_PICTURE_PARAMETER_SET_11		_MMIO(0x6BA2C)
7935 #define _ICL_DSC0_PICTURE_PARAMETER_SET_11_PB	0x7829C
7936 #define _ICL_DSC1_PICTURE_PARAMETER_SET_11_PB	0x7839C
7937 #define _ICL_DSC0_PICTURE_PARAMETER_SET_11_PC	0x7849C
7938 #define _ICL_DSC1_PICTURE_PARAMETER_SET_11_PC	0x7859C
7939 #define ICL_DSC0_PICTURE_PARAMETER_SET_11(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7940 							   _ICL_DSC0_PICTURE_PARAMETER_SET_11_PB, \
7941 							   _ICL_DSC0_PICTURE_PARAMETER_SET_11_PC)
7942 #define ICL_DSC1_PICTURE_PARAMETER_SET_11(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7943 							   _ICL_DSC1_PICTURE_PARAMETER_SET_11_PB, \
7944 							   _ICL_DSC1_PICTURE_PARAMETER_SET_11_PC)
7945 
7946 #define DSCA_PICTURE_PARAMETER_SET_12		_MMIO(0x6B260)
7947 #define DSCC_PICTURE_PARAMETER_SET_12		_MMIO(0x6BA60)
7948 #define _ICL_DSC0_PICTURE_PARAMETER_SET_12_PB	0x782A0
7949 #define _ICL_DSC1_PICTURE_PARAMETER_SET_12_PB	0x783A0
7950 #define _ICL_DSC0_PICTURE_PARAMETER_SET_12_PC	0x784A0
7951 #define _ICL_DSC1_PICTURE_PARAMETER_SET_12_PC	0x785A0
7952 #define ICL_DSC0_PICTURE_PARAMETER_SET_12(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7953 							   _ICL_DSC0_PICTURE_PARAMETER_SET_12_PB, \
7954 							   _ICL_DSC0_PICTURE_PARAMETER_SET_12_PC)
7955 #define ICL_DSC1_PICTURE_PARAMETER_SET_12(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7956 							   _ICL_DSC1_PICTURE_PARAMETER_SET_12_PB, \
7957 							   _ICL_DSC1_PICTURE_PARAMETER_SET_12_PC)
7958 
7959 #define DSCA_PICTURE_PARAMETER_SET_13		_MMIO(0x6B264)
7960 #define DSCC_PICTURE_PARAMETER_SET_13		_MMIO(0x6BA64)
7961 #define _ICL_DSC0_PICTURE_PARAMETER_SET_13_PB	0x782A4
7962 #define _ICL_DSC1_PICTURE_PARAMETER_SET_13_PB	0x783A4
7963 #define _ICL_DSC0_PICTURE_PARAMETER_SET_13_PC	0x784A4
7964 #define _ICL_DSC1_PICTURE_PARAMETER_SET_13_PC	0x785A4
7965 #define ICL_DSC0_PICTURE_PARAMETER_SET_13(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7966 							   _ICL_DSC0_PICTURE_PARAMETER_SET_13_PB, \
7967 							   _ICL_DSC0_PICTURE_PARAMETER_SET_13_PC)
7968 #define ICL_DSC1_PICTURE_PARAMETER_SET_13(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7969 							   _ICL_DSC1_PICTURE_PARAMETER_SET_13_PB, \
7970 							   _ICL_DSC1_PICTURE_PARAMETER_SET_13_PC)
7971 
7972 #define DSCA_PICTURE_PARAMETER_SET_14		_MMIO(0x6B268)
7973 #define DSCC_PICTURE_PARAMETER_SET_14		_MMIO(0x6BA68)
7974 #define _ICL_DSC0_PICTURE_PARAMETER_SET_14_PB	0x782A8
7975 #define _ICL_DSC1_PICTURE_PARAMETER_SET_14_PB	0x783A8
7976 #define _ICL_DSC0_PICTURE_PARAMETER_SET_14_PC	0x784A8
7977 #define _ICL_DSC1_PICTURE_PARAMETER_SET_14_PC	0x785A8
7978 #define ICL_DSC0_PICTURE_PARAMETER_SET_14(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7979 							   _ICL_DSC0_PICTURE_PARAMETER_SET_14_PB, \
7980 							   _ICL_DSC0_PICTURE_PARAMETER_SET_14_PC)
7981 #define ICL_DSC1_PICTURE_PARAMETER_SET_14(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7982 							   _ICL_DSC1_PICTURE_PARAMETER_SET_14_PB, \
7983 							   _ICL_DSC1_PICTURE_PARAMETER_SET_14_PC)
7984 
7985 #define DSCA_PICTURE_PARAMETER_SET_15		_MMIO(0x6B26C)
7986 #define DSCC_PICTURE_PARAMETER_SET_15		_MMIO(0x6BA6C)
7987 #define _ICL_DSC0_PICTURE_PARAMETER_SET_15_PB	0x782AC
7988 #define _ICL_DSC1_PICTURE_PARAMETER_SET_15_PB	0x783AC
7989 #define _ICL_DSC0_PICTURE_PARAMETER_SET_15_PC	0x784AC
7990 #define _ICL_DSC1_PICTURE_PARAMETER_SET_15_PC	0x785AC
7991 #define ICL_DSC0_PICTURE_PARAMETER_SET_15(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7992 							   _ICL_DSC0_PICTURE_PARAMETER_SET_15_PB, \
7993 							   _ICL_DSC0_PICTURE_PARAMETER_SET_15_PC)
7994 #define ICL_DSC1_PICTURE_PARAMETER_SET_15(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
7995 							   _ICL_DSC1_PICTURE_PARAMETER_SET_15_PB, \
7996 							   _ICL_DSC1_PICTURE_PARAMETER_SET_15_PC)
7997 
7998 #define DSCA_PICTURE_PARAMETER_SET_16		_MMIO(0x6B270)
7999 #define DSCC_PICTURE_PARAMETER_SET_16		_MMIO(0x6BA70)
8000 #define _ICL_DSC0_PICTURE_PARAMETER_SET_16_PB	0x782B0
8001 #define _ICL_DSC1_PICTURE_PARAMETER_SET_16_PB	0x783B0
8002 #define _ICL_DSC0_PICTURE_PARAMETER_SET_16_PC	0x784B0
8003 #define _ICL_DSC1_PICTURE_PARAMETER_SET_16_PC	0x785B0
8004 #define ICL_DSC0_PICTURE_PARAMETER_SET_16(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8005 							   _ICL_DSC0_PICTURE_PARAMETER_SET_16_PB, \
8006 							   _ICL_DSC0_PICTURE_PARAMETER_SET_16_PC)
8007 #define ICL_DSC1_PICTURE_PARAMETER_SET_16(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8008 							   _ICL_DSC1_PICTURE_PARAMETER_SET_16_PB, \
8009 							   _ICL_DSC1_PICTURE_PARAMETER_SET_16_PC)
8010 #define  DSC_SLICE_ROW_PER_FRAME(slice_row_per_frame)	((slice_row_per_frame) << 20)
8011 #define  DSC_SLICE_PER_LINE(slice_per_line)		((slice_per_line) << 16)
8012 #define  DSC_SLICE_CHUNK_SIZE(slice_chunk_size)		((slice_chunk_size) << 0)
8013 
8014 /* Icelake Rate Control Buffer Threshold Registers */
8015 #define DSCA_RC_BUF_THRESH_0			_MMIO(0x6B230)
8016 #define DSCA_RC_BUF_THRESH_0_UDW		_MMIO(0x6B230 + 4)
8017 #define DSCC_RC_BUF_THRESH_0			_MMIO(0x6BA30)
8018 #define DSCC_RC_BUF_THRESH_0_UDW		_MMIO(0x6BA30 + 4)
8019 #define _ICL_DSC0_RC_BUF_THRESH_0_PB		(0x78254)
8020 #define _ICL_DSC0_RC_BUF_THRESH_0_UDW_PB	(0x78254 + 4)
8021 #define _ICL_DSC1_RC_BUF_THRESH_0_PB		(0x78354)
8022 #define _ICL_DSC1_RC_BUF_THRESH_0_UDW_PB	(0x78354 + 4)
8023 #define _ICL_DSC0_RC_BUF_THRESH_0_PC		(0x78454)
8024 #define _ICL_DSC0_RC_BUF_THRESH_0_UDW_PC	(0x78454 + 4)
8025 #define _ICL_DSC1_RC_BUF_THRESH_0_PC		(0x78554)
8026 #define _ICL_DSC1_RC_BUF_THRESH_0_UDW_PC	(0x78554 + 4)
8027 #define ICL_DSC0_RC_BUF_THRESH_0(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
8028 						_ICL_DSC0_RC_BUF_THRESH_0_PB, \
8029 						_ICL_DSC0_RC_BUF_THRESH_0_PC)
8030 #define ICL_DSC0_RC_BUF_THRESH_0_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8031 						_ICL_DSC0_RC_BUF_THRESH_0_UDW_PB, \
8032 						_ICL_DSC0_RC_BUF_THRESH_0_UDW_PC)
8033 #define ICL_DSC1_RC_BUF_THRESH_0(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
8034 						_ICL_DSC1_RC_BUF_THRESH_0_PB, \
8035 						_ICL_DSC1_RC_BUF_THRESH_0_PC)
8036 #define ICL_DSC1_RC_BUF_THRESH_0_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8037 						_ICL_DSC1_RC_BUF_THRESH_0_UDW_PB, \
8038 						_ICL_DSC1_RC_BUF_THRESH_0_UDW_PC)
8039 
8040 #define DSCA_RC_BUF_THRESH_1			_MMIO(0x6B238)
8041 #define DSCA_RC_BUF_THRESH_1_UDW		_MMIO(0x6B238 + 4)
8042 #define DSCC_RC_BUF_THRESH_1			_MMIO(0x6BA38)
8043 #define DSCC_RC_BUF_THRESH_1_UDW		_MMIO(0x6BA38 + 4)
8044 #define _ICL_DSC0_RC_BUF_THRESH_1_PB		(0x7825C)
8045 #define _ICL_DSC0_RC_BUF_THRESH_1_UDW_PB	(0x7825C + 4)
8046 #define _ICL_DSC1_RC_BUF_THRESH_1_PB		(0x7835C)
8047 #define _ICL_DSC1_RC_BUF_THRESH_1_UDW_PB	(0x7835C + 4)
8048 #define _ICL_DSC0_RC_BUF_THRESH_1_PC		(0x7845C)
8049 #define _ICL_DSC0_RC_BUF_THRESH_1_UDW_PC	(0x7845C + 4)
8050 #define _ICL_DSC1_RC_BUF_THRESH_1_PC		(0x7855C)
8051 #define _ICL_DSC1_RC_BUF_THRESH_1_UDW_PC	(0x7855C + 4)
8052 #define ICL_DSC0_RC_BUF_THRESH_1(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
8053 						_ICL_DSC0_RC_BUF_THRESH_1_PB, \
8054 						_ICL_DSC0_RC_BUF_THRESH_1_PC)
8055 #define ICL_DSC0_RC_BUF_THRESH_1_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8056 						_ICL_DSC0_RC_BUF_THRESH_1_UDW_PB, \
8057 						_ICL_DSC0_RC_BUF_THRESH_1_UDW_PC)
8058 #define ICL_DSC1_RC_BUF_THRESH_1(pipe)		_MMIO_PIPE((pipe) - PIPE_B, \
8059 						_ICL_DSC1_RC_BUF_THRESH_1_PB, \
8060 						_ICL_DSC1_RC_BUF_THRESH_1_PC)
8061 #define ICL_DSC1_RC_BUF_THRESH_1_UDW(pipe)	_MMIO_PIPE((pipe) - PIPE_B, \
8062 						_ICL_DSC1_RC_BUF_THRESH_1_UDW_PB, \
8063 						_ICL_DSC1_RC_BUF_THRESH_1_UDW_PC)
8064 
8065 #define PORT_TX_DFLEXDPSP(fia)			_MMIO_FIA((fia), 0x008A0)
8066 #define   MODULAR_FIA_MASK			(1 << 4)
8067 #define   TC_LIVE_STATE_TBT(idx)		(1 << ((idx) * 8 + 6))
8068 #define   TC_LIVE_STATE_TC(idx)			(1 << ((idx) * 8 + 5))
8069 #define   DP_LANE_ASSIGNMENT_SHIFT(idx)		((idx) * 8)
8070 #define   DP_LANE_ASSIGNMENT_MASK(idx)		(0xf << ((idx) * 8))
8071 #define   DP_LANE_ASSIGNMENT(idx, x)		((x) << ((idx) * 8))
8072 
8073 #define PORT_TX_DFLEXDPPMS(fia)			_MMIO_FIA((fia), 0x00890)
8074 #define   DP_PHY_MODE_STATUS_COMPLETED(idx)	(1 << (idx))
8075 
8076 #define PORT_TX_DFLEXDPCSSS(fia)		_MMIO_FIA((fia), 0x00894)
8077 #define   DP_PHY_MODE_STATUS_NOT_SAFE(idx)	(1 << (idx))
8078 
8079 #define PORT_TX_DFLEXPA1(fia)			_MMIO_FIA((fia), 0x00880)
8080 #define   DP_PIN_ASSIGNMENT_SHIFT(idx)		((idx) * 4)
8081 #define   DP_PIN_ASSIGNMENT_MASK(idx)		(0xf << ((idx) * 4))
8082 #define   DP_PIN_ASSIGNMENT(idx, x)		((x) << ((idx) * 4))
8083 
8084 #define _TCSS_DDI_STATUS_1			0x161500
8085 #define _TCSS_DDI_STATUS_2			0x161504
8086 #define TCSS_DDI_STATUS(tc)			_MMIO(_PICK_EVEN(tc, \
8087 								 _TCSS_DDI_STATUS_1, \
8088 								 _TCSS_DDI_STATUS_2))
8089 #define  TCSS_DDI_STATUS_READY			REG_BIT(2)
8090 #define  TCSS_DDI_STATUS_HPD_LIVE_STATUS_TBT	REG_BIT(1)
8091 #define  TCSS_DDI_STATUS_HPD_LIVE_STATUS_ALT	REG_BIT(0)
8092 
8093 #define PRIMARY_SPI_TRIGGER			_MMIO(0x102040)
8094 #define PRIMARY_SPI_ADDRESS			_MMIO(0x102080)
8095 #define PRIMARY_SPI_REGIONID			_MMIO(0x102084)
8096 #define SPI_STATIC_REGIONS			_MMIO(0x102090)
8097 #define   OPTIONROM_SPI_REGIONID_MASK		REG_GENMASK(7, 0)
8098 #define OROM_OFFSET				_MMIO(0x1020c0)
8099 #define   OROM_OFFSET_MASK			REG_GENMASK(20, 16)
8100 
8101 /* This register controls the Display State Buffer (DSB) engines. */
8102 #define _DSBSL_INSTANCE_BASE		0x70B00
8103 #define DSBSL_INSTANCE(pipe, id)	(_DSBSL_INSTANCE_BASE + \
8104 					 (pipe) * 0x1000 + (id) * 0x100)
8105 #define DSB_HEAD(pipe, id)		_MMIO(DSBSL_INSTANCE(pipe, id) + 0x0)
8106 #define DSB_TAIL(pipe, id)		_MMIO(DSBSL_INSTANCE(pipe, id) + 0x4)
8107 #define DSB_CTRL(pipe, id)		_MMIO(DSBSL_INSTANCE(pipe, id) + 0x8)
8108 #define   DSB_ENABLE			(1 << 31)
8109 #define   DSB_STATUS_BUSY		(1 << 0)
8110 
8111 #define CLKREQ_POLICY			_MMIO(0x101038)
8112 #define  CLKREQ_POLICY_MEM_UP_OVRD	REG_BIT(1)
8113 
8114 #define CLKGATE_DIS_MISC			_MMIO(0x46534)
8115 #define  CLKGATE_DIS_MISC_DMASC_GATING_DIS	REG_BIT(21)
8116 
8117 #define _MTL_CLKGATE_DIS_TRANS_A			0x604E8
8118 #define _MTL_CLKGATE_DIS_TRANS_B			0x614E8
8119 #define MTL_CLKGATE_DIS_TRANS(trans)			_MMIO_TRANS2(trans, _MTL_CLKGATE_DIS_TRANS_A)
8120 #define  MTL_CLKGATE_DIS_TRANS_DMASC_GATING_DIS		REG_BIT(7)
8121 
8122 #define MTL_LATENCY_LP0_LP1		_MMIO(0x45780)
8123 #define MTL_LATENCY_LP2_LP3		_MMIO(0x45784)
8124 #define MTL_LATENCY_LP4_LP5		_MMIO(0x45788)
8125 #define  MTL_LATENCY_LEVEL_EVEN_MASK	REG_GENMASK(12, 0)
8126 #define  MTL_LATENCY_LEVEL_ODD_MASK	REG_GENMASK(28, 16)
8127 
8128 #define MTL_LATENCY_SAGV		_MMIO(0x4578b)
8129 #define   MTL_LATENCY_QCLK_SAGV		REG_GENMASK(12, 0)
8130 
8131 #define MTL_MEM_SS_INFO_GLOBAL			_MMIO(0x45700)
8132 #define   MTL_N_OF_ENABLED_QGV_POINTS_MASK	REG_GENMASK(11, 8)
8133 #define   MTL_N_OF_POPULATED_CH_MASK		REG_GENMASK(7, 4)
8134 #define   MTL_DDR_TYPE_MASK			REG_GENMASK(3, 0)
8135 
8136 #define MTL_MEM_SS_INFO_QGV_POINT_LOW(point)	 _MMIO(0x45710 + (point) * 2)
8137 #define   MTL_TRCD_MASK			REG_GENMASK(31, 24)
8138 #define   MTL_TRP_MASK			REG_GENMASK(23, 16)
8139 #define   MTL_DCLK_MASK			REG_GENMASK(15, 0)
8140 
8141 #define MTL_MEM_SS_INFO_QGV_POINT_HIGH(point)	 _MMIO(0x45714 + (point) * 2)
8142 #define   MTL_TRAS_MASK			REG_GENMASK(16, 8)
8143 #define   MTL_TRDPRE_MASK		REG_GENMASK(7, 0)
8144 
8145 #define MTL_MEDIA_GSI_BASE		0x380000
8146 
8147 #endif /* _I915_REG_H_ */
8148