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