Merge tag 'drm-misc-next-2023-03-16' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-block.git] / drivers / gpu / drm / i915 / i915_reg.h
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              (1 << 27)
1798 #define   PWM2_GATING_DIS               (1 << 14)
1799 #define   PWM1_GATING_DIS               (1 << 13)
1800
1801 #define GEN9_CLKGATE_DIS_3              _MMIO(0x46538)
1802 #define   TGL_VRH_GATING_DIS            REG_BIT(31)
1803 #define   DPT_GATING_DIS                REG_BIT(22)
1804
1805 #define GEN9_CLKGATE_DIS_4              _MMIO(0x4653C)
1806 #define   BXT_GMBUS_GATING_DIS          (1 << 14)
1807
1808 #define GEN9_CLKGATE_DIS_5              _MMIO(0x46540)
1809 #define   DPCE_GATING_DIS               REG_BIT(17)
1810
1811 #define _CLKGATE_DIS_PSL_A              0x46520
1812 #define _CLKGATE_DIS_PSL_B              0x46524
1813 #define _CLKGATE_DIS_PSL_C              0x46528
1814 #define   DUPS1_GATING_DIS              (1 << 15)
1815 #define   DUPS2_GATING_DIS              (1 << 19)
1816 #define   DUPS3_GATING_DIS              (1 << 23)
1817 #define   CURSOR_GATING_DIS             REG_BIT(28)
1818 #define   DPF_GATING_DIS                (1 << 10)
1819 #define   DPF_RAM_GATING_DIS            (1 << 9)
1820 #define   DPFR_GATING_DIS               (1 << 8)
1821
1822 #define CLKGATE_DIS_PSL(pipe) \
1823         _MMIO_PIPE(pipe, _CLKGATE_DIS_PSL_A, _CLKGATE_DIS_PSL_B)
1824
1825 #define _CLKGATE_DIS_PSL_EXT_A          0x4654C
1826 #define _CLKGATE_DIS_PSL_EXT_B          0x46550
1827 #define   PIPEDMC_GATING_DIS            REG_BIT(12)
1828
1829 #define CLKGATE_DIS_PSL_EXT(pipe) \
1830         _MMIO_PIPE(pipe, _CLKGATE_DIS_PSL_EXT_A, _CLKGATE_DIS_PSL_EXT_B)
1831
1832 /*
1833  * Display engine regs
1834  */
1835
1836 /* Pipe A CRC regs */
1837 #define _PIPE_CRC_CTL_A                 0x60050
1838 #define   PIPE_CRC_ENABLE               REG_BIT(31)
1839 /* skl+ source selection */
1840 #define   PIPE_CRC_SOURCE_MASK_SKL      REG_GENMASK(30, 28)
1841 #define   PIPE_CRC_SOURCE_PLANE_1_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 0)
1842 #define   PIPE_CRC_SOURCE_PLANE_2_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 2)
1843 #define   PIPE_CRC_SOURCE_DMUX_SKL      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 4)
1844 #define   PIPE_CRC_SOURCE_PLANE_3_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 6)
1845 #define   PIPE_CRC_SOURCE_PLANE_4_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 7)
1846 #define   PIPE_CRC_SOURCE_PLANE_5_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 5)
1847 #define   PIPE_CRC_SOURCE_PLANE_6_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 3)
1848 #define   PIPE_CRC_SOURCE_PLANE_7_SKL   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_SKL, 1)
1849 /* ivb+ source selection */
1850 #define   PIPE_CRC_SOURCE_MASK_IVB      REG_GENMASK(30, 29)
1851 #define   PIPE_CRC_SOURCE_PRIMARY_IVB   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 0)
1852 #define   PIPE_CRC_SOURCE_SPRITE_IVB    REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 1)
1853 #define   PIPE_CRC_SOURCE_PF_IVB        REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_IVB, 2)
1854 /* ilk+ source selection */
1855 #define   PIPE_CRC_SOURCE_MASK_ILK      REG_GENMASK(30, 28)
1856 #define   PIPE_CRC_SOURCE_PRIMARY_ILK   REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 0)
1857 #define   PIPE_CRC_SOURCE_SPRITE_ILK    REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 1)
1858 #define   PIPE_CRC_SOURCE_PIPE_ILK      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 2)
1859 /* embedded DP port on the north display block */
1860 #define   PIPE_CRC_SOURCE_PORT_A_ILK    REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 4)
1861 #define   PIPE_CRC_SOURCE_FDI_ILK       REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_ILK, 5)
1862 /* vlv source selection */
1863 #define   PIPE_CRC_SOURCE_MASK_VLV      REG_GENMASK(30, 27)
1864 #define   PIPE_CRC_SOURCE_PIPE_VLV      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 0)
1865 #define   PIPE_CRC_SOURCE_HDMIB_VLV     REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 1)
1866 #define   PIPE_CRC_SOURCE_HDMIC_VLV     REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 2)
1867 /* with DP port the pipe source is invalid */
1868 #define   PIPE_CRC_SOURCE_DP_D_VLV      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 3)
1869 #define   PIPE_CRC_SOURCE_DP_B_VLV      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 6)
1870 #define   PIPE_CRC_SOURCE_DP_C_VLV      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_VLV, 7)
1871 /* gen3+ source selection */
1872 #define   PIPE_CRC_SOURCE_MASK_I9XX     REG_GENMASK(30, 28)
1873 #define   PIPE_CRC_SOURCE_PIPE_I9XX     REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 0)
1874 #define   PIPE_CRC_SOURCE_SDVOB_I9XX    REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 1)
1875 #define   PIPE_CRC_SOURCE_SDVOC_I9XX    REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 2)
1876 /* with DP/TV port the pipe source is invalid */
1877 #define   PIPE_CRC_SOURCE_DP_D_G4X      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 3)
1878 #define   PIPE_CRC_SOURCE_TV_PRE        REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 4)
1879 #define   PIPE_CRC_SOURCE_TV_POST       REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 5)
1880 #define   PIPE_CRC_SOURCE_DP_B_G4X      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 6)
1881 #define   PIPE_CRC_SOURCE_DP_C_G4X      REG_FIELD_PREP(PIPE_CRC_SOURCE_MASK_I9XX, 7)
1882 /* gen2 doesn't have source selection bits */
1883 #define   PIPE_CRC_INCLUDE_BORDER_I8XX  REG_BIT(30)
1884
1885 #define _PIPE_CRC_RES_1_A_IVB           0x60064
1886 #define _PIPE_CRC_RES_2_A_IVB           0x60068
1887 #define _PIPE_CRC_RES_3_A_IVB           0x6006c
1888 #define _PIPE_CRC_RES_4_A_IVB           0x60070
1889 #define _PIPE_CRC_RES_5_A_IVB           0x60074
1890
1891 #define _PIPE_CRC_RES_RED_A             0x60060
1892 #define _PIPE_CRC_RES_GREEN_A           0x60064
1893 #define _PIPE_CRC_RES_BLUE_A            0x60068
1894 #define _PIPE_CRC_RES_RES1_A_I915       0x6006c
1895 #define _PIPE_CRC_RES_RES2_A_G4X        0x60080
1896
1897 /* Pipe B CRC regs */
1898 #define _PIPE_CRC_RES_1_B_IVB           0x61064
1899 #define _PIPE_CRC_RES_2_B_IVB           0x61068
1900 #define _PIPE_CRC_RES_3_B_IVB           0x6106c
1901 #define _PIPE_CRC_RES_4_B_IVB           0x61070
1902 #define _PIPE_CRC_RES_5_B_IVB           0x61074
1903
1904 #define PIPE_CRC_CTL(pipe)              _MMIO_TRANS2(pipe, _PIPE_CRC_CTL_A)
1905 #define PIPE_CRC_RES_1_IVB(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_1_A_IVB)
1906 #define PIPE_CRC_RES_2_IVB(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_2_A_IVB)
1907 #define PIPE_CRC_RES_3_IVB(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_3_A_IVB)
1908 #define PIPE_CRC_RES_4_IVB(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_4_A_IVB)
1909 #define PIPE_CRC_RES_5_IVB(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_5_A_IVB)
1910
1911 #define PIPE_CRC_RES_RED(pipe)          _MMIO_TRANS2(pipe, _PIPE_CRC_RES_RED_A)
1912 #define PIPE_CRC_RES_GREEN(pipe)        _MMIO_TRANS2(pipe, _PIPE_CRC_RES_GREEN_A)
1913 #define PIPE_CRC_RES_BLUE(pipe)         _MMIO_TRANS2(pipe, _PIPE_CRC_RES_BLUE_A)
1914 #define PIPE_CRC_RES_RES1_I915(pipe)    _MMIO_TRANS2(pipe, _PIPE_CRC_RES_RES1_A_I915)
1915 #define PIPE_CRC_RES_RES2_G4X(pipe)     _MMIO_TRANS2(pipe, _PIPE_CRC_RES_RES2_A_G4X)
1916
1917 /* Pipe/transcoder A timing regs */
1918 #define _TRANS_HTOTAL_A         0x60000
1919 #define   HTOTAL_MASK                   REG_GENMASK(31, 16)
1920 #define   HTOTAL(htotal)                REG_FIELD_PREP(HTOTAL_MASK, (htotal))
1921 #define   HACTIVE_MASK                  REG_GENMASK(15, 0)
1922 #define   HACTIVE(hdisplay)             REG_FIELD_PREP(HACTIVE_MASK, (hdisplay))
1923 #define _TRANS_HBLANK_A         0x60004
1924 #define   HBLANK_END_MASK               REG_GENMASK(31, 16)
1925 #define   HBLANK_END(hblank_end)        REG_FIELD_PREP(HBLANK_END_MASK, (hblank_end))
1926 #define   HBLANK_START_MASK             REG_GENMASK(15, 0)
1927 #define   HBLANK_START(hblank_start)    REG_FIELD_PREP(HBLANK_START_MASK, (hblank_start))
1928 #define _TRANS_HSYNC_A          0x60008
1929 #define   HSYNC_END_MASK                REG_GENMASK(31, 16)
1930 #define   HSYNC_END(hsync_end)          REG_FIELD_PREP(HSYNC_END_MASK, (hsync_end))
1931 #define   HSYNC_START_MASK              REG_GENMASK(15, 0)
1932 #define   HSYNC_START(hsync_start)      REG_FIELD_PREP(HSYNC_START_MASK, (hsync_start))
1933 #define _TRANS_VTOTAL_A         0x6000c
1934 #define   VTOTAL_MASK                   REG_GENMASK(31, 16)
1935 #define   VTOTAL(vtotal)                REG_FIELD_PREP(VTOTAL_MASK, (vtotal))
1936 #define   VACTIVE_MASK                  REG_GENMASK(15, 0)
1937 #define   VACTIVE(vdisplay)             REG_FIELD_PREP(VACTIVE_MASK, (vdisplay))
1938 #define _TRANS_VBLANK_A         0x60010
1939 #define   VBLANK_END_MASK               REG_GENMASK(31, 16)
1940 #define   VBLANK_END(vblank_end)        REG_FIELD_PREP(VBLANK_END_MASK, (vblank_end))
1941 #define   VBLANK_START_MASK             REG_GENMASK(15, 0)
1942 #define   VBLANK_START(vblank_start)    REG_FIELD_PREP(VBLANK_START_MASK, (vblank_start))
1943 #define _TRANS_VSYNC_A          0x60014
1944 #define   VSYNC_END_MASK                REG_GENMASK(31, 16)
1945 #define   VSYNC_END(vsync_end)          REG_FIELD_PREP(VSYNC_END_MASK, (vsync_end))
1946 #define   VSYNC_START_MASK              REG_GENMASK(15, 0)
1947 #define   VSYNC_START(vsync_start)      REG_FIELD_PREP(VSYNC_START_MASK, (vsync_start))
1948 #define _TRANS_EXITLINE_A       0x60018
1949 #define _PIPEASRC               0x6001c
1950 #define   PIPESRC_WIDTH_MASK    REG_GENMASK(31, 16)
1951 #define   PIPESRC_WIDTH(w)      REG_FIELD_PREP(PIPESRC_WIDTH_MASK, (w))
1952 #define   PIPESRC_HEIGHT_MASK   REG_GENMASK(15, 0)
1953 #define   PIPESRC_HEIGHT(h)     REG_FIELD_PREP(PIPESRC_HEIGHT_MASK, (h))
1954 #define _BCLRPAT_A              0x60020
1955 #define _TRANS_VSYNCSHIFT_A     0x60028
1956 #define _TRANS_MULT_A           0x6002c
1957
1958 /* Pipe/transcoder B timing regs */
1959 #define _TRANS_HTOTAL_B         0x61000
1960 #define _TRANS_HBLANK_B         0x61004
1961 #define _TRANS_HSYNC_B          0x61008
1962 #define _TRANS_VTOTAL_B         0x6100c
1963 #define _TRANS_VBLANK_B         0x61010
1964 #define _TRANS_VSYNC_B          0x61014
1965 #define _PIPEBSRC               0x6101c
1966 #define _BCLRPAT_B              0x61020
1967 #define _TRANS_VSYNCSHIFT_B     0x61028
1968 #define _TRANS_MULT_B           0x6102c
1969
1970 /* DSI 0 timing regs */
1971 #define _TRANS_HTOTAL_DSI0      0x6b000
1972 #define _TRANS_HSYNC_DSI0       0x6b008
1973 #define _TRANS_VTOTAL_DSI0      0x6b00c
1974 #define _TRANS_VSYNC_DSI0       0x6b014
1975 #define _TRANS_VSYNCSHIFT_DSI0  0x6b028
1976
1977 /* DSI 1 timing regs */
1978 #define _TRANS_HTOTAL_DSI1      0x6b800
1979 #define _TRANS_HSYNC_DSI1       0x6b808
1980 #define _TRANS_VTOTAL_DSI1      0x6b80c
1981 #define _TRANS_VSYNC_DSI1       0x6b814
1982 #define _TRANS_VSYNCSHIFT_DSI1  0x6b828
1983
1984 #define TRANSCODER_A_OFFSET 0x60000
1985 #define TRANSCODER_B_OFFSET 0x61000
1986 #define TRANSCODER_C_OFFSET 0x62000
1987 #define CHV_TRANSCODER_C_OFFSET 0x63000
1988 #define TRANSCODER_D_OFFSET 0x63000
1989 #define TRANSCODER_EDP_OFFSET 0x6f000
1990 #define TRANSCODER_DSI0_OFFSET  0x6b000
1991 #define TRANSCODER_DSI1_OFFSET  0x6b800
1992
1993 #define TRANS_HTOTAL(trans)     _MMIO_TRANS2((trans), _TRANS_HTOTAL_A)
1994 #define TRANS_HBLANK(trans)     _MMIO_TRANS2((trans), _TRANS_HBLANK_A)
1995 #define TRANS_HSYNC(trans)      _MMIO_TRANS2((trans), _TRANS_HSYNC_A)
1996 #define TRANS_VTOTAL(trans)     _MMIO_TRANS2((trans), _TRANS_VTOTAL_A)
1997 #define TRANS_VBLANK(trans)     _MMIO_TRANS2((trans), _TRANS_VBLANK_A)
1998 #define TRANS_VSYNC(trans)      _MMIO_TRANS2((trans), _TRANS_VSYNC_A)
1999 #define BCLRPAT(trans)          _MMIO_TRANS2((trans), _BCLRPAT_A)
2000 #define TRANS_VSYNCSHIFT(trans) _MMIO_TRANS2((trans), _TRANS_VSYNCSHIFT_A)
2001 #define PIPESRC(pipe)           _MMIO_TRANS2((pipe), _PIPEASRC)
2002 #define TRANS_MULT(trans)       _MMIO_TRANS2((trans), _TRANS_MULT_A)
2003
2004 #define TRANS_EXITLINE(trans)   _MMIO_TRANS2((trans), _TRANS_EXITLINE_A)
2005 #define   EXITLINE_ENABLE       REG_BIT(31)
2006 #define   EXITLINE_MASK         REG_GENMASK(12, 0)
2007 #define   EXITLINE_SHIFT        0
2008
2009 /* VRR registers */
2010 #define _TRANS_VRR_CTL_A                0x60420
2011 #define _TRANS_VRR_CTL_B                0x61420
2012 #define _TRANS_VRR_CTL_C                0x62420
2013 #define _TRANS_VRR_CTL_D                0x63420
2014 #define TRANS_VRR_CTL(trans)                    _MMIO_TRANS2(trans, _TRANS_VRR_CTL_A)
2015 #define   VRR_CTL_VRR_ENABLE                    REG_BIT(31)
2016 #define   VRR_CTL_IGN_MAX_SHIFT                 REG_BIT(30)
2017 #define   VRR_CTL_FLIP_LINE_EN                  REG_BIT(29)
2018 #define   VRR_CTL_PIPELINE_FULL_MASK            REG_GENMASK(10, 3)
2019 #define   VRR_CTL_PIPELINE_FULL(x)              REG_FIELD_PREP(VRR_CTL_PIPELINE_FULL_MASK, (x))
2020 #define   VRR_CTL_PIPELINE_FULL_OVERRIDE        REG_BIT(0)
2021 #define   XELPD_VRR_CTL_VRR_GUARDBAND_MASK      REG_GENMASK(15, 0)
2022 #define   XELPD_VRR_CTL_VRR_GUARDBAND(x)        REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, (x))
2023
2024 #define _TRANS_VRR_VMAX_A               0x60424
2025 #define _TRANS_VRR_VMAX_B               0x61424
2026 #define _TRANS_VRR_VMAX_C               0x62424
2027 #define _TRANS_VRR_VMAX_D               0x63424
2028 #define TRANS_VRR_VMAX(trans)           _MMIO_TRANS2(trans, _TRANS_VRR_VMAX_A)
2029 #define   VRR_VMAX_MASK                 REG_GENMASK(19, 0)
2030
2031 #define _TRANS_VRR_VMIN_A               0x60434
2032 #define _TRANS_VRR_VMIN_B               0x61434
2033 #define _TRANS_VRR_VMIN_C               0x62434
2034 #define _TRANS_VRR_VMIN_D               0x63434
2035 #define TRANS_VRR_VMIN(trans)           _MMIO_TRANS2(trans, _TRANS_VRR_VMIN_A)
2036 #define   VRR_VMIN_MASK                 REG_GENMASK(15, 0)
2037
2038 #define _TRANS_VRR_VMAXSHIFT_A          0x60428
2039 #define _TRANS_VRR_VMAXSHIFT_B          0x61428
2040 #define _TRANS_VRR_VMAXSHIFT_C          0x62428
2041 #define _TRANS_VRR_VMAXSHIFT_D          0x63428
2042 #define TRANS_VRR_VMAXSHIFT(trans)      _MMIO_TRANS2(trans, \
2043                                         _TRANS_VRR_VMAXSHIFT_A)
2044 #define   VRR_VMAXSHIFT_DEC_MASK        REG_GENMASK(29, 16)
2045 #define   VRR_VMAXSHIFT_DEC             REG_BIT(16)
2046 #define   VRR_VMAXSHIFT_INC_MASK        REG_GENMASK(12, 0)
2047
2048 #define _TRANS_VRR_STATUS_A             0x6042C
2049 #define _TRANS_VRR_STATUS_B             0x6142C
2050 #define _TRANS_VRR_STATUS_C             0x6242C
2051 #define _TRANS_VRR_STATUS_D             0x6342C
2052 #define TRANS_VRR_STATUS(trans)         _MMIO_TRANS2(trans, _TRANS_VRR_STATUS_A)
2053 #define   VRR_STATUS_VMAX_REACHED       REG_BIT(31)
2054 #define   VRR_STATUS_NOFLIP_TILL_BNDR   REG_BIT(30)
2055 #define   VRR_STATUS_FLIP_BEF_BNDR      REG_BIT(29)
2056 #define   VRR_STATUS_NO_FLIP_FRAME      REG_BIT(28)
2057 #define   VRR_STATUS_VRR_EN_LIVE        REG_BIT(27)
2058 #define   VRR_STATUS_FLIPS_SERVICED     REG_BIT(26)
2059 #define   VRR_STATUS_VBLANK_MASK        REG_GENMASK(22, 20)
2060 #define   STATUS_FSM_IDLE               REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 0)
2061 #define   STATUS_FSM_WAIT_TILL_FDB      REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 1)
2062 #define   STATUS_FSM_WAIT_TILL_FS       REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 2)
2063 #define   STATUS_FSM_WAIT_TILL_FLIP     REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 3)
2064 #define   STATUS_FSM_PIPELINE_FILL      REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 4)
2065 #define   STATUS_FSM_ACTIVE             REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 5)
2066 #define   STATUS_FSM_LEGACY_VBLANK      REG_FIELD_PREP(VRR_STATUS_VBLANK_MASK, 6)
2067
2068 #define _TRANS_VRR_VTOTAL_PREV_A        0x60480
2069 #define _TRANS_VRR_VTOTAL_PREV_B        0x61480
2070 #define _TRANS_VRR_VTOTAL_PREV_C        0x62480
2071 #define _TRANS_VRR_VTOTAL_PREV_D        0x63480
2072 #define TRANS_VRR_VTOTAL_PREV(trans)    _MMIO_TRANS2(trans, \
2073                                         _TRANS_VRR_VTOTAL_PREV_A)
2074 #define   VRR_VTOTAL_FLIP_BEFR_BNDR     REG_BIT(31)
2075 #define   VRR_VTOTAL_FLIP_AFTER_BNDR    REG_BIT(30)
2076 #define   VRR_VTOTAL_FLIP_AFTER_DBLBUF  REG_BIT(29)
2077 #define   VRR_VTOTAL_PREV_FRAME_MASK    REG_GENMASK(19, 0)
2078
2079 #define _TRANS_VRR_FLIPLINE_A           0x60438
2080 #define _TRANS_VRR_FLIPLINE_B           0x61438
2081 #define _TRANS_VRR_FLIPLINE_C           0x62438
2082 #define _TRANS_VRR_FLIPLINE_D           0x63438
2083 #define TRANS_VRR_FLIPLINE(trans)       _MMIO_TRANS2(trans, \
2084                                         _TRANS_VRR_FLIPLINE_A)
2085 #define   VRR_FLIPLINE_MASK             REG_GENMASK(19, 0)
2086
2087 #define _TRANS_VRR_STATUS2_A            0x6043C
2088 #define _TRANS_VRR_STATUS2_B            0x6143C
2089 #define _TRANS_VRR_STATUS2_C            0x6243C
2090 #define _TRANS_VRR_STATUS2_D            0x6343C
2091 #define TRANS_VRR_STATUS2(trans)        _MMIO_TRANS2(trans, _TRANS_VRR_STATUS2_A)
2092 #define   VRR_STATUS2_VERT_LN_CNT_MASK  REG_GENMASK(19, 0)
2093
2094 #define _TRANS_PUSH_A                   0x60A70
2095 #define _TRANS_PUSH_B                   0x61A70
2096 #define _TRANS_PUSH_C                   0x62A70
2097 #define _TRANS_PUSH_D                   0x63A70
2098 #define TRANS_PUSH(trans)               _MMIO_TRANS2(trans, _TRANS_PUSH_A)
2099 #define   TRANS_PUSH_EN                 REG_BIT(31)
2100 #define   TRANS_PUSH_SEND               REG_BIT(30)
2101
2102 /*
2103  * HSW+ eDP PSR registers
2104  *
2105  * HSW PSR registers are relative to DDIA(_DDI_BUF_CTL_A + 0x800) with just one
2106  * instance of it
2107  */
2108 #define _SRD_CTL_A                              0x60800
2109 #define _SRD_CTL_EDP                            0x6f800
2110 #define EDP_PSR_CTL(tran)                       _MMIO_TRANS2(tran, _SRD_CTL_A)
2111 #define   EDP_PSR_ENABLE                        (1 << 31)
2112 #define   BDW_PSR_SINGLE_FRAME                  (1 << 30)
2113 #define   EDP_PSR_RESTORE_PSR_ACTIVE_CTX_MASK   (1 << 29) /* SW can't modify */
2114 #define   EDP_PSR_LINK_STANDBY                  (1 << 27)
2115 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_MASK      (3 << 25)
2116 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_8_LINES   (0 << 25)
2117 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_4_LINES   (1 << 25)
2118 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_2_LINES   (2 << 25)
2119 #define   EDP_PSR_MIN_LINK_ENTRY_TIME_0_LINES   (3 << 25)
2120 #define   EDP_PSR_MAX_SLEEP_TIME_SHIFT          20
2121 #define   EDP_PSR_SKIP_AUX_EXIT                 (1 << 12)
2122 #define   EDP_PSR_TP1_TP2_SEL                   (0 << 11)
2123 #define   EDP_PSR_TP1_TP3_SEL                   (1 << 11)
2124 #define   EDP_PSR_CRC_ENABLE                    (1 << 10) /* BDW+ */
2125 #define   EDP_PSR_TP2_TP3_TIME_500us            (0 << 8)
2126 #define   EDP_PSR_TP2_TP3_TIME_100us            (1 << 8)
2127 #define   EDP_PSR_TP2_TP3_TIME_2500us           (2 << 8)
2128 #define   EDP_PSR_TP2_TP3_TIME_0us              (3 << 8)
2129 #define   EDP_PSR_TP4_TIME_0US                  (3 << 6) /* ICL+ */
2130 #define   EDP_PSR_TP1_TIME_500us                (0 << 4)
2131 #define   EDP_PSR_TP1_TIME_100us                (1 << 4)
2132 #define   EDP_PSR_TP1_TIME_2500us               (2 << 4)
2133 #define   EDP_PSR_TP1_TIME_0us                  (3 << 4)
2134 #define   EDP_PSR_IDLE_FRAME_SHIFT              0
2135
2136 /*
2137  * Until TGL, IMR/IIR are fixed at 0x648xx. On TGL+ those registers are relative
2138  * to transcoder and bits defined for each one as if using no shift (i.e. as if
2139  * it was for TRANSCODER_EDP)
2140  */
2141 #define EDP_PSR_IMR                             _MMIO(0x64834)
2142 #define EDP_PSR_IIR                             _MMIO(0x64838)
2143 #define _PSR_IMR_A                              0x60814
2144 #define _PSR_IIR_A                              0x60818
2145 #define TRANS_PSR_IMR(tran)                     _MMIO_TRANS2(tran, _PSR_IMR_A)
2146 #define TRANS_PSR_IIR(tran)                     _MMIO_TRANS2(tran, _PSR_IIR_A)
2147 #define   _EDP_PSR_TRANS_SHIFT(trans)           ((trans) == TRANSCODER_EDP ? \
2148                                                  0 : ((trans) - TRANSCODER_A + 1) * 8)
2149 #define   TGL_PSR_MASK                  REG_GENMASK(2, 0)
2150 #define   TGL_PSR_ERROR                 REG_BIT(2)
2151 #define   TGL_PSR_POST_EXIT             REG_BIT(1)
2152 #define   TGL_PSR_PRE_ENTRY             REG_BIT(0)
2153 #define   EDP_PSR_MASK(trans)           (TGL_PSR_MASK <<                \
2154                                          _EDP_PSR_TRANS_SHIFT(trans))
2155 #define   EDP_PSR_ERROR(trans)          (TGL_PSR_ERROR <<               \
2156                                          _EDP_PSR_TRANS_SHIFT(trans))
2157 #define   EDP_PSR_POST_EXIT(trans)      (TGL_PSR_POST_EXIT <<           \
2158                                          _EDP_PSR_TRANS_SHIFT(trans))
2159 #define   EDP_PSR_PRE_ENTRY(trans)      (TGL_PSR_PRE_ENTRY <<           \
2160                                          _EDP_PSR_TRANS_SHIFT(trans))
2161
2162 #define _SRD_AUX_DATA_A                         0x60814
2163 #define _SRD_AUX_DATA_EDP                       0x6f814
2164 #define EDP_PSR_AUX_DATA(tran, i)               _MMIO_TRANS2(tran, _SRD_AUX_DATA_A + (i) + 4) /* 5 registers */
2165
2166 #define _SRD_STATUS_A                           0x60840
2167 #define _SRD_STATUS_EDP                         0x6f840
2168 #define EDP_PSR_STATUS(tran)                    _MMIO_TRANS2(tran, _SRD_STATUS_A)
2169 #define   EDP_PSR_STATUS_STATE_MASK             (7 << 29)
2170 #define   EDP_PSR_STATUS_STATE_SHIFT            29
2171 #define   EDP_PSR_STATUS_STATE_IDLE             (0 << 29)
2172 #define   EDP_PSR_STATUS_STATE_SRDONACK         (1 << 29)
2173 #define   EDP_PSR_STATUS_STATE_SRDENT           (2 << 29)
2174 #define   EDP_PSR_STATUS_STATE_BUFOFF           (3 << 29)
2175 #define   EDP_PSR_STATUS_STATE_BUFON            (4 << 29)
2176 #define   EDP_PSR_STATUS_STATE_AUXACK           (5 << 29)
2177 #define   EDP_PSR_STATUS_STATE_SRDOFFACK        (6 << 29)
2178 #define   EDP_PSR_STATUS_LINK_MASK              (3 << 26)
2179 #define   EDP_PSR_STATUS_LINK_FULL_OFF          (0 << 26)
2180 #define   EDP_PSR_STATUS_LINK_FULL_ON           (1 << 26)
2181 #define   EDP_PSR_STATUS_LINK_STANDBY           (2 << 26)
2182 #define   EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT  20
2183 #define   EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK   0x1f
2184 #define   EDP_PSR_STATUS_COUNT_SHIFT            16
2185 #define   EDP_PSR_STATUS_COUNT_MASK             0xf
2186 #define   EDP_PSR_STATUS_AUX_ERROR              (1 << 15)
2187 #define   EDP_PSR_STATUS_AUX_SENDING            (1 << 12)
2188 #define   EDP_PSR_STATUS_SENDING_IDLE           (1 << 9)
2189 #define   EDP_PSR_STATUS_SENDING_TP2_TP3        (1 << 8)
2190 #define   EDP_PSR_STATUS_SENDING_TP1            (1 << 4)
2191 #define   EDP_PSR_STATUS_IDLE_MASK              0xf
2192
2193 #define _SRD_PERF_CNT_A                 0x60844
2194 #define _SRD_PERF_CNT_EDP               0x6f844
2195 #define EDP_PSR_PERF_CNT(tran)          _MMIO_TRANS2(tran, _SRD_PERF_CNT_A)
2196 #define   EDP_PSR_PERF_CNT_MASK         0xffffff
2197
2198 /* PSR_MASK on SKL+ */
2199 #define _SRD_DEBUG_A                            0x60860
2200 #define _SRD_DEBUG_EDP                          0x6f860
2201 #define EDP_PSR_DEBUG(tran)                     _MMIO_TRANS2(tran, _SRD_DEBUG_A)
2202 #define   EDP_PSR_DEBUG_MASK_MAX_SLEEP         (1 << 28)
2203 #define   EDP_PSR_DEBUG_MASK_LPSP              (1 << 27)
2204 #define   EDP_PSR_DEBUG_MASK_MEMUP             (1 << 26)
2205 #define   EDP_PSR_DEBUG_MASK_HPD               (1 << 25)
2206 #define   EDP_PSR_DEBUG_MASK_DISP_REG_WRITE    (1 << 16) /* Reserved in ICL+ */
2207 #define   EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1 << 15) /* SKL+ */
2208
2209 #define _PSR2_CTL_A                             0x60900
2210 #define _PSR2_CTL_EDP                           0x6f900
2211 #define EDP_PSR2_CTL(tran)                      _MMIO_TRANS2(tran, _PSR2_CTL_A)
2212 #define   EDP_PSR2_ENABLE                       (1 << 31)
2213 #define   EDP_SU_TRACK_ENABLE                   (1 << 30) /* up to adl-p */
2214 #define   TGL_EDP_PSR2_BLOCK_COUNT_NUM_2        (0 << 28)
2215 #define   TGL_EDP_PSR2_BLOCK_COUNT_NUM_3        (1 << 28)
2216 #define   EDP_Y_COORDINATE_ENABLE               REG_BIT(25) /* display 10, 11 and 12 */
2217 #define   EDP_PSR2_SU_SDP_SCANLINE              REG_BIT(25) /* display 13+ */
2218 #define   EDP_MAX_SU_DISABLE_TIME(t)            ((t) << 20)
2219 #define   EDP_MAX_SU_DISABLE_TIME_MASK          (0x1f << 20)
2220 #define   EDP_PSR2_IO_BUFFER_WAKE_MAX_LINES     8
2221 #define   EDP_PSR2_IO_BUFFER_WAKE(lines)        ((EDP_PSR2_IO_BUFFER_WAKE_MAX_LINES - (lines)) << 13)
2222 #define   EDP_PSR2_IO_BUFFER_WAKE_MASK          (3 << 13)
2223 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_MIN_LINES 5
2224 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_SHIFT     13
2225 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE(lines)    (((lines) - TGL_EDP_PSR2_IO_BUFFER_WAKE_MIN_LINES) << TGL_EDP_PSR2_IO_BUFFER_WAKE_SHIFT)
2226 #define   TGL_EDP_PSR2_IO_BUFFER_WAKE_MASK      (7 << 13)
2227 #define   EDP_PSR2_FAST_WAKE_MAX_LINES          8
2228 #define   EDP_PSR2_FAST_WAKE(lines)             ((EDP_PSR2_FAST_WAKE_MAX_LINES - (lines)) << 11)
2229 #define   EDP_PSR2_FAST_WAKE_MASK               (3 << 11)
2230 #define   TGL_EDP_PSR2_FAST_WAKE_MIN_LINES      5
2231 #define   TGL_EDP_PSR2_FAST_WAKE_MIN_SHIFT      10
2232 #define   TGL_EDP_PSR2_FAST_WAKE(lines)         (((lines) - TGL_EDP_PSR2_FAST_WAKE_MIN_LINES) << TGL_EDP_PSR2_FAST_WAKE_MIN_SHIFT)
2233 #define   TGL_EDP_PSR2_FAST_WAKE_MASK           (7 << 10)
2234 #define   EDP_PSR2_TP2_TIME_500us               (0 << 8)
2235 #define   EDP_PSR2_TP2_TIME_100us               (1 << 8)
2236 #define   EDP_PSR2_TP2_TIME_2500us              (2 << 8)
2237 #define   EDP_PSR2_TP2_TIME_50us                (3 << 8)
2238 #define   EDP_PSR2_TP2_TIME_MASK                (3 << 8)
2239 #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT        4
2240 #define   EDP_PSR2_FRAME_BEFORE_SU_MASK         (0xf << 4)
2241 #define   EDP_PSR2_FRAME_BEFORE_SU(a)           ((a) << 4)
2242 #define   EDP_PSR2_IDLE_FRAME_MASK              0xf
2243 #define   EDP_PSR2_IDLE_FRAME_SHIFT             0
2244
2245 #define _PSR_EVENT_TRANS_A                      0x60848
2246 #define _PSR_EVENT_TRANS_B                      0x61848
2247 #define _PSR_EVENT_TRANS_C                      0x62848
2248 #define _PSR_EVENT_TRANS_D                      0x63848
2249 #define _PSR_EVENT_TRANS_EDP                    0x6f848
2250 #define PSR_EVENT(tran)                         _MMIO_TRANS2(tran, _PSR_EVENT_TRANS_A)
2251 #define  PSR_EVENT_PSR2_WD_TIMER_EXPIRE         (1 << 17)
2252 #define  PSR_EVENT_PSR2_DISABLED                (1 << 16)
2253 #define  PSR_EVENT_SU_DIRTY_FIFO_UNDERRUN       (1 << 15)
2254 #define  PSR_EVENT_SU_CRC_FIFO_UNDERRUN         (1 << 14)
2255 #define  PSR_EVENT_GRAPHICS_RESET               (1 << 12)
2256 #define  PSR_EVENT_PCH_INTERRUPT                (1 << 11)
2257 #define  PSR_EVENT_MEMORY_UP                    (1 << 10)
2258 #define  PSR_EVENT_FRONT_BUFFER_MODIFY          (1 << 9)
2259 #define  PSR_EVENT_WD_TIMER_EXPIRE              (1 << 8)
2260 #define  PSR_EVENT_PIPE_REGISTERS_UPDATE        (1 << 6)
2261 #define  PSR_EVENT_REGISTER_UPDATE              (1 << 5) /* Reserved in ICL+ */
2262 #define  PSR_EVENT_HDCP_ENABLE                  (1 << 4)
2263 #define  PSR_EVENT_KVMR_SESSION_ENABLE          (1 << 3)
2264 #define  PSR_EVENT_VBI_ENABLE                   (1 << 2)
2265 #define  PSR_EVENT_LPSP_MODE_EXIT               (1 << 1)
2266 #define  PSR_EVENT_PSR_DISABLE                  (1 << 0)
2267
2268 #define _PSR2_STATUS_A                          0x60940
2269 #define _PSR2_STATUS_EDP                        0x6f940
2270 #define EDP_PSR2_STATUS(tran)                   _MMIO_TRANS2(tran, _PSR2_STATUS_A)
2271 #define EDP_PSR2_STATUS_STATE_MASK              REG_GENMASK(31, 28)
2272 #define EDP_PSR2_STATUS_STATE_DEEP_SLEEP        REG_FIELD_PREP(EDP_PSR2_STATUS_STATE_MASK, 0x8)
2273
2274 #define _PSR2_SU_STATUS_A               0x60914
2275 #define _PSR2_SU_STATUS_EDP             0x6f914
2276 #define _PSR2_SU_STATUS(tran, index)    _MMIO_TRANS2(tran, _PSR2_SU_STATUS_A + (index) * 4)
2277 #define PSR2_SU_STATUS(tran, frame)     (_PSR2_SU_STATUS(tran, (frame) / 3))
2278 #define PSR2_SU_STATUS_SHIFT(frame)     (((frame) % 3) * 10)
2279 #define PSR2_SU_STATUS_MASK(frame)      (0x3ff << PSR2_SU_STATUS_SHIFT(frame))
2280 #define PSR2_SU_STATUS_FRAMES           8
2281
2282 #define _PSR2_MAN_TRK_CTL_A                                     0x60910
2283 #define _PSR2_MAN_TRK_CTL_EDP                                   0x6f910
2284 #define PSR2_MAN_TRK_CTL(tran)                                  _MMIO_TRANS2(tran, _PSR2_MAN_TRK_CTL_A)
2285 #define  PSR2_MAN_TRK_CTL_ENABLE                                REG_BIT(31)
2286 #define  PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK             REG_GENMASK(30, 21)
2287 #define  PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR(val)             REG_FIELD_PREP(PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK, val)
2288 #define  PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK               REG_GENMASK(20, 11)
2289 #define  PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR(val)               REG_FIELD_PREP(PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK, val)
2290 #define  PSR2_MAN_TRK_CTL_SF_SINGLE_FULL_FRAME                  REG_BIT(3)
2291 #define  PSR2_MAN_TRK_CTL_SF_CONTINUOS_FULL_FRAME               REG_BIT(2)
2292 #define  PSR2_MAN_TRK_CTL_SF_PARTIAL_FRAME_UPDATE               REG_BIT(1)
2293 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_START_ADDR_MASK        REG_GENMASK(28, 16)
2294 #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)
2295 #define  ADLP_PSR2_MAN_TRK_CTL_SU_REGION_END_ADDR_MASK          REG_GENMASK(12, 0)
2296 #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)
2297 #define  ADLP_PSR2_MAN_TRK_CTL_SF_PARTIAL_FRAME_UPDATE          REG_BIT(31)
2298 #define  ADLP_PSR2_MAN_TRK_CTL_SF_SINGLE_FULL_FRAME             REG_BIT(14)
2299 #define  ADLP_PSR2_MAN_TRK_CTL_SF_CONTINUOS_FULL_FRAME          REG_BIT(13)
2300
2301 /* VGA port control */
2302 #define ADPA                    _MMIO(0x61100)
2303 #define PCH_ADPA                _MMIO(0xe1100)
2304 #define VLV_ADPA                _MMIO(VLV_DISPLAY_BASE + 0x61100)
2305
2306 #define   ADPA_DAC_ENABLE       (1 << 31)
2307 #define   ADPA_DAC_DISABLE      0
2308 #define   ADPA_PIPE_SEL_SHIFT           30
2309 #define   ADPA_PIPE_SEL_MASK            (1 << 30)
2310 #define   ADPA_PIPE_SEL(pipe)           ((pipe) << 30)
2311 #define   ADPA_PIPE_SEL_SHIFT_CPT       29
2312 #define   ADPA_PIPE_SEL_MASK_CPT        (3 << 29)
2313 #define   ADPA_PIPE_SEL_CPT(pipe)       ((pipe) << 29)
2314 #define   ADPA_CRT_HOTPLUG_MASK  0x03ff0000 /* bit 25-16 */
2315 #define   ADPA_CRT_HOTPLUG_MONITOR_NONE  (0 << 24)
2316 #define   ADPA_CRT_HOTPLUG_MONITOR_MASK  (3 << 24)
2317 #define   ADPA_CRT_HOTPLUG_MONITOR_COLOR (3 << 24)
2318 #define   ADPA_CRT_HOTPLUG_MONITOR_MONO  (2 << 24)
2319 #define   ADPA_CRT_HOTPLUG_ENABLE        (1 << 23)
2320 #define   ADPA_CRT_HOTPLUG_PERIOD_64     (0 << 22)
2321 #define   ADPA_CRT_HOTPLUG_PERIOD_128    (1 << 22)
2322 #define   ADPA_CRT_HOTPLUG_WARMUP_5MS    (0 << 21)
2323 #define   ADPA_CRT_HOTPLUG_WARMUP_10MS   (1 << 21)
2324 #define   ADPA_CRT_HOTPLUG_SAMPLE_2S     (0 << 20)
2325 #define   ADPA_CRT_HOTPLUG_SAMPLE_4S     (1 << 20)
2326 #define   ADPA_CRT_HOTPLUG_VOLTAGE_40    (0 << 18)
2327 #define   ADPA_CRT_HOTPLUG_VOLTAGE_50    (1 << 18)
2328 #define   ADPA_CRT_HOTPLUG_VOLTAGE_60    (2 << 18)
2329 #define   ADPA_CRT_HOTPLUG_VOLTAGE_70    (3 << 18)
2330 #define   ADPA_CRT_HOTPLUG_VOLREF_325MV  (0 << 17)
2331 #define   ADPA_CRT_HOTPLUG_VOLREF_475MV  (1 << 17)
2332 #define   ADPA_CRT_HOTPLUG_FORCE_TRIGGER (1 << 16)
2333 #define   ADPA_USE_VGA_HVPOLARITY (1 << 15)
2334 #define   ADPA_SETS_HVPOLARITY  0
2335 #define   ADPA_VSYNC_CNTL_DISABLE (1 << 10)
2336 #define   ADPA_VSYNC_CNTL_ENABLE 0
2337 #define   ADPA_HSYNC_CNTL_DISABLE (1 << 11)
2338 #define   ADPA_HSYNC_CNTL_ENABLE 0
2339 #define   ADPA_VSYNC_ACTIVE_HIGH (1 << 4)
2340 #define   ADPA_VSYNC_ACTIVE_LOW 0
2341 #define   ADPA_HSYNC_ACTIVE_HIGH (1 << 3)
2342 #define   ADPA_HSYNC_ACTIVE_LOW 0
2343 #define   ADPA_DPMS_MASK        (~(3 << 10))
2344 #define   ADPA_DPMS_ON          (0 << 10)
2345 #define   ADPA_DPMS_SUSPEND     (1 << 10)
2346 #define   ADPA_DPMS_STANDBY     (2 << 10)
2347 #define   ADPA_DPMS_OFF         (3 << 10)
2348
2349
2350 /* Hotplug control (945+ only) */
2351 #define PORT_HOTPLUG_EN         _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61110)
2352 #define   PORTB_HOTPLUG_INT_EN                  (1 << 29)
2353 #define   PORTC_HOTPLUG_INT_EN                  (1 << 28)
2354 #define   PORTD_HOTPLUG_INT_EN                  (1 << 27)
2355 #define   SDVOB_HOTPLUG_INT_EN                  (1 << 26)
2356 #define   SDVOC_HOTPLUG_INT_EN                  (1 << 25)
2357 #define   TV_HOTPLUG_INT_EN                     (1 << 18)
2358 #define   CRT_HOTPLUG_INT_EN                    (1 << 9)
2359 #define HOTPLUG_INT_EN_MASK                     (PORTB_HOTPLUG_INT_EN | \
2360                                                  PORTC_HOTPLUG_INT_EN | \
2361                                                  PORTD_HOTPLUG_INT_EN | \
2362                                                  SDVOC_HOTPLUG_INT_EN | \
2363                                                  SDVOB_HOTPLUG_INT_EN | \
2364                                                  CRT_HOTPLUG_INT_EN)
2365 #define   CRT_HOTPLUG_FORCE_DETECT              (1 << 3)
2366 #define CRT_HOTPLUG_ACTIVATION_PERIOD_32        (0 << 8)
2367 /* must use period 64 on GM45 according to docs */
2368 #define CRT_HOTPLUG_ACTIVATION_PERIOD_64        (1 << 8)
2369 #define CRT_HOTPLUG_DAC_ON_TIME_2M              (0 << 7)
2370 #define CRT_HOTPLUG_DAC_ON_TIME_4M              (1 << 7)
2371 #define CRT_HOTPLUG_VOLTAGE_COMPARE_40          (0 << 5)
2372 #define CRT_HOTPLUG_VOLTAGE_COMPARE_50          (1 << 5)
2373 #define CRT_HOTPLUG_VOLTAGE_COMPARE_60          (2 << 5)
2374 #define CRT_HOTPLUG_VOLTAGE_COMPARE_70          (3 << 5)
2375 #define CRT_HOTPLUG_VOLTAGE_COMPARE_MASK        (3 << 5)
2376 #define CRT_HOTPLUG_DETECT_DELAY_1G             (0 << 4)
2377 #define CRT_HOTPLUG_DETECT_DELAY_2G             (1 << 4)
2378 #define CRT_HOTPLUG_DETECT_VOLTAGE_325MV        (0 << 2)
2379 #define CRT_HOTPLUG_DETECT_VOLTAGE_475MV        (1 << 2)
2380
2381 #define PORT_HOTPLUG_STAT       _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61114)
2382 /* HDMI/DP bits are g4x+ */
2383 #define   PORTD_HOTPLUG_LIVE_STATUS_G4X         (1 << 27)
2384 #define   PORTC_HOTPLUG_LIVE_STATUS_G4X         (1 << 28)
2385 #define   PORTB_HOTPLUG_LIVE_STATUS_G4X         (1 << 29)
2386 #define   PORTD_HOTPLUG_INT_STATUS              (3 << 21)
2387 #define   PORTD_HOTPLUG_INT_LONG_PULSE          (2 << 21)
2388 #define   PORTD_HOTPLUG_INT_SHORT_PULSE         (1 << 21)
2389 #define   PORTC_HOTPLUG_INT_STATUS              (3 << 19)
2390 #define   PORTC_HOTPLUG_INT_LONG_PULSE          (2 << 19)
2391 #define   PORTC_HOTPLUG_INT_SHORT_PULSE         (1 << 19)
2392 #define   PORTB_HOTPLUG_INT_STATUS              (3 << 17)
2393 #define   PORTB_HOTPLUG_INT_LONG_PULSE          (2 << 17)
2394 #define   PORTB_HOTPLUG_INT_SHORT_PLUSE         (1 << 17)
2395 /* CRT/TV common between gen3+ */
2396 #define   CRT_HOTPLUG_INT_STATUS                (1 << 11)
2397 #define   TV_HOTPLUG_INT_STATUS                 (1 << 10)
2398 #define   CRT_HOTPLUG_MONITOR_MASK              (3 << 8)
2399 #define   CRT_HOTPLUG_MONITOR_COLOR             (3 << 8)
2400 #define   CRT_HOTPLUG_MONITOR_MONO              (2 << 8)
2401 #define   CRT_HOTPLUG_MONITOR_NONE              (0 << 8)
2402 #define   DP_AUX_CHANNEL_D_INT_STATUS_G4X       (1 << 6)
2403 #define   DP_AUX_CHANNEL_C_INT_STATUS_G4X       (1 << 5)
2404 #define   DP_AUX_CHANNEL_B_INT_STATUS_G4X       (1 << 4)
2405 #define   DP_AUX_CHANNEL_MASK_INT_STATUS_G4X    (7 << 4)
2406
2407 /* SDVO is different across gen3/4 */
2408 #define   SDVOC_HOTPLUG_INT_STATUS_G4X          (1 << 3)
2409 #define   SDVOB_HOTPLUG_INT_STATUS_G4X          (1 << 2)
2410 /*
2411  * Bspec seems to be seriously misleaded about the SDVO hpd bits on i965g/gm,
2412  * since reality corrobates that they're the same as on gen3. But keep these
2413  * bits here (and the comment!) to help any other lost wanderers back onto the
2414  * right tracks.
2415  */
2416 #define   SDVOC_HOTPLUG_INT_STATUS_I965         (3 << 4)
2417 #define   SDVOB_HOTPLUG_INT_STATUS_I965         (3 << 2)
2418 #define   SDVOC_HOTPLUG_INT_STATUS_I915         (1 << 7)
2419 #define   SDVOB_HOTPLUG_INT_STATUS_I915         (1 << 6)
2420 #define   HOTPLUG_INT_STATUS_G4X                (CRT_HOTPLUG_INT_STATUS | \
2421                                                  SDVOB_HOTPLUG_INT_STATUS_G4X | \
2422                                                  SDVOC_HOTPLUG_INT_STATUS_G4X | \
2423                                                  PORTB_HOTPLUG_INT_STATUS | \
2424                                                  PORTC_HOTPLUG_INT_STATUS | \
2425                                                  PORTD_HOTPLUG_INT_STATUS)
2426
2427 #define HOTPLUG_INT_STATUS_I915                 (CRT_HOTPLUG_INT_STATUS | \
2428                                                  SDVOB_HOTPLUG_INT_STATUS_I915 | \
2429                                                  SDVOC_HOTPLUG_INT_STATUS_I915 | \
2430                                                  PORTB_HOTPLUG_INT_STATUS | \
2431                                                  PORTC_HOTPLUG_INT_STATUS | \
2432                                                  PORTD_HOTPLUG_INT_STATUS)
2433
2434 /* SDVO and HDMI port control.
2435  * The same register may be used for SDVO or HDMI */
2436 #define _GEN3_SDVOB     0x61140
2437 #define _GEN3_SDVOC     0x61160
2438 #define GEN3_SDVOB      _MMIO(_GEN3_SDVOB)
2439 #define GEN3_SDVOC      _MMIO(_GEN3_SDVOC)
2440 #define GEN4_HDMIB      GEN3_SDVOB
2441 #define GEN4_HDMIC      GEN3_SDVOC
2442 #define VLV_HDMIB       _MMIO(VLV_DISPLAY_BASE + 0x61140)
2443 #define VLV_HDMIC       _MMIO(VLV_DISPLAY_BASE + 0x61160)
2444 #define CHV_HDMID       _MMIO(VLV_DISPLAY_BASE + 0x6116C)
2445 #define PCH_SDVOB       _MMIO(0xe1140)
2446 #define PCH_HDMIB       PCH_SDVOB
2447 #define PCH_HDMIC       _MMIO(0xe1150)
2448 #define PCH_HDMID       _MMIO(0xe1160)
2449
2450 #define PORT_DFT_I9XX                           _MMIO(0x61150)
2451 #define   DC_BALANCE_RESET                      (1 << 25)
2452 #define PORT_DFT2_G4X           _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61154)
2453 #define   DC_BALANCE_RESET_VLV                  (1 << 31)
2454 #define   PIPE_SCRAMBLE_RESET_MASK              ((1 << 14) | (0x3 << 0))
2455 #define   PIPE_C_SCRAMBLE_RESET                 REG_BIT(14) /* chv */
2456 #define   PIPE_B_SCRAMBLE_RESET                 REG_BIT(1)
2457 #define   PIPE_A_SCRAMBLE_RESET                 REG_BIT(0)
2458
2459 /* Gen 3 SDVO bits: */
2460 #define   SDVO_ENABLE                           (1 << 31)
2461 #define   SDVO_PIPE_SEL_SHIFT                   30
2462 #define   SDVO_PIPE_SEL_MASK                    (1 << 30)
2463 #define   SDVO_PIPE_SEL(pipe)                   ((pipe) << 30)
2464 #define   SDVO_STALL_SELECT                     (1 << 29)
2465 #define   SDVO_INTERRUPT_ENABLE                 (1 << 26)
2466 /*
2467  * 915G/GM SDVO pixel multiplier.
2468  * Programmed value is multiplier - 1, up to 5x.
2469  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
2470  */
2471 #define   SDVO_PORT_MULTIPLY_MASK               (7 << 23)
2472 #define   SDVO_PORT_MULTIPLY_SHIFT              23
2473 #define   SDVO_PHASE_SELECT_MASK                (15 << 19)
2474 #define   SDVO_PHASE_SELECT_DEFAULT             (6 << 19)
2475 #define   SDVO_CLOCK_OUTPUT_INVERT              (1 << 18)
2476 #define   SDVOC_GANG_MODE                       (1 << 16) /* Port C only */
2477 #define   SDVO_BORDER_ENABLE                    (1 << 7) /* SDVO only */
2478 #define   SDVOB_PCIE_CONCURRENCY                (1 << 3) /* Port B only */
2479 #define   SDVO_DETECTED                         (1 << 2)
2480 /* Bits to be preserved when writing */
2481 #define   SDVOB_PRESERVE_MASK ((1 << 17) | (1 << 16) | (1 << 14) | \
2482                                SDVO_INTERRUPT_ENABLE)
2483 #define   SDVOC_PRESERVE_MASK ((1 << 17) | SDVO_INTERRUPT_ENABLE)
2484
2485 /* Gen 4 SDVO/HDMI bits: */
2486 #define   SDVO_COLOR_FORMAT_8bpc                (0 << 26)
2487 #define   SDVO_COLOR_FORMAT_MASK                (7 << 26)
2488 #define   SDVO_ENCODING_SDVO                    (0 << 10)
2489 #define   SDVO_ENCODING_HDMI                    (2 << 10)
2490 #define   HDMI_MODE_SELECT_HDMI                 (1 << 9) /* HDMI only */
2491 #define   HDMI_MODE_SELECT_DVI                  (0 << 9) /* HDMI only */
2492 #define   HDMI_COLOR_RANGE_16_235               (1 << 8) /* HDMI only */
2493 #define   HDMI_AUDIO_ENABLE                     (1 << 6) /* HDMI only */
2494 /* VSYNC/HSYNC bits new with 965, default is to be set */
2495 #define   SDVO_VSYNC_ACTIVE_HIGH                (1 << 4)
2496 #define   SDVO_HSYNC_ACTIVE_HIGH                (1 << 3)
2497
2498 /* Gen 5 (IBX) SDVO/HDMI bits: */
2499 #define   HDMI_COLOR_FORMAT_12bpc               (3 << 26) /* HDMI only */
2500 #define   SDVOB_HOTPLUG_ENABLE                  (1 << 23) /* SDVO only */
2501
2502 /* Gen 6 (CPT) SDVO/HDMI bits: */
2503 #define   SDVO_PIPE_SEL_SHIFT_CPT               29
2504 #define   SDVO_PIPE_SEL_MASK_CPT                (3 << 29)
2505 #define   SDVO_PIPE_SEL_CPT(pipe)               ((pipe) << 29)
2506
2507 /* CHV SDVO/HDMI bits: */
2508 #define   SDVO_PIPE_SEL_SHIFT_CHV               24
2509 #define   SDVO_PIPE_SEL_MASK_CHV                (3 << 24)
2510 #define   SDVO_PIPE_SEL_CHV(pipe)               ((pipe) << 24)
2511
2512 /* Video Data Island Packet control */
2513 #define VIDEO_DIP_DATA          _MMIO(0x61178)
2514 /* Read the description of VIDEO_DIP_DATA (before Haswell) or VIDEO_DIP_ECC
2515  * (Haswell and newer) to see which VIDEO_DIP_DATA byte corresponds to each byte
2516  * of the infoframe structure specified by CEA-861. */
2517 #define   VIDEO_DIP_DATA_SIZE   32
2518 #define   VIDEO_DIP_GMP_DATA_SIZE       36
2519 #define   VIDEO_DIP_VSC_DATA_SIZE       36
2520 #define   VIDEO_DIP_PPS_DATA_SIZE       132
2521 #define VIDEO_DIP_CTL           _MMIO(0x61170)
2522 /* Pre HSW: */
2523 #define   VIDEO_DIP_ENABLE              (1 << 31)
2524 #define   VIDEO_DIP_PORT(port)          ((port) << 29)
2525 #define   VIDEO_DIP_PORT_MASK           (3 << 29)
2526 #define   VIDEO_DIP_ENABLE_GCP          (1 << 25) /* ilk+ */
2527 #define   VIDEO_DIP_ENABLE_AVI          (1 << 21)
2528 #define   VIDEO_DIP_ENABLE_VENDOR       (2 << 21)
2529 #define   VIDEO_DIP_ENABLE_GAMUT        (4 << 21) /* ilk+ */
2530 #define   VIDEO_DIP_ENABLE_SPD          (8 << 21)
2531 #define   VIDEO_DIP_SELECT_AVI          (0 << 19)
2532 #define   VIDEO_DIP_SELECT_VENDOR       (1 << 19)
2533 #define   VIDEO_DIP_SELECT_GAMUT        (2 << 19)
2534 #define   VIDEO_DIP_SELECT_SPD          (3 << 19)
2535 #define   VIDEO_DIP_SELECT_MASK         (3 << 19)
2536 #define   VIDEO_DIP_FREQ_ONCE           (0 << 16)
2537 #define   VIDEO_DIP_FREQ_VSYNC          (1 << 16)
2538 #define   VIDEO_DIP_FREQ_2VSYNC         (2 << 16)
2539 #define   VIDEO_DIP_FREQ_MASK           (3 << 16)
2540 /* HSW and later: */
2541 #define   VIDEO_DIP_ENABLE_DRM_GLK      (1 << 28)
2542 #define   PSR_VSC_BIT_7_SET             (1 << 27)
2543 #define   VSC_SELECT_MASK               (0x3 << 25)
2544 #define   VSC_SELECT_SHIFT              25
2545 #define   VSC_DIP_HW_HEA_DATA           (0 << 25)
2546 #define   VSC_DIP_HW_HEA_SW_DATA        (1 << 25)
2547 #define   VSC_DIP_HW_DATA_SW_HEA        (2 << 25)
2548 #define   VSC_DIP_SW_HEA_DATA           (3 << 25)
2549 #define   VDIP_ENABLE_PPS               (1 << 24)
2550 #define   VIDEO_DIP_ENABLE_VSC_HSW      (1 << 20)
2551 #define   VIDEO_DIP_ENABLE_GCP_HSW      (1 << 16)
2552 #define   VIDEO_DIP_ENABLE_AVI_HSW      (1 << 12)
2553 #define   VIDEO_DIP_ENABLE_VS_HSW       (1 << 8)
2554 #define   VIDEO_DIP_ENABLE_GMP_HSW      (1 << 4)
2555 #define   VIDEO_DIP_ENABLE_SPD_HSW      (1 << 0)
2556
2557 /* Panel power sequencing */
2558 #define PPS_BASE                        0x61200
2559 #define VLV_PPS_BASE                    (VLV_DISPLAY_BASE + PPS_BASE)
2560 #define PCH_PPS_BASE                    0xC7200
2561
2562 #define _MMIO_PPS(pps_idx, reg)         _MMIO(dev_priv->display.pps.mmio_base - \
2563                                               PPS_BASE + (reg) +        \
2564                                               (pps_idx) * 0x100)
2565
2566 #define _PP_STATUS                      0x61200
2567 #define PP_STATUS(pps_idx)              _MMIO_PPS(pps_idx, _PP_STATUS)
2568 #define   PP_ON                         REG_BIT(31)
2569 /*
2570  * Indicates that all dependencies of the panel are on:
2571  *
2572  * - PLL enabled
2573  * - pipe enabled
2574  * - LVDS/DVOB/DVOC on
2575  */
2576 #define   PP_READY                      REG_BIT(30)
2577 #define   PP_SEQUENCE_MASK              REG_GENMASK(29, 28)
2578 #define   PP_SEQUENCE_NONE              REG_FIELD_PREP(PP_SEQUENCE_MASK, 0)
2579 #define   PP_SEQUENCE_POWER_UP          REG_FIELD_PREP(PP_SEQUENCE_MASK, 1)
2580 #define   PP_SEQUENCE_POWER_DOWN        REG_FIELD_PREP(PP_SEQUENCE_MASK, 2)
2581 #define   PP_CYCLE_DELAY_ACTIVE         REG_BIT(27)
2582 #define   PP_SEQUENCE_STATE_MASK        REG_GENMASK(3, 0)
2583 #define   PP_SEQUENCE_STATE_OFF_IDLE    REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x0)
2584 #define   PP_SEQUENCE_STATE_OFF_S0_1    REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x1)
2585 #define   PP_SEQUENCE_STATE_OFF_S0_2    REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x2)
2586 #define   PP_SEQUENCE_STATE_OFF_S0_3    REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x3)
2587 #define   PP_SEQUENCE_STATE_ON_IDLE     REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x8)
2588 #define   PP_SEQUENCE_STATE_ON_S1_1     REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0x9)
2589 #define   PP_SEQUENCE_STATE_ON_S1_2     REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xa)
2590 #define   PP_SEQUENCE_STATE_ON_S1_3     REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xb)
2591 #define   PP_SEQUENCE_STATE_RESET       REG_FIELD_PREP(PP_SEQUENCE_STATE_MASK, 0xf)
2592
2593 #define _PP_CONTROL                     0x61204
2594 #define PP_CONTROL(pps_idx)             _MMIO_PPS(pps_idx, _PP_CONTROL)
2595 #define  PANEL_UNLOCK_MASK              REG_GENMASK(31, 16)
2596 #define  PANEL_UNLOCK_REGS              REG_FIELD_PREP(PANEL_UNLOCK_MASK, 0xabcd)
2597 #define  BXT_POWER_CYCLE_DELAY_MASK     REG_GENMASK(8, 4)
2598 #define  EDP_FORCE_VDD                  REG_BIT(3)
2599 #define  EDP_BLC_ENABLE                 REG_BIT(2)
2600 #define  PANEL_POWER_RESET              REG_BIT(1)
2601 #define  PANEL_POWER_ON                 REG_BIT(0)
2602
2603 #define _PP_ON_DELAYS                   0x61208
2604 #define PP_ON_DELAYS(pps_idx)           _MMIO_PPS(pps_idx, _PP_ON_DELAYS)
2605 #define  PANEL_PORT_SELECT_MASK         REG_GENMASK(31, 30)
2606 #define  PANEL_PORT_SELECT_LVDS         REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 0)
2607 #define  PANEL_PORT_SELECT_DPA          REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 1)
2608 #define  PANEL_PORT_SELECT_DPC          REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 2)
2609 #define  PANEL_PORT_SELECT_DPD          REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, 3)
2610 #define  PANEL_PORT_SELECT_VLV(port)    REG_FIELD_PREP(PANEL_PORT_SELECT_MASK, port)
2611 #define  PANEL_POWER_UP_DELAY_MASK      REG_GENMASK(28, 16)
2612 #define  PANEL_LIGHT_ON_DELAY_MASK      REG_GENMASK(12, 0)
2613
2614 #define _PP_OFF_DELAYS                  0x6120C
2615 #define PP_OFF_DELAYS(pps_idx)          _MMIO_PPS(pps_idx, _PP_OFF_DELAYS)
2616 #define  PANEL_POWER_DOWN_DELAY_MASK    REG_GENMASK(28, 16)
2617 #define  PANEL_LIGHT_OFF_DELAY_MASK     REG_GENMASK(12, 0)
2618
2619 #define _PP_DIVISOR                     0x61210
2620 #define PP_DIVISOR(pps_idx)             _MMIO_PPS(pps_idx, _PP_DIVISOR)
2621 #define  PP_REFERENCE_DIVIDER_MASK      REG_GENMASK(31, 8)
2622 #define  PANEL_POWER_CYCLE_DELAY_MASK   REG_GENMASK(4, 0)
2623
2624 /* Panel fitting */
2625 #define PFIT_CONTROL    _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61230)
2626 #define   PFIT_ENABLE           (1 << 31)
2627 #define   PFIT_PIPE_MASK        (3 << 29)
2628 #define   PFIT_PIPE_SHIFT       29
2629 #define   PFIT_PIPE(pipe)       ((pipe) << 29)
2630 #define   VERT_INTERP_DISABLE   (0 << 10)
2631 #define   VERT_INTERP_BILINEAR  (1 << 10)
2632 #define   VERT_INTERP_MASK      (3 << 10)
2633 #define   VERT_AUTO_SCALE       (1 << 9)
2634 #define   HORIZ_INTERP_DISABLE  (0 << 6)
2635 #define   HORIZ_INTERP_BILINEAR (1 << 6)
2636 #define   HORIZ_INTERP_MASK     (3 << 6)
2637 #define   HORIZ_AUTO_SCALE      (1 << 5)
2638 #define   PANEL_8TO6_DITHER_ENABLE (1 << 3)
2639 #define   PFIT_FILTER_FUZZY     (0 << 24)
2640 #define   PFIT_SCALING_AUTO     (0 << 26)
2641 #define   PFIT_SCALING_PROGRAMMED (1 << 26)
2642 #define   PFIT_SCALING_PILLAR   (2 << 26)
2643 #define   PFIT_SCALING_LETTER   (3 << 26)
2644 #define PFIT_PGM_RATIOS _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61234)
2645 /* Pre-965 */
2646 #define         PFIT_VERT_SCALE_SHIFT           20
2647 #define         PFIT_VERT_SCALE_MASK            0xfff00000
2648 #define         PFIT_HORIZ_SCALE_SHIFT          4
2649 #define         PFIT_HORIZ_SCALE_MASK           0x0000fff0
2650 /* 965+ */
2651 #define         PFIT_VERT_SCALE_SHIFT_965       16
2652 #define         PFIT_VERT_SCALE_MASK_965        0x1fff0000
2653 #define         PFIT_HORIZ_SCALE_SHIFT_965      0
2654 #define         PFIT_HORIZ_SCALE_MASK_965       0x00001fff
2655
2656 #define PFIT_AUTO_RATIOS _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x61238)
2657
2658 #define PCH_GTC_CTL             _MMIO(0xe7000)
2659 #define   PCH_GTC_ENABLE        (1 << 31)
2660
2661 /* TV port control */
2662 #define TV_CTL                  _MMIO(0x68000)
2663 /* Enables the TV encoder */
2664 # define TV_ENC_ENABLE                  (1 << 31)
2665 /* Sources the TV encoder input from pipe B instead of A. */
2666 # define TV_ENC_PIPE_SEL_SHIFT          30
2667 # define TV_ENC_PIPE_SEL_MASK           (1 << 30)
2668 # define TV_ENC_PIPE_SEL(pipe)          ((pipe) << 30)
2669 /* Outputs composite video (DAC A only) */
2670 # define TV_ENC_OUTPUT_COMPOSITE        (0 << 28)
2671 /* Outputs SVideo video (DAC B/C) */
2672 # define TV_ENC_OUTPUT_SVIDEO           (1 << 28)
2673 /* Outputs Component video (DAC A/B/C) */
2674 # define TV_ENC_OUTPUT_COMPONENT        (2 << 28)
2675 /* Outputs Composite and SVideo (DAC A/B/C) */
2676 # define TV_ENC_OUTPUT_SVIDEO_COMPOSITE (3 << 28)
2677 # define TV_TRILEVEL_SYNC               (1 << 21)
2678 /* Enables slow sync generation (945GM only) */
2679 # define TV_SLOW_SYNC                   (1 << 20)
2680 /* Selects 4x oversampling for 480i and 576p */
2681 # define TV_OVERSAMPLE_4X               (0 << 18)
2682 /* Selects 2x oversampling for 720p and 1080i */
2683 # define TV_OVERSAMPLE_2X               (1 << 18)
2684 /* Selects no oversampling for 1080p */
2685 # define TV_OVERSAMPLE_NONE             (2 << 18)
2686 /* Selects 8x oversampling */
2687 # define TV_OVERSAMPLE_8X               (3 << 18)
2688 # define TV_OVERSAMPLE_MASK             (3 << 18)
2689 /* Selects progressive mode rather than interlaced */
2690 # define TV_PROGRESSIVE                 (1 << 17)
2691 /* Sets the colorburst to PAL mode.  Required for non-M PAL modes. */
2692 # define TV_PAL_BURST                   (1 << 16)
2693 /* Field for setting delay of Y compared to C */
2694 # define TV_YC_SKEW_MASK                (7 << 12)
2695 /* Enables a fix for 480p/576p standard definition modes on the 915GM only */
2696 # define TV_ENC_SDP_FIX                 (1 << 11)
2697 /*
2698  * Enables a fix for the 915GM only.
2699  *
2700  * Not sure what it does.
2701  */
2702 # define TV_ENC_C0_FIX                  (1 << 10)
2703 /* Bits that must be preserved by software */
2704 # define TV_CTL_SAVE                    ((1 << 11) | (3 << 9) | (7 << 6) | 0xf)
2705 # define TV_FUSE_STATE_MASK             (3 << 4)
2706 /* Read-only state that reports all features enabled */
2707 # define TV_FUSE_STATE_ENABLED          (0 << 4)
2708 /* Read-only state that reports that Macrovision is disabled in hardware*/
2709 # define TV_FUSE_STATE_NO_MACROVISION   (1 << 4)
2710 /* Read-only state that reports that TV-out is disabled in hardware. */
2711 # define TV_FUSE_STATE_DISABLED         (2 << 4)
2712 /* Normal operation */
2713 # define TV_TEST_MODE_NORMAL            (0 << 0)
2714 /* Encoder test pattern 1 - combo pattern */
2715 # define TV_TEST_MODE_PATTERN_1         (1 << 0)
2716 /* Encoder test pattern 2 - full screen vertical 75% color bars */
2717 # define TV_TEST_MODE_PATTERN_2         (2 << 0)
2718 /* Encoder test pattern 3 - full screen horizontal 75% color bars */
2719 # define TV_TEST_MODE_PATTERN_3         (3 << 0)
2720 /* Encoder test pattern 4 - random noise */
2721 # define TV_TEST_MODE_PATTERN_4         (4 << 0)
2722 /* Encoder test pattern 5 - linear color ramps */
2723 # define TV_TEST_MODE_PATTERN_5         (5 << 0)
2724 /*
2725  * This test mode forces the DACs to 50% of full output.
2726  *
2727  * This is used for load detection in combination with TVDAC_SENSE_MASK
2728  */
2729 # define TV_TEST_MODE_MONITOR_DETECT    (7 << 0)
2730 # define TV_TEST_MODE_MASK              (7 << 0)
2731
2732 #define TV_DAC                  _MMIO(0x68004)
2733 # define TV_DAC_SAVE            0x00ffff00
2734 /*
2735  * Reports that DAC state change logic has reported change (RO).
2736  *
2737  * This gets cleared when TV_DAC_STATE_EN is cleared
2738 */
2739 # define TVDAC_STATE_CHG                (1 << 31)
2740 # define TVDAC_SENSE_MASK               (7 << 28)
2741 /* Reports that DAC A voltage is above the detect threshold */
2742 # define TVDAC_A_SENSE                  (1 << 30)
2743 /* Reports that DAC B voltage is above the detect threshold */
2744 # define TVDAC_B_SENSE                  (1 << 29)
2745 /* Reports that DAC C voltage is above the detect threshold */
2746 # define TVDAC_C_SENSE                  (1 << 28)
2747 /*
2748  * Enables DAC state detection logic, for load-based TV detection.
2749  *
2750  * The PLL of the chosen pipe (in TV_CTL) must be running, and the encoder set
2751  * to off, for load detection to work.
2752  */
2753 # define TVDAC_STATE_CHG_EN             (1 << 27)
2754 /* Sets the DAC A sense value to high */
2755 # define TVDAC_A_SENSE_CTL              (1 << 26)
2756 /* Sets the DAC B sense value to high */
2757 # define TVDAC_B_SENSE_CTL              (1 << 25)
2758 /* Sets the DAC C sense value to high */
2759 # define TVDAC_C_SENSE_CTL              (1 << 24)
2760 /* Overrides the ENC_ENABLE and DAC voltage levels */
2761 # define DAC_CTL_OVERRIDE               (1 << 7)
2762 /* Sets the slew rate.  Must be preserved in software */
2763 # define ENC_TVDAC_SLEW_FAST            (1 << 6)
2764 # define DAC_A_1_3_V                    (0 << 4)
2765 # define DAC_A_1_1_V                    (1 << 4)
2766 # define DAC_A_0_7_V                    (2 << 4)
2767 # define DAC_A_MASK                     (3 << 4)
2768 # define DAC_B_1_3_V                    (0 << 2)
2769 # define DAC_B_1_1_V                    (1 << 2)
2770 # define DAC_B_0_7_V                    (2 << 2)
2771 # define DAC_B_MASK                     (3 << 2)
2772 # define DAC_C_1_3_V                    (0 << 0)
2773 # define DAC_C_1_1_V                    (1 << 0)
2774 # define DAC_C_0_7_V                    (2 << 0)
2775 # define DAC_C_MASK                     (3 << 0)
2776
2777 /*
2778  * CSC coefficients are stored in a floating point format with 9 bits of
2779  * mantissa and 2 or 3 bits of exponent.  The exponent is represented as 2**-n,
2780  * where 2-bit exponents are unsigned n, and 3-bit exponents are signed n with
2781  * -1 (0x3) being the only legal negative value.
2782  */
2783 #define TV_CSC_Y                _MMIO(0x68010)
2784 # define TV_RY_MASK                     0x07ff0000
2785 # define TV_RY_SHIFT                    16
2786 # define TV_GY_MASK                     0x00000fff
2787 # define TV_GY_SHIFT                    0
2788
2789 #define TV_CSC_Y2               _MMIO(0x68014)
2790 # define TV_BY_MASK                     0x07ff0000
2791 # define TV_BY_SHIFT                    16
2792 /*
2793  * Y attenuation for component video.
2794  *
2795  * Stored in 1.9 fixed point.
2796  */
2797 # define TV_AY_MASK                     0x000003ff
2798 # define TV_AY_SHIFT                    0
2799
2800 #define TV_CSC_U                _MMIO(0x68018)
2801 # define TV_RU_MASK                     0x07ff0000
2802 # define TV_RU_SHIFT                    16
2803 # define TV_GU_MASK                     0x000007ff
2804 # define TV_GU_SHIFT                    0
2805
2806 #define TV_CSC_U2               _MMIO(0x6801c)
2807 # define TV_BU_MASK                     0x07ff0000
2808 # define TV_BU_SHIFT                    16
2809 /*
2810  * U attenuation for component video.
2811  *
2812  * Stored in 1.9 fixed point.
2813  */
2814 # define TV_AU_MASK                     0x000003ff
2815 # define TV_AU_SHIFT                    0
2816
2817 #define TV_CSC_V                _MMIO(0x68020)
2818 # define TV_RV_MASK                     0x0fff0000
2819 # define TV_RV_SHIFT                    16
2820 # define TV_GV_MASK                     0x000007ff
2821 # define TV_GV_SHIFT                    0
2822
2823 #define TV_CSC_V2               _MMIO(0x68024)
2824 # define TV_BV_MASK                     0x07ff0000
2825 # define TV_BV_SHIFT                    16
2826 /*
2827  * V attenuation for component video.
2828  *
2829  * Stored in 1.9 fixed point.
2830  */
2831 # define TV_AV_MASK                     0x000007ff
2832 # define TV_AV_SHIFT                    0
2833
2834 #define TV_CLR_KNOBS            _MMIO(0x68028)
2835 /* 2s-complement brightness adjustment */
2836 # define TV_BRIGHTNESS_MASK             0xff000000
2837 # define TV_BRIGHTNESS_SHIFT            24
2838 /* Contrast adjustment, as a 2.6 unsigned floating point number */
2839 # define TV_CONTRAST_MASK               0x00ff0000
2840 # define TV_CONTRAST_SHIFT              16
2841 /* Saturation adjustment, as a 2.6 unsigned floating point number */
2842 # define TV_SATURATION_MASK             0x0000ff00
2843 # define TV_SATURATION_SHIFT            8
2844 /* Hue adjustment, as an integer phase angle in degrees */
2845 # define TV_HUE_MASK                    0x000000ff
2846 # define TV_HUE_SHIFT                   0
2847
2848 #define TV_CLR_LEVEL            _MMIO(0x6802c)
2849 /* Controls the DAC level for black */
2850 # define TV_BLACK_LEVEL_MASK            0x01ff0000
2851 # define TV_BLACK_LEVEL_SHIFT           16
2852 /* Controls the DAC level for blanking */
2853 # define TV_BLANK_LEVEL_MASK            0x000001ff
2854 # define TV_BLANK_LEVEL_SHIFT           0
2855
2856 #define TV_H_CTL_1              _MMIO(0x68030)
2857 /* Number of pixels in the hsync. */
2858 # define TV_HSYNC_END_MASK              0x1fff0000
2859 # define TV_HSYNC_END_SHIFT             16
2860 /* Total number of pixels minus one in the line (display and blanking). */
2861 # define TV_HTOTAL_MASK                 0x00001fff
2862 # define TV_HTOTAL_SHIFT                0
2863
2864 #define TV_H_CTL_2              _MMIO(0x68034)
2865 /* Enables the colorburst (needed for non-component color) */
2866 # define TV_BURST_ENA                   (1 << 31)
2867 /* Offset of the colorburst from the start of hsync, in pixels minus one. */
2868 # define TV_HBURST_START_SHIFT          16
2869 # define TV_HBURST_START_MASK           0x1fff0000
2870 /* Length of the colorburst */
2871 # define TV_HBURST_LEN_SHIFT            0
2872 # define TV_HBURST_LEN_MASK             0x0001fff
2873
2874 #define TV_H_CTL_3              _MMIO(0x68038)
2875 /* End of hblank, measured in pixels minus one from start of hsync */
2876 # define TV_HBLANK_END_SHIFT            16
2877 # define TV_HBLANK_END_MASK             0x1fff0000
2878 /* Start of hblank, measured in pixels minus one from start of hsync */
2879 # define TV_HBLANK_START_SHIFT          0
2880 # define TV_HBLANK_START_MASK           0x0001fff
2881
2882 #define TV_V_CTL_1              _MMIO(0x6803c)
2883 /* XXX */
2884 # define TV_NBR_END_SHIFT               16
2885 # define TV_NBR_END_MASK                0x07ff0000
2886 /* XXX */
2887 # define TV_VI_END_F1_SHIFT             8
2888 # define TV_VI_END_F1_MASK              0x00003f00
2889 /* XXX */
2890 # define TV_VI_END_F2_SHIFT             0
2891 # define TV_VI_END_F2_MASK              0x0000003f
2892
2893 #define TV_V_CTL_2              _MMIO(0x68040)
2894 /* Length of vsync, in half lines */
2895 # define TV_VSYNC_LEN_MASK              0x07ff0000
2896 # define TV_VSYNC_LEN_SHIFT             16
2897 /* Offset of the start of vsync in field 1, measured in one less than the
2898  * number of half lines.
2899  */
2900 # define TV_VSYNC_START_F1_MASK         0x00007f00
2901 # define TV_VSYNC_START_F1_SHIFT        8
2902 /*
2903  * Offset of the start of vsync in field 2, measured in one less than the
2904  * number of half lines.
2905  */
2906 # define TV_VSYNC_START_F2_MASK         0x0000007f
2907 # define TV_VSYNC_START_F2_SHIFT        0
2908
2909 #define TV_V_CTL_3              _MMIO(0x68044)
2910 /* Enables generation of the equalization signal */
2911 # define TV_EQUAL_ENA                   (1 << 31)
2912 /* Length of vsync, in half lines */
2913 # define TV_VEQ_LEN_MASK                0x007f0000
2914 # define TV_VEQ_LEN_SHIFT               16
2915 /* Offset of the start of equalization in field 1, measured in one less than
2916  * the number of half lines.
2917  */
2918 # define TV_VEQ_START_F1_MASK           0x0007f00
2919 # define TV_VEQ_START_F1_SHIFT          8
2920 /*
2921  * Offset of the start of equalization in field 2, measured in one less than
2922  * the number of half lines.
2923  */
2924 # define TV_VEQ_START_F2_MASK           0x000007f
2925 # define TV_VEQ_START_F2_SHIFT          0
2926
2927 #define TV_V_CTL_4              _MMIO(0x68048)
2928 /*
2929  * Offset to start of vertical colorburst, measured in one less than the
2930  * number of lines from vertical start.
2931  */
2932 # define TV_VBURST_START_F1_MASK        0x003f0000
2933 # define TV_VBURST_START_F1_SHIFT       16
2934 /*
2935  * Offset to the end of vertical colorburst, measured in one less than the
2936  * number of lines from the start of NBR.
2937  */
2938 # define TV_VBURST_END_F1_MASK          0x000000ff
2939 # define TV_VBURST_END_F1_SHIFT         0
2940
2941 #define TV_V_CTL_5              _MMIO(0x6804c)
2942 /*
2943  * Offset to start of vertical colorburst, measured in one less than the
2944  * number of lines from vertical start.
2945  */
2946 # define TV_VBURST_START_F2_MASK        0x003f0000
2947 # define TV_VBURST_START_F2_SHIFT       16
2948 /*
2949  * Offset to the end of vertical colorburst, measured in one less than the
2950  * number of lines from the start of NBR.
2951  */
2952 # define TV_VBURST_END_F2_MASK          0x000000ff
2953 # define TV_VBURST_END_F2_SHIFT         0
2954
2955 #define TV_V_CTL_6              _MMIO(0x68050)
2956 /*
2957  * Offset to start of vertical colorburst, measured in one less than the
2958  * number of lines from vertical start.
2959  */
2960 # define TV_VBURST_START_F3_MASK        0x003f0000
2961 # define TV_VBURST_START_F3_SHIFT       16
2962 /*
2963  * Offset to the end of vertical colorburst, measured in one less than the
2964  * number of lines from the start of NBR.
2965  */
2966 # define TV_VBURST_END_F3_MASK          0x000000ff
2967 # define TV_VBURST_END_F3_SHIFT         0
2968
2969 #define TV_V_CTL_7              _MMIO(0x68054)
2970 /*
2971  * Offset to start of vertical colorburst, measured in one less than the
2972  * number of lines from vertical start.
2973  */
2974 # define TV_VBURST_START_F4_MASK        0x003f0000
2975 # define TV_VBURST_START_F4_SHIFT       16
2976 /*
2977  * Offset to the end of vertical colorburst, measured in one less than the
2978  * number of lines from the start of NBR.
2979  */
2980 # define TV_VBURST_END_F4_MASK          0x000000ff
2981 # define TV_VBURST_END_F4_SHIFT         0
2982
2983 #define TV_SC_CTL_1             _MMIO(0x68060)
2984 /* Turns on the first subcarrier phase generation DDA */
2985 # define TV_SC_DDA1_EN                  (1 << 31)
2986 /* Turns on the first subcarrier phase generation DDA */
2987 # define TV_SC_DDA2_EN                  (1 << 30)
2988 /* Turns on the first subcarrier phase generation DDA */
2989 # define TV_SC_DDA3_EN                  (1 << 29)
2990 /* Sets the subcarrier DDA to reset frequency every other field */
2991 # define TV_SC_RESET_EVERY_2            (0 << 24)
2992 /* Sets the subcarrier DDA to reset frequency every fourth field */
2993 # define TV_SC_RESET_EVERY_4            (1 << 24)
2994 /* Sets the subcarrier DDA to reset frequency every eighth field */
2995 # define TV_SC_RESET_EVERY_8            (2 << 24)
2996 /* Sets the subcarrier DDA to never reset the frequency */
2997 # define TV_SC_RESET_NEVER              (3 << 24)
2998 /* Sets the peak amplitude of the colorburst.*/
2999 # define TV_BURST_LEVEL_MASK            0x00ff0000
3000 # define TV_BURST_LEVEL_SHIFT           16
3001 /* Sets the increment of the first subcarrier phase generation DDA */
3002 # define TV_SCDDA1_INC_MASK             0x00000fff
3003 # define TV_SCDDA1_INC_SHIFT            0
3004
3005 #define TV_SC_CTL_2             _MMIO(0x68064)
3006 /* Sets the rollover for the second subcarrier phase generation DDA */
3007 # define TV_SCDDA2_SIZE_MASK            0x7fff0000
3008 # define TV_SCDDA2_SIZE_SHIFT           16
3009 /* Sets the increent of the second subcarrier phase generation DDA */
3010 # define TV_SCDDA2_INC_MASK             0x00007fff
3011 # define TV_SCDDA2_INC_SHIFT            0
3012
3013 #define TV_SC_CTL_3             _MMIO(0x68068)
3014 /* Sets the rollover for the third subcarrier phase generation DDA */
3015 # define TV_SCDDA3_SIZE_MASK            0x7fff0000
3016 # define TV_SCDDA3_SIZE_SHIFT           16
3017 /* Sets the increent of the third subcarrier phase generation DDA */
3018 # define TV_SCDDA3_INC_MASK             0x00007fff
3019 # define TV_SCDDA3_INC_SHIFT            0
3020
3021 #define TV_WIN_POS              _MMIO(0x68070)
3022 /* X coordinate of the display from the start of horizontal active */
3023 # define TV_XPOS_MASK                   0x1fff0000
3024 # define TV_XPOS_SHIFT                  16
3025 /* Y coordinate of the display from the start of vertical active (NBR) */
3026 # define TV_YPOS_MASK                   0x00000fff
3027 # define TV_YPOS_SHIFT                  0
3028
3029 #define TV_WIN_SIZE             _MMIO(0x68074)
3030 /* Horizontal size of the display window, measured in pixels*/
3031 # define TV_XSIZE_MASK                  0x1fff0000
3032 # define TV_XSIZE_SHIFT                 16
3033 /*
3034  * Vertical size of the display window, measured in pixels.
3035  *
3036  * Must be even for interlaced modes.
3037  */
3038 # define TV_YSIZE_MASK                  0x00000fff
3039 # define TV_YSIZE_SHIFT                 0
3040
3041 #define TV_FILTER_CTL_1         _MMIO(0x68080)
3042 /*
3043  * Enables automatic scaling calculation.
3044  *
3045  * If set, the rest of the registers are ignored, and the calculated values can
3046  * be read back from the register.
3047  */
3048 # define TV_AUTO_SCALE                  (1 << 31)
3049 /*
3050  * Disables the vertical filter.
3051  *
3052  * This is required on modes more than 1024 pixels wide */
3053 # define TV_V_FILTER_BYPASS             (1 << 29)
3054 /* Enables adaptive vertical filtering */
3055 # define TV_VADAPT                      (1 << 28)
3056 # define TV_VADAPT_MODE_MASK            (3 << 26)
3057 /* Selects the least adaptive vertical filtering mode */
3058 # define TV_VADAPT_MODE_LEAST           (0 << 26)
3059 /* Selects the moderately adaptive vertical filtering mode */
3060 # define TV_VADAPT_MODE_MODERATE        (1 << 26)
3061 /* Selects the most adaptive vertical filtering mode */
3062 # define TV_VADAPT_MODE_MOST            (3 << 26)
3063 /*
3064  * Sets the horizontal scaling factor.
3065  *
3066  * This should be the fractional part of the horizontal scaling factor divided
3067  * by the oversampling rate.  TV_HSCALE should be less than 1, and set to:
3068  *
3069  * (src width - 1) / ((oversample * dest width) - 1)
3070  */
3071 # define TV_HSCALE_FRAC_MASK            0x00003fff
3072 # define TV_HSCALE_FRAC_SHIFT           0
3073
3074 #define TV_FILTER_CTL_2         _MMIO(0x68084)
3075 /*
3076  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
3077  *
3078  * TV_VSCALE should be (src height - 1) / ((interlace * dest height) - 1)
3079  */
3080 # define TV_VSCALE_INT_MASK             0x00038000
3081 # define TV_VSCALE_INT_SHIFT            15
3082 /*
3083  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
3084  *
3085  * \sa TV_VSCALE_INT_MASK
3086  */
3087 # define TV_VSCALE_FRAC_MASK            0x00007fff
3088 # define TV_VSCALE_FRAC_SHIFT           0
3089
3090 #define TV_FILTER_CTL_3         _MMIO(0x68088)
3091 /*
3092  * Sets the integer part of the 3.15 fixed-point vertical scaling factor.
3093  *
3094  * TV_VSCALE should be (src height - 1) / (1/4 * (dest height - 1))
3095  *
3096  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
3097  */
3098 # define TV_VSCALE_IP_INT_MASK          0x00038000
3099 # define TV_VSCALE_IP_INT_SHIFT         15
3100 /*
3101  * Sets the fractional part of the 3.15 fixed-point vertical scaling factor.
3102  *
3103  * For progressive modes, TV_VSCALE_IP_INT should be set to zeroes.
3104  *
3105  * \sa TV_VSCALE_IP_INT_MASK
3106  */
3107 # define TV_VSCALE_IP_FRAC_MASK         0x00007fff
3108 # define TV_VSCALE_IP_FRAC_SHIFT                0
3109
3110 #define TV_CC_CONTROL           _MMIO(0x68090)
3111 # define TV_CC_ENABLE                   (1 << 31)
3112 /*
3113  * Specifies which field to send the CC data in.
3114  *
3115  * CC data is usually sent in field 0.
3116  */
3117 # define TV_CC_FID_MASK                 (1 << 27)
3118 # define TV_CC_FID_SHIFT                27
3119 /* Sets the horizontal position of the CC data.  Usually 135. */
3120 # define TV_CC_HOFF_MASK                0x03ff0000
3121 # define TV_CC_HOFF_SHIFT               16
3122 /* Sets the vertical position of the CC data.  Usually 21 */
3123 # define TV_CC_LINE_MASK                0x0000003f
3124 # define TV_CC_LINE_SHIFT               0
3125
3126 #define TV_CC_DATA              _MMIO(0x68094)
3127 # define TV_CC_RDY                      (1 << 31)
3128 /* Second word of CC data to be transmitted. */
3129 # define TV_CC_DATA_2_MASK              0x007f0000
3130 # define TV_CC_DATA_2_SHIFT             16
3131 /* First word of CC data to be transmitted. */
3132 # define TV_CC_DATA_1_MASK              0x0000007f
3133 # define TV_CC_DATA_1_SHIFT             0
3134
3135 #define TV_H_LUMA(i)            _MMIO(0x68100 + (i) * 4) /* 60 registers */
3136 #define TV_H_CHROMA(i)          _MMIO(0x68200 + (i) * 4) /* 60 registers */
3137 #define TV_V_LUMA(i)            _MMIO(0x68300 + (i) * 4) /* 43 registers */
3138 #define TV_V_CHROMA(i)          _MMIO(0x68400 + (i) * 4) /* 43 registers */
3139
3140 /* Display Port */
3141 #define DP_A                    _MMIO(0x64000) /* eDP */
3142 #define DP_B                    _MMIO(0x64100)
3143 #define DP_C                    _MMIO(0x64200)
3144 #define DP_D                    _MMIO(0x64300)
3145
3146 #define VLV_DP_B                _MMIO(VLV_DISPLAY_BASE + 0x64100)
3147 #define VLV_DP_C                _MMIO(VLV_DISPLAY_BASE + 0x64200)
3148 #define CHV_DP_D                _MMIO(VLV_DISPLAY_BASE + 0x64300)
3149
3150 #define   DP_PORT_EN                    (1 << 31)
3151 #define   DP_PIPE_SEL_SHIFT             30
3152 #define   DP_PIPE_SEL_MASK              (1 << 30)
3153 #define   DP_PIPE_SEL(pipe)             ((pipe) << 30)
3154 #define   DP_PIPE_SEL_SHIFT_IVB         29
3155 #define   DP_PIPE_SEL_MASK_IVB          (3 << 29)
3156 #define   DP_PIPE_SEL_IVB(pipe)         ((pipe) << 29)
3157 #define   DP_PIPE_SEL_SHIFT_CHV         16
3158 #define   DP_PIPE_SEL_MASK_CHV          (3 << 16)
3159 #define   DP_PIPE_SEL_CHV(pipe)         ((pipe) << 16)
3160
3161 /* Link training mode - select a suitable mode for each stage */
3162 #define   DP_LINK_TRAIN_PAT_1           (0 << 28)
3163 #define   DP_LINK_TRAIN_PAT_2           (1 << 28)
3164 #define   DP_LINK_TRAIN_PAT_IDLE        (2 << 28)
3165 #define   DP_LINK_TRAIN_OFF             (3 << 28)
3166 #define   DP_LINK_TRAIN_MASK            (3 << 28)
3167 #define   DP_LINK_TRAIN_SHIFT           28
3168
3169 /* CPT Link training mode */
3170 #define   DP_LINK_TRAIN_PAT_1_CPT       (0 << 8)
3171 #define   DP_LINK_TRAIN_PAT_2_CPT       (1 << 8)
3172 #define   DP_LINK_TRAIN_PAT_IDLE_CPT    (2 << 8)
3173 #define   DP_LINK_TRAIN_OFF_CPT         (3 << 8)
3174 #define   DP_LINK_TRAIN_MASK_CPT        (7 << 8)
3175 #define   DP_LINK_TRAIN_SHIFT_CPT       8
3176
3177 /* Signal voltages. These are mostly controlled by the other end */
3178 #define   DP_VOLTAGE_0_4                (0 << 25)
3179 #define   DP_VOLTAGE_0_6                (1 << 25)
3180 #define   DP_VOLTAGE_0_8                (2 << 25)
3181 #define   DP_VOLTAGE_1_2                (3 << 25)
3182 #define   DP_VOLTAGE_MASK               (7 << 25)
3183 #define   DP_VOLTAGE_SHIFT              25
3184
3185 /* Signal pre-emphasis levels, like voltages, the other end tells us what
3186  * they want
3187  */
3188 #define   DP_PRE_EMPHASIS_0             (0 << 22)
3189 #define   DP_PRE_EMPHASIS_3_5           (1 << 22)
3190 #define   DP_PRE_EMPHASIS_6             (2 << 22)
3191 #define   DP_PRE_EMPHASIS_9_5           (3 << 22)
3192 #define   DP_PRE_EMPHASIS_MASK          (7 << 22)
3193 #define   DP_PRE_EMPHASIS_SHIFT         22
3194
3195 /* How many wires to use. I guess 3 was too hard */
3196 #define   DP_PORT_WIDTH(width)          (((width) - 1) << 19)
3197 #define   DP_PORT_WIDTH_MASK            (7 << 19)
3198 #define   DP_PORT_WIDTH_SHIFT           19
3199
3200 /* Mystic DPCD version 1.1 special mode */
3201 #define   DP_ENHANCED_FRAMING           (1 << 18)
3202
3203 /* eDP */
3204 #define   DP_PLL_FREQ_270MHZ            (0 << 16)
3205 #define   DP_PLL_FREQ_162MHZ            (1 << 16)
3206 #define   DP_PLL_FREQ_MASK              (3 << 16)
3207
3208 /* locked once port is enabled */
3209 #define   DP_PORT_REVERSAL              (1 << 15)
3210
3211 /* eDP */
3212 #define   DP_PLL_ENABLE                 (1 << 14)
3213
3214 /* sends the clock on lane 15 of the PEG for debug */
3215 #define   DP_CLOCK_OUTPUT_ENABLE        (1 << 13)
3216
3217 #define   DP_SCRAMBLING_DISABLE         (1 << 12)
3218 #define   DP_SCRAMBLING_DISABLE_IRONLAKE        (1 << 7)
3219
3220 /* limit RGB values to avoid confusing TVs */
3221 #define   DP_COLOR_RANGE_16_235         (1 << 8)
3222
3223 /* Turn on the audio link */
3224 #define   DP_AUDIO_OUTPUT_ENABLE        (1 << 6)
3225
3226 /* vs and hs sync polarity */
3227 #define   DP_SYNC_VS_HIGH               (1 << 4)
3228 #define   DP_SYNC_HS_HIGH               (1 << 3)
3229
3230 /* A fantasy */
3231 #define   DP_DETECTED                   (1 << 2)
3232
3233 /* The aux channel provides a way to talk to the
3234  * signal sink for DDC etc. Max packet size supported
3235  * is 20 bytes in each direction, hence the 5 fixed
3236  * data registers
3237  */
3238 #define _DPA_AUX_CH_CTL         (DISPLAY_MMIO_BASE(dev_priv) + 0x64010)
3239 #define _DPA_AUX_CH_DATA1       (DISPLAY_MMIO_BASE(dev_priv) + 0x64014)
3240
3241 #define _DPB_AUX_CH_CTL         (DISPLAY_MMIO_BASE(dev_priv) + 0x64110)
3242 #define _DPB_AUX_CH_DATA1       (DISPLAY_MMIO_BASE(dev_priv) + 0x64114)
3243
3244 #define DP_AUX_CH_CTL(aux_ch)   _MMIO_PORT(aux_ch, _DPA_AUX_CH_CTL, _DPB_AUX_CH_CTL)
3245 #define DP_AUX_CH_DATA(aux_ch, i)       _MMIO(_PORT(aux_ch, _DPA_AUX_CH_DATA1, _DPB_AUX_CH_DATA1) + (i) * 4) /* 5 registers */
3246
3247 #define _XELPDP_USBC1_AUX_CH_CTL        0x16F210
3248 #define _XELPDP_USBC2_AUX_CH_CTL        0x16F410
3249 #define _XELPDP_USBC3_AUX_CH_CTL        0x16F610
3250 #define _XELPDP_USBC4_AUX_CH_CTL        0x16F810
3251
3252 #define XELPDP_DP_AUX_CH_CTL(aux_ch)            _MMIO(_PICK(aux_ch, \
3253                                                        _DPA_AUX_CH_CTL, \
3254                                                        _DPB_AUX_CH_CTL, \
3255                                                        0, /* port/aux_ch C is non-existent */ \
3256                                                        _XELPDP_USBC1_AUX_CH_CTL, \
3257                                                        _XELPDP_USBC2_AUX_CH_CTL, \
3258                                                        _XELPDP_USBC3_AUX_CH_CTL, \
3259                                                        _XELPDP_USBC4_AUX_CH_CTL))
3260
3261 #define _XELPDP_USBC1_AUX_CH_DATA1      0x16F214
3262 #define _XELPDP_USBC2_AUX_CH_DATA1      0x16F414
3263 #define _XELPDP_USBC3_AUX_CH_DATA1      0x16F614
3264 #define _XELPDP_USBC4_AUX_CH_DATA1      0x16F814
3265
3266 #define XELPDP_DP_AUX_CH_DATA(aux_ch, i)        _MMIO(_PICK(aux_ch, \
3267                                                        _DPA_AUX_CH_DATA1, \
3268                                                        _DPB_AUX_CH_DATA1, \
3269                                                        0, /* port/aux_ch C is non-existent */ \
3270                                                        _XELPDP_USBC1_AUX_CH_DATA1, \
3271                                                        _XELPDP_USBC2_AUX_CH_DATA1, \
3272                                                        _XELPDP_USBC3_AUX_CH_DATA1, \
3273                                                        _XELPDP_USBC4_AUX_CH_DATA1) + (i) * 4)
3274
3275 #define   DP_AUX_CH_CTL_SEND_BUSY           (1 << 31)
3276 #define   DP_AUX_CH_CTL_DONE                (1 << 30)
3277 #define   DP_AUX_CH_CTL_INTERRUPT           (1 << 29)
3278 #define   DP_AUX_CH_CTL_TIME_OUT_ERROR      (1 << 28)
3279 #define   DP_AUX_CH_CTL_TIME_OUT_400us      (0 << 26)
3280 #define   DP_AUX_CH_CTL_TIME_OUT_600us      (1 << 26)
3281 #define   DP_AUX_CH_CTL_TIME_OUT_800us      (2 << 26)
3282 #define   DP_AUX_CH_CTL_TIME_OUT_MAX        (3 << 26) /* Varies per platform */
3283 #define   DP_AUX_CH_CTL_TIME_OUT_MASK       (3 << 26)
3284 #define   DP_AUX_CH_CTL_RECEIVE_ERROR       (1 << 25)
3285 #define   DP_AUX_CH_CTL_MESSAGE_SIZE_MASK    (0x1f << 20)
3286 #define   DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT   20
3287 #define   XELPDP_DP_AUX_CH_CTL_POWER_REQUEST REG_BIT(19)
3288 #define   XELPDP_DP_AUX_CH_CTL_POWER_STATUS  REG_BIT(18)
3289 #define   DP_AUX_CH_CTL_PRECHARGE_2US_MASK   (0xf << 16)
3290 #define   DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT  16
3291 #define   DP_AUX_CH_CTL_AUX_AKSV_SELECT     (1 << 15)
3292 #define   DP_AUX_CH_CTL_MANCHESTER_TEST     (1 << 14)
3293 #define   DP_AUX_CH_CTL_SYNC_TEST           (1 << 13)
3294 #define   DP_AUX_CH_CTL_DEGLITCH_TEST       (1 << 12)
3295 #define   DP_AUX_CH_CTL_PRECHARGE_TEST      (1 << 11)
3296 #define   DP_AUX_CH_CTL_BIT_CLOCK_2X_MASK    (0x7ff)
3297 #define   DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT   0
3298 #define   DP_AUX_CH_CTL_PSR_DATA_AUX_REG_SKL    (1 << 14)
3299 #define   DP_AUX_CH_CTL_FS_DATA_AUX_REG_SKL     (1 << 13)
3300 #define   DP_AUX_CH_CTL_GTC_DATA_AUX_REG_SKL    (1 << 12)
3301 #define   DP_AUX_CH_CTL_TBT_IO                  (1 << 11)
3302 #define   DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL_MASK (0x1f << 5)
3303 #define   DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL(c) (((c) - 1) << 5)
3304 #define   DP_AUX_CH_CTL_SYNC_PULSE_SKL(c)   ((c) - 1)
3305
3306 /*
3307  * Computing GMCH M and N values for the Display Port link
3308  *
3309  * GMCH M/N = dot clock * bytes per pixel / ls_clk * # of lanes
3310  *
3311  * ls_clk (we assume) is the DP link clock (1.62 or 2.7 GHz)
3312  *
3313  * The GMCH value is used internally
3314  *
3315  * bytes_per_pixel is the number of bytes coming out of the plane,
3316  * which is after the LUTs, so we want the bytes for our color format.
3317  * For our current usage, this is always 3, one byte for R, G and B.
3318  */
3319 #define _PIPEA_DATA_M_G4X       0x70050
3320 #define _PIPEB_DATA_M_G4X       0x71050
3321
3322 /* Transfer unit size for display port - 1, default is 0x3f (for TU size 64) */
3323 #define  TU_SIZE_MASK           REG_GENMASK(30, 25)
3324 #define  TU_SIZE(x)             REG_FIELD_PREP(TU_SIZE_MASK, (x) - 1) /* default size 64 */
3325
3326 #define  DATA_LINK_M_N_MASK     REG_GENMASK(23, 0)
3327 #define  DATA_LINK_N_MAX        (0x800000)
3328
3329 #define _PIPEA_DATA_N_G4X       0x70054
3330 #define _PIPEB_DATA_N_G4X       0x71054
3331
3332 /*
3333  * Computing Link M and N values for the Display Port link
3334  *
3335  * Link M / N = pixel_clock / ls_clk
3336  *
3337  * (the DP spec calls pixel_clock the 'strm_clk')
3338  *
3339  * The Link value is transmitted in the Main Stream
3340  * Attributes and VB-ID.
3341  */
3342
3343 #define _PIPEA_LINK_M_G4X       0x70060
3344 #define _PIPEB_LINK_M_G4X       0x71060
3345 #define _PIPEA_LINK_N_G4X       0x70064
3346 #define _PIPEB_LINK_N_G4X       0x71064
3347
3348 #define PIPE_DATA_M_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_DATA_M_G4X, _PIPEB_DATA_M_G4X)
3349 #define PIPE_DATA_N_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_DATA_N_G4X, _PIPEB_DATA_N_G4X)
3350 #define PIPE_LINK_M_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_LINK_M_G4X, _PIPEB_LINK_M_G4X)
3351 #define PIPE_LINK_N_G4X(pipe) _MMIO_PIPE(pipe, _PIPEA_LINK_N_G4X, _PIPEB_LINK_N_G4X)
3352
3353 /* Display & cursor control */
3354
3355 /* Pipe A */
3356 #define _PIPEADSL               0x70000
3357 #define   PIPEDSL_CURR_FIELD    REG_BIT(31) /* ctg+ */
3358 #define   PIPEDSL_LINE_MASK     REG_GENMASK(19, 0)
3359 #define _TRANSACONF             0x70008
3360 #define   TRANSCONF_ENABLE                      REG_BIT(31)
3361 #define   TRANSCONF_DOUBLE_WIDE                 REG_BIT(30) /* pre-i965 */
3362 #define   TRANSCONF_STATE_ENABLE                        REG_BIT(30) /* i965+ */
3363 #define   TRANSCONF_DSI_PLL_LOCKED              REG_BIT(29) /* vlv & pipe A only */
3364 #define   TRANSCONF_FRAME_START_DELAY_MASK      REG_GENMASK(28, 27) /* pre-hsw */
3365 #define   TRANSCONF_FRAME_START_DELAY(x)                REG_FIELD_PREP(TRANSCONF_FRAME_START_DELAY_MASK, (x)) /* pre-hsw: 0-3 */
3366 #define   TRANSCONF_PIPE_LOCKED                 REG_BIT(25)
3367 #define   TRANSCONF_FORCE_BORDER                        REG_BIT(25)
3368 #define   TRANSCONF_GAMMA_MODE_MASK_I9XX                REG_BIT(24) /* gmch */
3369 #define   TRANSCONF_GAMMA_MODE_MASK_ILK         REG_GENMASK(25, 24) /* ilk-ivb */
3370 #define   TRANSCONF_GAMMA_MODE_8BIT             REG_FIELD_PREP(TRANSCONF_GAMMA_MODE_MASK, 0)
3371 #define   TRANSCONF_GAMMA_MODE_10BIT            REG_FIELD_PREP(TRANSCONF_GAMMA_MODE_MASK, 1)
3372 #define   TRANSCONF_GAMMA_MODE_12BIT            REG_FIELD_PREP(TRANSCONF_GAMMA_MODE_MASK_ILK, 2) /* ilk-ivb */
3373 #define   TRANSCONF_GAMMA_MODE_SPLIT            REG_FIELD_PREP(TRANSCONF_GAMMA_MODE_MASK_ILK, 3) /* ivb */
3374 #define   TRANSCONF_GAMMA_MODE(x)               REG_FIELD_PREP(TRANSCONF_GAMMA_MODE_MASK_ILK, (x)) /* pass in GAMMA_MODE_MODE_* */
3375 #define   TRANSCONF_INTERLACE_MASK              REG_GENMASK(23, 21) /* gen3+ */
3376 #define   TRANSCONF_INTERLACE_PROGRESSIVE       REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK, 0)
3377 #define   TRANSCONF_INTERLACE_W_SYNC_SHIFT_PANEL        REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK, 4) /* gen4 only */
3378 #define   TRANSCONF_INTERLACE_W_SYNC_SHIFT      REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK, 5) /* gen4 only */
3379 #define   TRANSCONF_INTERLACE_W_FIELD_INDICATION        REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK, 6)
3380 #define   TRANSCONF_INTERLACE_FIELD_0_ONLY      REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK, 7) /* gen3 only */
3381 /*
3382  * ilk+: PF/D=progressive fetch/display, IF/D=interlaced fetch/display,
3383  * DBL=power saving pixel doubling, PF-ID* requires panel fitter
3384  */
3385 #define   TRANSCONF_INTERLACE_MASK_ILK          REG_GENMASK(23, 21) /* ilk+ */
3386 #define   TRANSCONF_INTERLACE_MASK_HSW          REG_GENMASK(22, 21) /* hsw+ */
3387 #define   TRANSCONF_INTERLACE_PF_PD_ILK         REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK_ILK, 0)
3388 #define   TRANSCONF_INTERLACE_PF_ID_ILK         REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK_ILK, 1)
3389 #define   TRANSCONF_INTERLACE_IF_ID_ILK         REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK_ILK, 3)
3390 #define   TRANSCONF_INTERLACE_IF_ID_DBL_ILK     REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK_ILK, 4) /* ilk/snb only */
3391 #define   TRANSCONF_INTERLACE_PF_ID_DBL_ILK     REG_FIELD_PREP(TRANSCONF_INTERLACE_MASK_ILK, 5) /* ilk/snb only */
3392 #define   TRANSCONF_REFRESH_RATE_ALT_ILK                REG_BIT(20)
3393 #define   TRANSCONF_MSA_TIMING_DELAY_MASK       REG_GENMASK(19, 18) /* ilk/snb/ivb */
3394 #define   TRANSCONF_MSA_TIMING_DELAY(x)         REG_FIELD_PREP(TRANSCONF_MSA_TIMING_DELAY_MASK, (x))
3395 #define   TRANSCONF_CXSR_DOWNCLOCK              REG_BIT(16)
3396 #define   TRANSCONF_REFRESH_RATE_ALT_VLV                REG_BIT(14)
3397 #define   TRANSCONF_COLOR_RANGE_SELECT          REG_BIT(13)
3398 #define   TRANSCONF_OUTPUT_COLORSPACE_MASK      REG_GENMASK(12, 11) /* ilk-ivb */
3399 #define   TRANSCONF_OUTPUT_COLORSPACE_RGB       REG_FIELD_PREP(TRANSCONF_OUTPUT_COLORSPACE_MASK, 0) /* ilk-ivb */
3400 #define   TRANSCONF_OUTPUT_COLORSPACE_YUV601    REG_FIELD_PREP(TRANSCONF_OUTPUT_COLORSPACE_MASK, 1) /* ilk-ivb */
3401 #define   TRANSCONF_OUTPUT_COLORSPACE_YUV709    REG_FIELD_PREP(TRANSCONF_OUTPUT_COLORSPACE_MASK, 2) /* ilk-ivb */
3402 #define   TRANSCONF_OUTPUT_COLORSPACE_YUV_HSW   REG_BIT(11) /* hsw only */
3403 #define   TRANSCONF_BPC_MASK                    REG_GENMASK(7, 5) /* ctg-ivb */
3404 #define   TRANSCONF_BPC_8                       REG_FIELD_PREP(TRANSCONF_BPC_MASK, 0)
3405 #define   TRANSCONF_BPC_10                      REG_FIELD_PREP(TRANSCONF_BPC_MASK, 1)
3406 #define   TRANSCONF_BPC_6                       REG_FIELD_PREP(TRANSCONF_BPC_MASK, 2)
3407 #define   TRANSCONF_BPC_12                      REG_FIELD_PREP(TRANSCONF_BPC_MASK, 3)
3408 #define   TRANSCONF_DITHER_EN                   REG_BIT(4)
3409 #define   TRANSCONF_DITHER_TYPE_MASK            REG_GENMASK(3, 2)
3410 #define   TRANSCONF_DITHER_TYPE_SP              REG_FIELD_PREP(TRANSCONF_DITHER_TYPE_MASK, 0)
3411 #define   TRANSCONF_DITHER_TYPE_ST1             REG_FIELD_PREP(TRANSCONF_DITHER_TYPE_MASK, 1)
3412 #define   TRANSCONF_DITHER_TYPE_ST2             REG_FIELD_PREP(TRANSCONF_DITHER_TYPE_MASK, 2)
3413 #define   TRANSCONF_DITHER_TYPE_TEMP            REG_FIELD_PREP(TRANSCONF_DITHER_TYPE_MASK, 3)
3414 #define _PIPEASTAT              0x70024
3415 #define   PIPE_FIFO_UNDERRUN_STATUS             (1UL << 31)
3416 #define   SPRITE1_FLIP_DONE_INT_EN_VLV          (1UL << 30)
3417 #define   PIPE_CRC_ERROR_ENABLE                 (1UL << 29)
3418 #define   PIPE_CRC_DONE_ENABLE                  (1UL << 28)
3419 #define   PERF_COUNTER2_INTERRUPT_EN            (1UL << 27)
3420 #define   PIPE_GMBUS_EVENT_ENABLE               (1UL << 27)
3421 #define   PLANE_FLIP_DONE_INT_EN_VLV            (1UL << 26)
3422 #define   PIPE_HOTPLUG_INTERRUPT_ENABLE         (1UL << 26)
3423 #define   PIPE_VSYNC_INTERRUPT_ENABLE           (1UL << 25)
3424 #define   PIPE_DISPLAY_LINE_COMPARE_ENABLE      (1UL << 24)
3425 #define   PIPE_DPST_EVENT_ENABLE                (1UL << 23)
3426 #define   SPRITE0_FLIP_DONE_INT_EN_VLV          (1UL << 22)
3427 #define   PIPE_LEGACY_BLC_EVENT_ENABLE          (1UL << 22)
3428 #define   PIPE_ODD_FIELD_INTERRUPT_ENABLE       (1UL << 21)
3429 #define   PIPE_EVEN_FIELD_INTERRUPT_ENABLE      (1UL << 20)
3430 #define   PIPE_B_PSR_INTERRUPT_ENABLE_VLV       (1UL << 19)
3431 #define   PERF_COUNTER_INTERRUPT_EN             (1UL << 19)
3432 #define   PIPE_HOTPLUG_TV_INTERRUPT_ENABLE      (1UL << 18) /* pre-965 */
3433 #define   PIPE_START_VBLANK_INTERRUPT_ENABLE    (1UL << 18) /* 965 or later */
3434 #define   PIPE_FRAMESTART_INTERRUPT_ENABLE      (1UL << 17)
3435 #define   PIPE_VBLANK_INTERRUPT_ENABLE          (1UL << 17)
3436 #define   PIPEA_HBLANK_INT_EN_VLV               (1UL << 16)
3437 #define   PIPE_OVERLAY_UPDATED_ENABLE           (1UL << 16)
3438 #define   SPRITE1_FLIP_DONE_INT_STATUS_VLV      (1UL << 15)
3439 #define   SPRITE0_FLIP_DONE_INT_STATUS_VLV      (1UL << 14)
3440 #define   PIPE_CRC_ERROR_INTERRUPT_STATUS       (1UL << 13)
3441 #define   PIPE_CRC_DONE_INTERRUPT_STATUS        (1UL << 12)
3442 #define   PERF_COUNTER2_INTERRUPT_STATUS        (1UL << 11)
3443 #define   PIPE_GMBUS_INTERRUPT_STATUS           (1UL << 11)
3444 #define   PLANE_FLIP_DONE_INT_STATUS_VLV        (1UL << 10)
3445 #define   PIPE_HOTPLUG_INTERRUPT_STATUS         (1UL << 10)
3446 #define   PIPE_VSYNC_INTERRUPT_STATUS           (1UL << 9)
3447 #define   PIPE_DISPLAY_LINE_COMPARE_STATUS      (1UL << 8)
3448 #define   PIPE_DPST_EVENT_STATUS                (1UL << 7)
3449 #define   PIPE_A_PSR_STATUS_VLV                 (1UL << 6)
3450 #define   PIPE_LEGACY_BLC_EVENT_STATUS          (1UL << 6)
3451 #define   PIPE_ODD_FIELD_INTERRUPT_STATUS       (1UL << 5)
3452 #define   PIPE_EVEN_FIELD_INTERRUPT_STATUS      (1UL << 4)
3453 #define   PIPE_B_PSR_STATUS_VLV                 (1UL << 3)
3454 #define   PERF_COUNTER_INTERRUPT_STATUS         (1UL << 3)
3455 #define   PIPE_HOTPLUG_TV_INTERRUPT_STATUS      (1UL << 2) /* pre-965 */
3456 #define   PIPE_START_VBLANK_INTERRUPT_STATUS    (1UL << 2) /* 965 or later */
3457 #define   PIPE_FRAMESTART_INTERRUPT_STATUS      (1UL << 1)
3458 #define   PIPE_VBLANK_INTERRUPT_STATUS          (1UL << 1)
3459 #define   PIPE_HBLANK_INT_STATUS                (1UL << 0)
3460 #define   PIPE_OVERLAY_UPDATED_STATUS           (1UL << 0)
3461
3462 #define PIPESTAT_INT_ENABLE_MASK                0x7fff0000
3463 #define PIPESTAT_INT_STATUS_MASK                0x0000ffff
3464
3465 #define PIPE_A_OFFSET           0x70000
3466 #define PIPE_B_OFFSET           0x71000
3467 #define PIPE_C_OFFSET           0x72000
3468 #define PIPE_D_OFFSET           0x73000
3469 #define CHV_PIPE_C_OFFSET       0x74000
3470 /*
3471  * There's actually no pipe EDP. Some pipe registers have
3472  * simply shifted from the pipe to the transcoder, while
3473  * keeping their original offset. Thus we need PIPE_EDP_OFFSET
3474  * to access such registers in transcoder EDP.
3475  */
3476 #define PIPE_EDP_OFFSET 0x7f000
3477
3478 /* ICL DSI 0 and 1 */
3479 #define PIPE_DSI0_OFFSET        0x7b000
3480 #define PIPE_DSI1_OFFSET        0x7b800
3481
3482 #define TRANSCONF(trans)        _MMIO_PIPE2((trans), _TRANSACONF)
3483 #define PIPEDSL(pipe)           _MMIO_PIPE2(pipe, _PIPEADSL)
3484 #define PIPEFRAME(pipe)         _MMIO_PIPE2(pipe, _PIPEAFRAMEHIGH)
3485 #define PIPEFRAMEPIXEL(pipe)    _MMIO_PIPE2(pipe, _PIPEAFRAMEPIXEL)
3486 #define PIPESTAT(pipe)          _MMIO_PIPE2(pipe, _PIPEASTAT)
3487
3488 #define  _PIPEAGCMAX           0x70010
3489 #define  _PIPEBGCMAX           0x71010
3490 #define PIPEGCMAX(pipe, i)     _MMIO_PIPE2(pipe, _PIPEAGCMAX + (i) * 4) /* u1.16 */
3491
3492 #define _PIPE_ARB_CTL_A                 0x70028 /* icl+ */
3493 #define PIPE_ARB_CTL(pipe)              _MMIO_PIPE2(pipe, _PIPE_ARB_CTL_A)
3494 #define   PIPE_ARB_USE_PROG_SLOTS       REG_BIT(13)
3495
3496 #define _PIPE_MISC_A                    0x70030
3497 #define _PIPE_MISC_B                    0x71030
3498 #define   PIPEMISC_YUV420_ENABLE                REG_BIT(27) /* glk+ */
3499 #define   PIPEMISC_YUV420_MODE_FULL_BLEND       REG_BIT(26) /* glk+ */
3500 #define   PIPEMISC_HDR_MODE_PRECISION           REG_BIT(23) /* icl+ */
3501 #define   PIPEMISC_OUTPUT_COLORSPACE_YUV        REG_BIT(11)
3502 #define   PIPEMISC_PIXEL_ROUNDING_TRUNC         REG_BIT(8) /* tgl+ */
3503 /*
3504  * For Display < 13, Bits 5-7 of PIPE MISC represent DITHER BPC with
3505  * valid values of: 6, 8, 10 BPC.
3506  * ADLP+, the bits 5-7 represent PORT OUTPUT BPC with valid values of:
3507  * 6, 8, 10, 12 BPC.
3508  */
3509 #define   PIPEMISC_BPC_MASK                     REG_GENMASK(7, 5)
3510 #define   PIPEMISC_BPC_8                        REG_FIELD_PREP(PIPEMISC_BPC_MASK, 0)
3511 #define   PIPEMISC_BPC_10                       REG_FIELD_PREP(PIPEMISC_BPC_MASK, 1)
3512 #define   PIPEMISC_BPC_6                        REG_FIELD_PREP(PIPEMISC_BPC_MASK, 2)
3513 #define   PIPEMISC_BPC_12_ADLP                  REG_FIELD_PREP(PIPEMISC_BPC_MASK, 4) /* adlp+ */
3514 #define   PIPEMISC_DITHER_ENABLE                REG_BIT(4)
3515 #define   PIPEMISC_DITHER_TYPE_MASK             REG_GENMASK(3, 2)
3516 #define   PIPEMISC_DITHER_TYPE_SP               REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 0)
3517 #define   PIPEMISC_DITHER_TYPE_ST1              REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 1)
3518 #define   PIPEMISC_DITHER_TYPE_ST2              REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 2)
3519 #define   PIPEMISC_DITHER_TYPE_TEMP             REG_FIELD_PREP(PIPEMISC_DITHER_TYPE_MASK, 3)
3520 #define PIPEMISC(pipe)                  _MMIO_PIPE2(pipe, _PIPE_MISC_A)
3521
3522 #define _PIPE_MISC2_A                                   0x7002C
3523 #define _PIPE_MISC2_B                                   0x7102C
3524 #define   PIPE_MISC2_BUBBLE_COUNTER_MASK        REG_GENMASK(31, 24)
3525 #define   PIPE_MISC2_BUBBLE_COUNTER_SCALER_EN   REG_FIELD_PREP(PIPE_MISC2_BUBBLE_COUNTER_MASK, 80)
3526 #define   PIPE_MISC2_BUBBLE_COUNTER_SCALER_DIS  REG_FIELD_PREP(PIPE_MISC2_BUBBLE_COUNTER_MASK, 20)
3527 #define PIPE_MISC2(pipe)                                        _MMIO_PIPE2(pipe, _PIPE_MISC2_A)
3528
3529 /* Skylake+ pipe bottom (background) color */
3530 #define _SKL_BOTTOM_COLOR_A             0x70034
3531 #define _SKL_BOTTOM_COLOR_B             0x71034
3532 #define   SKL_BOTTOM_COLOR_GAMMA_ENABLE         REG_BIT(31)
3533 #define   SKL_BOTTOM_COLOR_CSC_ENABLE           REG_BIT(30)
3534 #define SKL_BOTTOM_COLOR(pipe)          _MMIO_PIPE(pipe, _SKL_BOTTOM_COLOR_A, _SKL_BOTTOM_COLOR_B)
3535
3536 #define _ICL_PIPE_A_STATUS                      0x70058
3537 #define ICL_PIPESTATUS(pipe)                    _MMIO_PIPE2(pipe, _ICL_PIPE_A_STATUS)
3538 #define   PIPE_STATUS_UNDERRUN                          REG_BIT(31)
3539 #define   PIPE_STATUS_SOFT_UNDERRUN_XELPD               REG_BIT(28)
3540 #define   PIPE_STATUS_HARD_UNDERRUN_XELPD               REG_BIT(27)
3541 #define   PIPE_STATUS_PORT_UNDERRUN_XELPD               REG_BIT(26)
3542
3543 #define VLV_DPFLIPSTAT                          _MMIO(VLV_DISPLAY_BASE + 0x70028)
3544 #define   PIPEB_LINE_COMPARE_INT_EN                     REG_BIT(29)
3545 #define   PIPEB_HLINE_INT_EN                    REG_BIT(28)
3546 #define   PIPEB_VBLANK_INT_EN                   REG_BIT(27)
3547 #define   SPRITED_FLIP_DONE_INT_EN                      REG_BIT(26)
3548 #define   SPRITEC_FLIP_DONE_INT_EN                      REG_BIT(25)
3549 #define   PLANEB_FLIP_DONE_INT_EN                       REG_BIT(24)
3550 #define   PIPE_PSR_INT_EN                       REG_BIT(22)
3551 #define   PIPEA_LINE_COMPARE_INT_EN                     REG_BIT(21)
3552 #define   PIPEA_HLINE_INT_EN                    REG_BIT(20)
3553 #define   PIPEA_VBLANK_INT_EN                   REG_BIT(19)
3554 #define   SPRITEB_FLIP_DONE_INT_EN                      REG_BIT(18)
3555 #define   SPRITEA_FLIP_DONE_INT_EN                      REG_BIT(17)
3556 #define   PLANEA_FLIPDONE_INT_EN                        REG_BIT(16)
3557 #define   PIPEC_LINE_COMPARE_INT_EN                     REG_BIT(13)
3558 #define   PIPEC_HLINE_INT_EN                    REG_BIT(12)
3559 #define   PIPEC_VBLANK_INT_EN                   REG_BIT(11)
3560 #define   SPRITEF_FLIPDONE_INT_EN                       REG_BIT(10)
3561 #define   SPRITEE_FLIPDONE_INT_EN                       REG_BIT(9)
3562 #define   PLANEC_FLIPDONE_INT_EN                        REG_BIT(8)
3563
3564 #define DPINVGTT                                _MMIO(VLV_DISPLAY_BASE + 0x7002c) /* VLV/CHV only */
3565 #define   DPINVGTT_EN_MASK_CHV                          REG_GENMASK(27, 16)
3566 #define   DPINVGTT_EN_MASK_VLV                          REG_GENMASK(23, 16)
3567 #define   SPRITEF_INVALID_GTT_INT_EN                    REG_BIT(27)
3568 #define   SPRITEE_INVALID_GTT_INT_EN                    REG_BIT(26)
3569 #define   PLANEC_INVALID_GTT_INT_EN                     REG_BIT(25)
3570 #define   CURSORC_INVALID_GTT_INT_EN                    REG_BIT(24)
3571 #define   CURSORB_INVALID_GTT_INT_EN                    REG_BIT(23)
3572 #define   CURSORA_INVALID_GTT_INT_EN                    REG_BIT(22)
3573 #define   SPRITED_INVALID_GTT_INT_EN                    REG_BIT(21)
3574 #define   SPRITEC_INVALID_GTT_INT_EN                    REG_BIT(20)
3575 #define   PLANEB_INVALID_GTT_INT_EN                     REG_BIT(19)
3576 #define   SPRITEB_INVALID_GTT_INT_EN                    REG_BIT(18)
3577 #define   SPRITEA_INVALID_GTT_INT_EN                    REG_BIT(17)
3578 #define   PLANEA_INVALID_GTT_INT_EN                     REG_BIT(16)
3579 #define   DPINVGTT_STATUS_MASK_CHV                      REG_GENMASK(11, 0)
3580 #define   DPINVGTT_STATUS_MASK_VLV                      REG_GENMASK(7, 0)
3581 #define   SPRITEF_INVALID_GTT_STATUS                    REG_BIT(11)
3582 #define   SPRITEE_INVALID_GTT_STATUS                    REG_BIT(10)
3583 #define   PLANEC_INVALID_GTT_STATUS                     REG_BIT(9)
3584 #define   CURSORC_INVALID_GTT_STATUS                    REG_BIT(8)
3585 #define   CURSORB_INVALID_GTT_STATUS                    REG_BIT(7)
3586 #define   CURSORA_INVALID_GTT_STATUS                    REG_BIT(6)
3587 #define   SPRITED_INVALID_GTT_STATUS                    REG_BIT(5)
3588 #define   SPRITEC_INVALID_GTT_STATUS                    REG_BIT(4)
3589 #define   PLANEB_INVALID_GTT_STATUS                     REG_BIT(3)
3590 #define   SPRITEB_INVALID_GTT_STATUS                    REG_BIT(2)
3591 #define   SPRITEA_INVALID_GTT_STATUS                    REG_BIT(1)
3592 #define   PLANEA_INVALID_GTT_STATUS                     REG_BIT(0)
3593
3594 #define DSPARB                  _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70030)
3595 #define   DSPARB_CSTART_MASK    (0x7f << 7)
3596 #define   DSPARB_CSTART_SHIFT   7
3597 #define   DSPARB_BSTART_MASK    (0x7f)
3598 #define   DSPARB_BSTART_SHIFT   0
3599 #define   DSPARB_BEND_SHIFT     9 /* on 855 */
3600 #define   DSPARB_AEND_SHIFT     0
3601 #define   DSPARB_SPRITEA_SHIFT_VLV      0
3602 #define   DSPARB_SPRITEA_MASK_VLV       (0xff << 0)
3603 #define   DSPARB_SPRITEB_SHIFT_VLV      8
3604 #define   DSPARB_SPRITEB_MASK_VLV       (0xff << 8)
3605 #define   DSPARB_SPRITEC_SHIFT_VLV      16
3606 #define   DSPARB_SPRITEC_MASK_VLV       (0xff << 16)
3607 #define   DSPARB_SPRITED_SHIFT_VLV      24
3608 #define   DSPARB_SPRITED_MASK_VLV       (0xff << 24)
3609 #define DSPARB2                         _MMIO(VLV_DISPLAY_BASE + 0x70060) /* vlv/chv */
3610 #define   DSPARB_SPRITEA_HI_SHIFT_VLV   0
3611 #define   DSPARB_SPRITEA_HI_MASK_VLV    (0x1 << 0)
3612 #define   DSPARB_SPRITEB_HI_SHIFT_VLV   4
3613 #define   DSPARB_SPRITEB_HI_MASK_VLV    (0x1 << 4)
3614 #define   DSPARB_SPRITEC_HI_SHIFT_VLV   8
3615 #define   DSPARB_SPRITEC_HI_MASK_VLV    (0x1 << 8)
3616 #define   DSPARB_SPRITED_HI_SHIFT_VLV   12
3617 #define   DSPARB_SPRITED_HI_MASK_VLV    (0x1 << 12)
3618 #define   DSPARB_SPRITEE_HI_SHIFT_VLV   16
3619 #define   DSPARB_SPRITEE_HI_MASK_VLV    (0x1 << 16)
3620 #define   DSPARB_SPRITEF_HI_SHIFT_VLV   20
3621 #define   DSPARB_SPRITEF_HI_MASK_VLV    (0x1 << 20)
3622 #define DSPARB3                         _MMIO(VLV_DISPLAY_BASE + 0x7006c) /* chv */
3623 #define   DSPARB_SPRITEE_SHIFT_VLV      0
3624 #define   DSPARB_SPRITEE_MASK_VLV       (0xff << 0)
3625 #define   DSPARB_SPRITEF_SHIFT_VLV      8
3626 #define   DSPARB_SPRITEF_MASK_VLV       (0xff << 8)
3627
3628 /* pnv/gen4/g4x/vlv/chv */
3629 #define DSPFW1          _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70034)
3630 #define   DSPFW_SR_SHIFT                23
3631 #define   DSPFW_SR_MASK                 (0x1ff << 23)
3632 #define   DSPFW_CURSORB_SHIFT           16
3633 #define   DSPFW_CURSORB_MASK            (0x3f << 16)
3634 #define   DSPFW_PLANEB_SHIFT            8
3635 #define   DSPFW_PLANEB_MASK             (0x7f << 8)
3636 #define   DSPFW_PLANEB_MASK_VLV         (0xff << 8) /* vlv/chv */
3637 #define   DSPFW_PLANEA_SHIFT            0
3638 #define   DSPFW_PLANEA_MASK             (0x7f << 0)
3639 #define   DSPFW_PLANEA_MASK_VLV         (0xff << 0) /* vlv/chv */
3640 #define DSPFW2          _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70038)
3641 #define   DSPFW_FBC_SR_EN               (1 << 31)         /* g4x */
3642 #define   DSPFW_FBC_SR_SHIFT            28
3643 #define   DSPFW_FBC_SR_MASK             (0x7 << 28) /* g4x */
3644 #define   DSPFW_FBC_HPLL_SR_SHIFT       24
3645 #define   DSPFW_FBC_HPLL_SR_MASK        (0xf << 24) /* g4x */
3646 #define   DSPFW_SPRITEB_SHIFT           (16)
3647 #define   DSPFW_SPRITEB_MASK            (0x7f << 16) /* g4x */
3648 #define   DSPFW_SPRITEB_MASK_VLV        (0xff << 16) /* vlv/chv */
3649 #define   DSPFW_CURSORA_SHIFT           8
3650 #define   DSPFW_CURSORA_MASK            (0x3f << 8)
3651 #define   DSPFW_PLANEC_OLD_SHIFT        0
3652 #define   DSPFW_PLANEC_OLD_MASK         (0x7f << 0) /* pre-gen4 sprite C */
3653 #define   DSPFW_SPRITEA_SHIFT           0
3654 #define   DSPFW_SPRITEA_MASK            (0x7f << 0) /* g4x */
3655 #define   DSPFW_SPRITEA_MASK_VLV        (0xff << 0) /* vlv/chv */
3656 #define DSPFW3          _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x7003c)
3657 #define   DSPFW_HPLL_SR_EN              (1 << 31)
3658 #define   PINEVIEW_SELF_REFRESH_EN      (1 << 30)
3659 #define   DSPFW_CURSOR_SR_SHIFT         24
3660 #define   DSPFW_CURSOR_SR_MASK          (0x3f << 24)
3661 #define   DSPFW_HPLL_CURSOR_SHIFT       16
3662 #define   DSPFW_HPLL_CURSOR_MASK        (0x3f << 16)
3663 #define   DSPFW_HPLL_SR_SHIFT           0
3664 #define   DSPFW_HPLL_SR_MASK            (0x1ff << 0)
3665
3666 /* vlv/chv */
3667 #define DSPFW4          _MMIO(VLV_DISPLAY_BASE + 0x70070)
3668 #define   DSPFW_SPRITEB_WM1_SHIFT       16
3669 #define   DSPFW_SPRITEB_WM1_MASK        (0xff << 16)
3670 #define   DSPFW_CURSORA_WM1_SHIFT       8
3671 #define   DSPFW_CURSORA_WM1_MASK        (0x3f << 8)
3672 #define   DSPFW_SPRITEA_WM1_SHIFT       0
3673 #define   DSPFW_SPRITEA_WM1_MASK        (0xff << 0)
3674 #define DSPFW5          _MMIO(VLV_DISPLAY_BASE + 0x70074)
3675 #define   DSPFW_PLANEB_WM1_SHIFT        24
3676 #define   DSPFW_PLANEB_WM1_MASK         (0xff << 24)
3677 #define   DSPFW_PLANEA_WM1_SHIFT        16
3678 #define   DSPFW_PLANEA_WM1_MASK         (0xff << 16)
3679 #define   DSPFW_CURSORB_WM1_SHIFT       8
3680 #define   DSPFW_CURSORB_WM1_MASK        (0x3f << 8)
3681 #define   DSPFW_CURSOR_SR_WM1_SHIFT     0
3682 #define   DSPFW_CURSOR_SR_WM1_MASK      (0x3f << 0)
3683 #define DSPFW6          _MMIO(VLV_DISPLAY_BASE + 0x70078)
3684 #define   DSPFW_SR_WM1_SHIFT            0
3685 #define   DSPFW_SR_WM1_MASK             (0x1ff << 0)
3686 #define DSPFW7          _MMIO(VLV_DISPLAY_BASE + 0x7007c)
3687 #define DSPFW7_CHV      _MMIO(VLV_DISPLAY_BASE + 0x700b4) /* wtf #1? */
3688 #define   DSPFW_SPRITED_WM1_SHIFT       24
3689 #define   DSPFW_SPRITED_WM1_MASK        (0xff << 24)
3690 #define   DSPFW_SPRITED_SHIFT           16
3691 #define   DSPFW_SPRITED_MASK_VLV        (0xff << 16)
3692 #define   DSPFW_SPRITEC_WM1_SHIFT       8
3693 #define   DSPFW_SPRITEC_WM1_MASK        (0xff << 8)
3694 #define   DSPFW_SPRITEC_SHIFT           0
3695 #define   DSPFW_SPRITEC_MASK_VLV        (0xff << 0)
3696 #define DSPFW8_CHV      _MMIO(VLV_DISPLAY_BASE + 0x700b8)
3697 #define   DSPFW_SPRITEF_WM1_SHIFT       24
3698 #define   DSPFW_SPRITEF_WM1_MASK        (0xff << 24)
3699 #define   DSPFW_SPRITEF_SHIFT           16
3700 #define   DSPFW_SPRITEF_MASK_VLV        (0xff << 16)
3701 #define   DSPFW_SPRITEE_WM1_SHIFT       8
3702 #define   DSPFW_SPRITEE_WM1_MASK        (0xff << 8)
3703 #define   DSPFW_SPRITEE_SHIFT           0
3704 #define   DSPFW_SPRITEE_MASK_VLV        (0xff << 0)
3705 #define DSPFW9_CHV      _MMIO(VLV_DISPLAY_BASE + 0x7007c) /* wtf #2? */
3706 #define   DSPFW_PLANEC_WM1_SHIFT        24
3707 #define   DSPFW_PLANEC_WM1_MASK         (0xff << 24)
3708 #define   DSPFW_PLANEC_SHIFT            16
3709 #define   DSPFW_PLANEC_MASK_VLV         (0xff << 16)
3710 #define   DSPFW_CURSORC_WM1_SHIFT       8
3711 #define   DSPFW_CURSORC_WM1_MASK        (0x3f << 16)
3712 #define   DSPFW_CURSORC_SHIFT           0
3713 #define   DSPFW_CURSORC_MASK            (0x3f << 0)
3714
3715 /* vlv/chv high order bits */
3716 #define DSPHOWM         _MMIO(VLV_DISPLAY_BASE + 0x70064)
3717 #define   DSPFW_SR_HI_SHIFT             24
3718 #define   DSPFW_SR_HI_MASK              (3 << 24) /* 2 bits for chv, 1 for vlv */
3719 #define   DSPFW_SPRITEF_HI_SHIFT        23
3720 #define   DSPFW_SPRITEF_HI_MASK         (1 << 23)
3721 #define   DSPFW_SPRITEE_HI_SHIFT        22
3722 #define   DSPFW_SPRITEE_HI_MASK         (1 << 22)
3723 #define   DSPFW_PLANEC_HI_SHIFT         21
3724 #define   DSPFW_PLANEC_HI_MASK          (1 << 21)
3725 #define   DSPFW_SPRITED_HI_SHIFT        20
3726 #define   DSPFW_SPRITED_HI_MASK         (1 << 20)
3727 #define   DSPFW_SPRITEC_HI_SHIFT        16
3728 #define   DSPFW_SPRITEC_HI_MASK         (1 << 16)
3729 #define   DSPFW_PLANEB_HI_SHIFT         12
3730 #define   DSPFW_PLANEB_HI_MASK          (1 << 12)
3731 #define   DSPFW_SPRITEB_HI_SHIFT        8
3732 #define   DSPFW_SPRITEB_HI_MASK         (1 << 8)
3733 #define   DSPFW_SPRITEA_HI_SHIFT        4
3734 #define   DSPFW_SPRITEA_HI_MASK         (1 << 4)
3735 #define   DSPFW_PLANEA_HI_SHIFT         0
3736 #define   DSPFW_PLANEA_HI_MASK          (1 << 0)
3737 #define DSPHOWM1        _MMIO(VLV_DISPLAY_BASE + 0x70068)
3738 #define   DSPFW_SR_WM1_HI_SHIFT         24
3739 #define   DSPFW_SR_WM1_HI_MASK          (3 << 24) /* 2 bits for chv, 1 for vlv */
3740 #define   DSPFW_SPRITEF_WM1_HI_SHIFT    23
3741 #define   DSPFW_SPRITEF_WM1_HI_MASK     (1 << 23)
3742 #define   DSPFW_SPRITEE_WM1_HI_SHIFT    22
3743 #define   DSPFW_SPRITEE_WM1_HI_MASK     (1 << 22)
3744 #define   DSPFW_PLANEC_WM1_HI_SHIFT     21
3745 #define   DSPFW_PLANEC_WM1_HI_MASK      (1 << 21)
3746 #define   DSPFW_SPRITED_WM1_HI_SHIFT    20
3747 #define   DSPFW_SPRITED_WM1_HI_MASK     (1 << 20)
3748 #define   DSPFW_SPRITEC_WM1_HI_SHIFT    16
3749 #define   DSPFW_SPRITEC_WM1_HI_MASK     (1 << 16)
3750 #define   DSPFW_PLANEB_WM1_HI_SHIFT     12
3751 #define   DSPFW_PLANEB_WM1_HI_MASK      (1 << 12)
3752 #define   DSPFW_SPRITEB_WM1_HI_SHIFT    8
3753 #define   DSPFW_SPRITEB_WM1_HI_MASK     (1 << 8)
3754 #define   DSPFW_SPRITEA_WM1_HI_SHIFT    4
3755 #define   DSPFW_SPRITEA_WM1_HI_MASK     (1 << 4)
3756 #define   DSPFW_PLANEA_WM1_HI_SHIFT     0
3757 #define   DSPFW_PLANEA_WM1_HI_MASK      (1 << 0)
3758
3759 /* drain latency register values*/
3760 #define VLV_DDL(pipe)                   _MMIO(VLV_DISPLAY_BASE + 0x70050 + 4 * (pipe))
3761 #define DDL_CURSOR_SHIFT                24
3762 #define DDL_SPRITE_SHIFT(sprite)        (8 + 8 * (sprite))
3763 #define DDL_PLANE_SHIFT                 0
3764 #define DDL_PRECISION_HIGH              (1 << 7)
3765 #define DDL_PRECISION_LOW               (0 << 7)
3766 #define DRAIN_LATENCY_MASK              0x7f
3767
3768 #define CBR1_VLV                        _MMIO(VLV_DISPLAY_BASE + 0x70400)
3769 #define  CBR_PND_DEADLINE_DISABLE       (1 << 31)
3770 #define  CBR_PWM_CLOCK_MUX_SELECT       (1 << 30)
3771
3772 #define CBR4_VLV                        _MMIO(VLV_DISPLAY_BASE + 0x70450)
3773 #define  CBR_DPLLBMD_PIPE(pipe)         (1 << (7 + (pipe) * 11)) /* pipes B and C */
3774
3775 /* FIFO watermark sizes etc */
3776 #define G4X_FIFO_LINE_SIZE      64
3777 #define I915_FIFO_LINE_SIZE     64
3778 #define I830_FIFO_LINE_SIZE     32
3779
3780 #define VALLEYVIEW_FIFO_SIZE    255
3781 #define G4X_FIFO_SIZE           127
3782 #define I965_FIFO_SIZE          512
3783 #define I945_FIFO_SIZE          127
3784 #define I915_FIFO_SIZE          95
3785 #define I855GM_FIFO_SIZE        127 /* In cachelines */
3786 #define I830_FIFO_SIZE          95
3787
3788 #define VALLEYVIEW_MAX_WM       0xff
3789 #define G4X_MAX_WM              0x3f
3790 #define I915_MAX_WM             0x3f
3791
3792 #define PINEVIEW_DISPLAY_FIFO   512 /* in 64byte unit */
3793 #define PINEVIEW_FIFO_LINE_SIZE 64
3794 #define PINEVIEW_MAX_WM         0x1ff
3795 #define PINEVIEW_DFT_WM         0x3f
3796 #define PINEVIEW_DFT_HPLLOFF_WM 0
3797 #define PINEVIEW_GUARD_WM               10
3798 #define PINEVIEW_CURSOR_FIFO            64
3799 #define PINEVIEW_CURSOR_MAX_WM  0x3f
3800 #define PINEVIEW_CURSOR_DFT_WM  0
3801 #define PINEVIEW_CURSOR_GUARD_WM        5
3802
3803 #define VALLEYVIEW_CURSOR_MAX_WM 64
3804 #define I965_CURSOR_FIFO        64
3805 #define I965_CURSOR_MAX_WM      32
3806 #define I965_CURSOR_DFT_WM      8
3807
3808 /* Watermark register definitions for SKL */
3809 #define _CUR_WM_A_0             0x70140
3810 #define _CUR_WM_B_0             0x71140
3811 #define _CUR_WM_SAGV_A          0x70158
3812 #define _CUR_WM_SAGV_B          0x71158
3813 #define _CUR_WM_SAGV_TRANS_A    0x7015C
3814 #define _CUR_WM_SAGV_TRANS_B    0x7115C
3815 #define _CUR_WM_TRANS_A         0x70168
3816 #define _CUR_WM_TRANS_B         0x71168
3817 #define _PLANE_WM_1_A_0         0x70240
3818 #define _PLANE_WM_1_B_0         0x71240
3819 #define _PLANE_WM_2_A_0         0x70340
3820 #define _PLANE_WM_2_B_0         0x71340
3821 #define _PLANE_WM_SAGV_1_A      0x70258
3822 #define _PLANE_WM_SAGV_1_B      0x71258
3823 #define _PLANE_WM_SAGV_2_A      0x70358
3824 #define _PLANE_WM_SAGV_2_B      0x71358
3825 #define _PLANE_WM_SAGV_TRANS_1_A        0x7025C
3826 #define _PLANE_WM_SAGV_TRANS_1_B        0x7125C
3827 #define _PLANE_WM_SAGV_TRANS_2_A        0x7035C
3828 #define _PLANE_WM_SAGV_TRANS_2_B        0x7135C
3829 #define _PLANE_WM_TRANS_1_A     0x70268
3830 #define _PLANE_WM_TRANS_1_B     0x71268
3831 #define _PLANE_WM_TRANS_2_A     0x70368
3832 #define _PLANE_WM_TRANS_2_B     0x71368
3833 #define   PLANE_WM_EN           (1 << 31)
3834 #define   PLANE_WM_IGNORE_LINES (1 << 30)
3835 #define   PLANE_WM_LINES_MASK   REG_GENMASK(26, 14)
3836 #define   PLANE_WM_BLOCKS_MASK  REG_GENMASK(11, 0)
3837
3838 #define _CUR_WM_0(pipe) _PIPE(pipe, _CUR_WM_A_0, _CUR_WM_B_0)
3839 #define CUR_WM(pipe, level) _MMIO(_CUR_WM_0(pipe) + ((4) * (level)))
3840 #define CUR_WM_SAGV(pipe) _MMIO_PIPE(pipe, _CUR_WM_SAGV_A, _CUR_WM_SAGV_B)
3841 #define CUR_WM_SAGV_TRANS(pipe) _MMIO_PIPE(pipe, _CUR_WM_SAGV_TRANS_A, _CUR_WM_SAGV_TRANS_B)
3842 #define CUR_WM_TRANS(pipe) _MMIO_PIPE(pipe, _CUR_WM_TRANS_A, _CUR_WM_TRANS_B)
3843 #define _PLANE_WM_1(pipe) _PIPE(pipe, _PLANE_WM_1_A_0, _PLANE_WM_1_B_0)
3844 #define _PLANE_WM_2(pipe) _PIPE(pipe, _PLANE_WM_2_A_0, _PLANE_WM_2_B_0)
3845 #define _PLANE_WM_BASE(pipe, plane) \
3846         _PLANE(plane, _PLANE_WM_1(pipe), _PLANE_WM_2(pipe))
3847 #define PLANE_WM(pipe, plane, level) \
3848         _MMIO(_PLANE_WM_BASE(pipe, plane) + ((4) * (level)))
3849 #define _PLANE_WM_SAGV_1(pipe) \
3850         _PIPE(pipe, _PLANE_WM_SAGV_1_A, _PLANE_WM_SAGV_1_B)
3851 #define _PLANE_WM_SAGV_2(pipe) \
3852         _PIPE(pipe, _PLANE_WM_SAGV_2_A, _PLANE_WM_SAGV_2_B)
3853 #define PLANE_WM_SAGV(pipe, plane) \
3854         _MMIO(_PLANE(plane, _PLANE_WM_SAGV_1(pipe), _PLANE_WM_SAGV_2(pipe)))
3855 #define _PLANE_WM_SAGV_TRANS_1(pipe) \
3856         _PIPE(pipe, _PLANE_WM_SAGV_TRANS_1_A, _PLANE_WM_SAGV_TRANS_1_B)
3857 #define _PLANE_WM_SAGV_TRANS_2(pipe) \
3858         _PIPE(pipe, _PLANE_WM_SAGV_TRANS_2_A, _PLANE_WM_SAGV_TRANS_2_B)
3859 #define PLANE_WM_SAGV_TRANS(pipe, plane) \
3860         _MMIO(_PLANE(plane, _PLANE_WM_SAGV_TRANS_1(pipe), _PLANE_WM_SAGV_TRANS_2(pipe)))
3861 #define _PLANE_WM_TRANS_1(pipe) \
3862         _PIPE(pipe, _PLANE_WM_TRANS_1_A, _PLANE_WM_TRANS_1_B)
3863 #define _PLANE_WM_TRANS_2(pipe) \
3864         _PIPE(pipe, _PLANE_WM_TRANS_2_A, _PLANE_WM_TRANS_2_B)
3865 #define PLANE_WM_TRANS(pipe, plane) \
3866         _MMIO(_PLANE(plane, _PLANE_WM_TRANS_1(pipe), _PLANE_WM_TRANS_2(pipe)))
3867
3868 /* define the Watermark register on Ironlake */
3869 #define _WM0_PIPEA_ILK          0x45100
3870 #define _WM0_PIPEB_ILK          0x45104
3871 #define _WM0_PIPEC_IVB          0x45200
3872 #define WM0_PIPE_ILK(pipe)      _MMIO_PIPE3((pipe), _WM0_PIPEA_ILK, \
3873                                             _WM0_PIPEB_ILK, _WM0_PIPEC_IVB)
3874 #define  WM0_PIPE_PRIMARY_MASK  REG_GENMASK(31, 16)
3875 #define  WM0_PIPE_SPRITE_MASK   REG_GENMASK(15, 8)
3876 #define  WM0_PIPE_CURSOR_MASK   REG_GENMASK(7, 0)
3877 #define  WM0_PIPE_PRIMARY(x)    REG_FIELD_PREP(WM0_PIPE_PRIMARY_MASK, (x))
3878 #define  WM0_PIPE_SPRITE(x)     REG_FIELD_PREP(WM0_PIPE_SPRITE_MASK, (x))
3879 #define  WM0_PIPE_CURSOR(x)     REG_FIELD_PREP(WM0_PIPE_CURSOR_MASK, (x))
3880 #define WM1_LP_ILK              _MMIO(0x45108)
3881 #define WM2_LP_ILK              _MMIO(0x4510c)
3882 #define WM3_LP_ILK              _MMIO(0x45110)
3883 #define  WM_LP_ENABLE           REG_BIT(31)
3884 #define  WM_LP_LATENCY_MASK     REG_GENMASK(30, 24)
3885 #define  WM_LP_FBC_MASK_BDW     REG_GENMASK(23, 19)
3886 #define  WM_LP_FBC_MASK_ILK     REG_GENMASK(23, 20)
3887 #define  WM_LP_PRIMARY_MASK     REG_GENMASK(18, 8)
3888 #define  WM_LP_CURSOR_MASK      REG_GENMASK(7, 0)
3889 #define  WM_LP_LATENCY(x)       REG_FIELD_PREP(WM_LP_LATENCY_MASK, (x))
3890 #define  WM_LP_FBC_BDW(x)       REG_FIELD_PREP(WM_LP_FBC_MASK_BDW, (x))
3891 #define  WM_LP_FBC_ILK(x)       REG_FIELD_PREP(WM_LP_FBC_MASK_ILK, (x))
3892 #define  WM_LP_PRIMARY(x)       REG_FIELD_PREP(WM_LP_PRIMARY_MASK, (x))
3893 #define  WM_LP_CURSOR(x)        REG_FIELD_PREP(WM_LP_CURSOR_MASK, (x))
3894 #define WM1S_LP_ILK             _MMIO(0x45120)
3895 #define WM2S_LP_IVB             _MMIO(0x45124)
3896 #define WM3S_LP_IVB             _MMIO(0x45128)
3897 #define  WM_LP_SPRITE_ENABLE    REG_BIT(31) /* ilk/snb WM1S only */
3898 #define  WM_LP_SPRITE_MASK      REG_GENMASK(10, 0)
3899 #define  WM_LP_SPRITE(x)        REG_FIELD_PREP(WM_LP_SPRITE_MASK, (x))
3900
3901 /*
3902  * The two pipe frame counter registers are not synchronized, so
3903  * reading a stable value is somewhat tricky. The following code
3904  * should work:
3905  *
3906  *  do {
3907  *    high1 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
3908  *             PIPE_FRAME_HIGH_SHIFT;
3909  *    low1 =  ((INREG(PIPEAFRAMEPIXEL) & PIPE_FRAME_LOW_MASK) >>
3910  *             PIPE_FRAME_LOW_SHIFT);
3911  *    high2 = ((INREG(PIPEAFRAMEHIGH) & PIPE_FRAME_HIGH_MASK) >>
3912  *             PIPE_FRAME_HIGH_SHIFT);
3913  *  } while (high1 != high2);
3914  *  frame = (high1 << 8) | low1;
3915  */
3916 #define _PIPEAFRAMEHIGH          0x70040
3917 #define   PIPE_FRAME_HIGH_MASK    0x0000ffff
3918 #define   PIPE_FRAME_HIGH_SHIFT   0
3919 #define _PIPEAFRAMEPIXEL         0x70044
3920 #define   PIPE_FRAME_LOW_MASK     0xff000000
3921 #define   PIPE_FRAME_LOW_SHIFT    24
3922 #define   PIPE_PIXEL_MASK         0x00ffffff
3923 #define   PIPE_PIXEL_SHIFT        0
3924 /* GM45+ just has to be different */
3925 #define _PIPEA_FRMCOUNT_G4X     0x70040
3926 #define _PIPEA_FLIPCOUNT_G4X    0x70044
3927 #define PIPE_FRMCOUNT_G4X(pipe) _MMIO_PIPE2(pipe, _PIPEA_FRMCOUNT_G4X)
3928 #define PIPE_FLIPCOUNT_G4X(pipe) _MMIO_PIPE2(pipe, _PIPEA_FLIPCOUNT_G4X)
3929
3930 /* Cursor A & B regs */
3931 #define _CURACNTR               0x70080
3932 /* Old style CUR*CNTR flags (desktop 8xx) */
3933 #define   CURSOR_ENABLE                 REG_BIT(31)
3934 #define   CURSOR_PIPE_GAMMA_ENABLE      REG_BIT(30)
3935 #define   CURSOR_STRIDE_MASK    REG_GENMASK(29, 28)
3936 #define   CURSOR_STRIDE(stride) REG_FIELD_PREP(CURSOR_STRIDE_MASK, ffs(stride) - 9) /* 256,512,1k,2k */
3937 #define   CURSOR_FORMAT_MASK    REG_GENMASK(26, 24)
3938 #define   CURSOR_FORMAT_2C      REG_FIELD_PREP(CURSOR_FORMAT_MASK, 0)
3939 #define   CURSOR_FORMAT_3C      REG_FIELD_PREP(CURSOR_FORMAT_MASK, 1)
3940 #define   CURSOR_FORMAT_4C      REG_FIELD_PREP(CURSOR_FORMAT_MASK, 2)
3941 #define   CURSOR_FORMAT_ARGB    REG_FIELD_PREP(CURSOR_FORMAT_MASK, 4)
3942 #define   CURSOR_FORMAT_XRGB    REG_FIELD_PREP(CURSOR_FORMAT_MASK, 5)
3943 /* New style CUR*CNTR flags */
3944 #define   MCURSOR_ARB_SLOTS_MASK        REG_GENMASK(30, 28) /* icl+ */
3945 #define   MCURSOR_ARB_SLOTS(x)          REG_FIELD_PREP(MCURSOR_ARB_SLOTS_MASK, (x)) /* icl+ */
3946 #define   MCURSOR_PIPE_SEL_MASK         REG_GENMASK(29, 28)
3947 #define   MCURSOR_PIPE_SEL(pipe)        REG_FIELD_PREP(MCURSOR_PIPE_SEL_MASK, (pipe))
3948 #define   MCURSOR_PIPE_GAMMA_ENABLE     REG_BIT(26)
3949 #define   MCURSOR_PIPE_CSC_ENABLE       REG_BIT(24) /* ilk+ */
3950 #define   MCURSOR_ROTATE_180            REG_BIT(15)
3951 #define   MCURSOR_TRICKLE_FEED_DISABLE  REG_BIT(14)
3952 #define   MCURSOR_MODE_MASK             0x27
3953 #define   MCURSOR_MODE_DISABLE          0x00
3954 #define   MCURSOR_MODE_128_32B_AX       0x02
3955 #define   MCURSOR_MODE_256_32B_AX       0x03
3956 #define   MCURSOR_MODE_64_32B_AX        0x07
3957 #define   MCURSOR_MODE_128_ARGB_AX      (0x20 | MCURSOR_MODE_128_32B_AX)
3958 #define   MCURSOR_MODE_256_ARGB_AX      (0x20 | MCURSOR_MODE_256_32B_AX)
3959 #define   MCURSOR_MODE_64_ARGB_AX       (0x20 | MCURSOR_MODE_64_32B_AX)
3960 #define _CURABASE               0x70084
3961 #define _CURAPOS                0x70088
3962 #define   CURSOR_POS_Y_SIGN             REG_BIT(31)
3963 #define   CURSOR_POS_Y_MASK             REG_GENMASK(30, 16)
3964 #define   CURSOR_POS_Y(y)               REG_FIELD_PREP(CURSOR_POS_Y_MASK, (y))
3965 #define   CURSOR_POS_X_SIGN             REG_BIT(15)
3966 #define   CURSOR_POS_X_MASK             REG_GENMASK(14, 0)
3967 #define   CURSOR_POS_X(x)               REG_FIELD_PREP(CURSOR_POS_X_MASK, (x))
3968 #define _CURASIZE               0x700a0 /* 845/865 */
3969 #define   CURSOR_HEIGHT_MASK            REG_GENMASK(21, 12)
3970 #define   CURSOR_HEIGHT(h)              REG_FIELD_PREP(CURSOR_HEIGHT_MASK, (h))
3971 #define   CURSOR_WIDTH_MASK             REG_GENMASK(9, 0)
3972 #define   CURSOR_WIDTH(w)               REG_FIELD_PREP(CURSOR_WIDTH_MASK, (w))
3973 #define _CUR_FBC_CTL_A          0x700a0 /* ivb+ */
3974 #define   CUR_FBC_EN                    REG_BIT(31)
3975 #define   CUR_FBC_HEIGHT_MASK           REG_GENMASK(7, 0)
3976 #define   CUR_FBC_HEIGHT(h)             REG_FIELD_PREP(CUR_FBC_HEIGHT_MASK, (h))
3977 #define _CURASURFLIVE           0x700ac /* g4x+ */
3978 #define _CURBCNTR               0x700c0
3979 #define _CURBBASE               0x700c4
3980 #define _CURBPOS                0x700c8
3981
3982 #define _CURBCNTR_IVB           0x71080
3983 #define _CURBBASE_IVB           0x71084
3984 #define _CURBPOS_IVB            0x71088
3985
3986 #define CURCNTR(pipe) _MMIO_CURSOR2(pipe, _CURACNTR)
3987 #define CURBASE(pipe) _MMIO_CURSOR2(pipe, _CURABASE)
3988 #define CURPOS(pipe) _MMIO_CURSOR2(pipe, _CURAPOS)
3989 #define CURSIZE(pipe) _MMIO_CURSOR2(pipe, _CURASIZE)
3990 #define CUR_FBC_CTL(pipe) _MMIO_CURSOR2(pipe, _CUR_FBC_CTL_A)
3991 #define CURSURFLIVE(pipe) _MMIO_CURSOR2(pipe, _CURASURFLIVE)
3992
3993 #define CURSOR_A_OFFSET 0x70080
3994 #define CURSOR_B_OFFSET 0x700c0
3995 #define CHV_CURSOR_C_OFFSET 0x700e0
3996 #define IVB_CURSOR_B_OFFSET 0x71080
3997 #define IVB_CURSOR_C_OFFSET 0x72080
3998 #define TGL_CURSOR_D_OFFSET 0x73080
3999
4000 /* Display A control */
4001 #define _DSPAADDR_VLV                           0x7017C /* vlv/chv */
4002 #define _DSPACNTR                               0x70180
4003 #define   DISP_ENABLE                   REG_BIT(31)
4004 #define   DISP_PIPE_GAMMA_ENABLE        REG_BIT(30)
4005 #define   DISP_FORMAT_MASK              REG_GENMASK(29, 26)
4006 #define   DISP_FORMAT_8BPP              REG_FIELD_PREP(DISP_FORMAT_MASK, 2)
4007 #define   DISP_FORMAT_BGRA555           REG_FIELD_PREP(DISP_FORMAT_MASK, 3)
4008 #define   DISP_FORMAT_BGRX555           REG_FIELD_PREP(DISP_FORMAT_MASK, 4)
4009 #define   DISP_FORMAT_BGRX565           REG_FIELD_PREP(DISP_FORMAT_MASK, 5)
4010 #define   DISP_FORMAT_BGRX888           REG_FIELD_PREP(DISP_FORMAT_MASK, 6)
4011 #define   DISP_FORMAT_BGRA888           REG_FIELD_PREP(DISP_FORMAT_MASK, 7)
4012 #define   DISP_FORMAT_RGBX101010        REG_FIELD_PREP(DISP_FORMAT_MASK, 8)
4013 #define   DISP_FORMAT_RGBA101010        REG_FIELD_PREP(DISP_FORMAT_MASK, 9)
4014 #define   DISP_FORMAT_BGRX101010        REG_FIELD_PREP(DISP_FORMAT_MASK, 10)
4015 #define   DISP_FORMAT_BGRA101010        REG_FIELD_PREP(DISP_FORMAT_MASK, 11)
4016 #define   DISP_FORMAT_RGBX161616        REG_FIELD_PREP(DISP_FORMAT_MASK, 12)
4017 #define   DISP_FORMAT_RGBX888           REG_FIELD_PREP(DISP_FORMAT_MASK, 14)
4018 #define   DISP_FORMAT_RGBA888           REG_FIELD_PREP(DISP_FORMAT_MASK, 15)
4019 #define   DISP_STEREO_ENABLE            REG_BIT(25)
4020 #define   DISP_PIPE_CSC_ENABLE          REG_BIT(24) /* ilk+ */
4021 #define   DISP_PIPE_SEL_MASK            REG_GENMASK(25, 24)
4022 #define   DISP_PIPE_SEL(pipe)           REG_FIELD_PREP(DISP_PIPE_SEL_MASK, (pipe))
4023 #define   DISP_SRC_KEY_ENABLE           REG_BIT(22)
4024 #define   DISP_LINE_DOUBLE              REG_BIT(20)
4025 #define   DISP_STEREO_POLARITY_SECOND   REG_BIT(18)
4026 #define   DISP_ALPHA_PREMULTIPLY        REG_BIT(16) /* CHV pipe B */
4027 #define   DISP_ROTATE_180               REG_BIT(15)
4028 #define   DISP_TRICKLE_FEED_DISABLE     REG_BIT(14) /* g4x+ */
4029 #define   DISP_TILED                    REG_BIT(10)
4030 #define   DISP_ASYNC_FLIP               REG_BIT(9) /* g4x+ */
4031 #define   DISP_MIRROR                   REG_BIT(8) /* CHV pipe B */
4032 #define _DSPAADDR                               0x70184
4033 #define _DSPASTRIDE                             0x70188
4034 #define _DSPAPOS                                0x7018C /* reserved */
4035 #define   DISP_POS_Y_MASK               REG_GENMASK(31, 16)
4036 #define   DISP_POS_Y(y)                 REG_FIELD_PREP(DISP_POS_Y_MASK, (y))
4037 #define   DISP_POS_X_MASK               REG_GENMASK(15, 0)
4038 #define   DISP_POS_X(x)                 REG_FIELD_PREP(DISP_POS_X_MASK, (x))
4039 #define _DSPASIZE                               0x70190
4040 #define   DISP_HEIGHT_MASK              REG_GENMASK(31, 16)
4041 #define   DISP_HEIGHT(h)                REG_FIELD_PREP(DISP_HEIGHT_MASK, (h))
4042 #define   DISP_WIDTH_MASK               REG_GENMASK(15, 0)
4043 #define   DISP_WIDTH(w)                 REG_FIELD_PREP(DISP_WIDTH_MASK, (w))
4044 #define _DSPASURF                               0x7019C /* 965+ only */
4045 #define   DISP_ADDR_MASK                REG_GENMASK(31, 12)
4046 #define _DSPATILEOFF                            0x701A4 /* 965+ only */
4047 #define   DISP_OFFSET_Y_MASK            REG_GENMASK(31, 16)
4048 #define   DISP_OFFSET_Y(y)              REG_FIELD_PREP(DISP_OFFSET_Y_MASK, (y))
4049 #define   DISP_OFFSET_X_MASK            REG_GENMASK(15, 0)
4050 #define   DISP_OFFSET_X(x)              REG_FIELD_PREP(DISP_OFFSET_X_MASK, (x))
4051 #define _DSPAOFFSET                             0x701A4 /* HSW */
4052 #define _DSPASURFLIVE                           0x701AC
4053 #define _DSPAGAMC                               0x701E0
4054
4055 #define DSPADDR_VLV(plane)      _MMIO_PIPE2(plane, _DSPAADDR_VLV)
4056 #define DSPCNTR(plane)          _MMIO_PIPE2(plane, _DSPACNTR)
4057 #define DSPADDR(plane)          _MMIO_PIPE2(plane, _DSPAADDR)
4058 #define DSPSTRIDE(plane)        _MMIO_PIPE2(plane, _DSPASTRIDE)
4059 #define DSPPOS(plane)           _MMIO_PIPE2(plane, _DSPAPOS)
4060 #define DSPSIZE(plane)          _MMIO_PIPE2(plane, _DSPASIZE)
4061 #define DSPSURF(plane)          _MMIO_PIPE2(plane, _DSPASURF)
4062 #define DSPTILEOFF(plane)       _MMIO_PIPE2(plane, _DSPATILEOFF)
4063 #define DSPLINOFF(plane)        DSPADDR(plane)
4064 #define DSPOFFSET(plane)        _MMIO_PIPE2(plane, _DSPAOFFSET)
4065 #define DSPSURFLIVE(plane)      _MMIO_PIPE2(plane, _DSPASURFLIVE)
4066 #define DSPGAMC(plane, i)       _MMIO_PIPE2(plane, _DSPAGAMC + (5 - (i)) * 4) /* plane C only, 6 x u0.8 */
4067
4068 /* CHV pipe B blender and primary plane */
4069 #define _CHV_BLEND_A            0x60a00
4070 #define   CHV_BLEND_MASK        REG_GENMASK(31, 30)
4071 #define   CHV_BLEND_LEGACY      REG_FIELD_PREP(CHV_BLEND_MASK, 0)
4072 #define   CHV_BLEND_ANDROID     REG_FIELD_PREP(CHV_BLEND_MASK, 1)
4073 #define   CHV_BLEND_MPO         REG_FIELD_PREP(CHV_BLEND_MASK, 2)
4074 #define _CHV_CANVAS_A           0x60a04
4075 #define   CHV_CANVAS_RED_MASK   REG_GENMASK(29, 20)
4076 #define   CHV_CANVAS_GREEN_MASK REG_GENMASK(19, 10)
4077 #define   CHV_CANVAS_BLUE_MASK  REG_GENMASK(9, 0)
4078 #define _PRIMPOS_A              0x60a08
4079 #define   PRIM_POS_Y_MASK       REG_GENMASK(31, 16)
4080 #define   PRIM_POS_Y(y)         REG_FIELD_PREP(PRIM_POS_Y_MASK, (y))
4081 #define   PRIM_POS_X_MASK       REG_GENMASK(15, 0)
4082 #define   PRIM_POS_X(x)         REG_FIELD_PREP(PRIM_POS_X_MASK, (x))
4083 #define _PRIMSIZE_A             0x60a0c
4084 #define   PRIM_HEIGHT_MASK      REG_GENMASK(31, 16)
4085 #define   PRIM_HEIGHT(h)        REG_FIELD_PREP(PRIM_HEIGHT_MASK, (h))
4086 #define   PRIM_WIDTH_MASK       REG_GENMASK(15, 0)
4087 #define   PRIM_WIDTH(w)         REG_FIELD_PREP(PRIM_WIDTH_MASK, (w))
4088 #define _PRIMCNSTALPHA_A        0x60a10
4089 #define   PRIM_CONST_ALPHA_ENABLE       REG_BIT(31)
4090 #define   PRIM_CONST_ALPHA_MASK         REG_GENMASK(7, 0)
4091 #define   PRIM_CONST_ALPHA(alpha)       REG_FIELD_PREP(PRIM_CONST_ALPHA_MASK, (alpha))
4092
4093 #define CHV_BLEND(pipe)         _MMIO_TRANS2(pipe, _CHV_BLEND_A)
4094 #define CHV_CANVAS(pipe)        _MMIO_TRANS2(pipe, _CHV_CANVAS_A)
4095 #define PRIMPOS(plane)          _MMIO_TRANS2(plane, _PRIMPOS_A)
4096 #define PRIMSIZE(plane)         _MMIO_TRANS2(plane, _PRIMSIZE_A)
4097 #define PRIMCNSTALPHA(plane)    _MMIO_TRANS2(plane, _PRIMCNSTALPHA_A)
4098
4099 /* Display/Sprite base address macros */
4100 #define DISP_BASEADDR_MASK      (0xfffff000)
4101 #define I915_LO_DISPBASE(val)   ((val) & ~DISP_BASEADDR_MASK)
4102 #define I915_HI_DISPBASE(val)   ((val) & DISP_BASEADDR_MASK)
4103
4104 /*
4105  * VBIOS flags
4106  * gen2:
4107  * [00:06] alm,mgm
4108  * [10:16] all
4109  * [30:32] alm,mgm
4110  * gen3+:
4111  * [00:0f] all
4112  * [10:1f] all
4113  * [30:32] all
4114  */
4115 #define SWF0(i) _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x70410 + (i) * 4)
4116 #define SWF1(i) _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x71410 + (i) * 4)
4117 #define SWF3(i) _MMIO(DISPLAY_MMIO_BASE(dev_priv) + 0x72414 + (i) * 4)
4118 #define SWF_ILK(i)      _MMIO(0x4F000 + (i) * 4)
4119
4120 /* Pipe B */
4121 #define _PIPEBDSL               (DISPLAY_MMIO_BASE(dev_priv) + 0x71000)
4122 #define _TRANSBCONF             (DISPLAY_MMIO_BASE(dev_priv) + 0x71008)
4123 #define _PIPEBSTAT              (DISPLAY_MMIO_BASE(dev_priv) + 0x71024)
4124 #define _PIPEBFRAMEHIGH         0x71040
4125 #define _PIPEBFRAMEPIXEL        0x71044
4126 #define _PIPEB_FRMCOUNT_G4X     (DISPLAY_MMIO_BASE(dev_priv) + 0x71040)
4127 #define _PIPEB_FLIPCOUNT_G4X    (DISPLAY_MMIO_BASE(dev_priv) + 0x71044)
4128
4129
4130 /* Display B control */
4131 #define _DSPBCNTR               (DISPLAY_MMIO_BASE(dev_priv) + 0x71180)
4132 #define   DISP_ALPHA_TRANS_ENABLE       REG_BIT(15)
4133 #define   DISP_SPRITE_ABOVE_OVERLAY     REG_BIT(0)
4134 #define _DSPBADDR               (DISPLAY_MMIO_BASE(dev_priv) + 0x71184)
4135 #define _DSPBSTRIDE             (DISPLAY_MMIO_BASE(dev_priv) + 0x71188)
4136 #define _DSPBPOS                (DISPLAY_MMIO_BASE(dev_priv) + 0x7118C)
4137 #define _DSPBSIZE               (DISPLAY_MMIO_BASE(dev_priv) + 0x71190)
4138 #define _DSPBSURF               (DISPLAY_MMIO_BASE(dev_priv) + 0x7119C)
4139 #define _DSPBTILEOFF            (DISPLAY_MMIO_BASE(dev_priv) + 0x711A4)
4140 #define _DSPBOFFSET             (DISPLAY_MMIO_BASE(dev_priv) + 0x711A4)
4141 #define _DSPBSURFLIVE           (DISPLAY_MMIO_BASE(dev_priv) + 0x711AC)
4142
4143 /* ICL DSI 0 and 1 */
4144 #define _PIPEDSI0CONF           0x7b008
4145 #define _PIPEDSI1CONF           0x7b808
4146
4147 /* Sprite A control */
4148 #define _DVSACNTR               0x72180
4149 #define   DVS_ENABLE                    REG_BIT(31)
4150 #define   DVS_PIPE_GAMMA_ENABLE         REG_BIT(30)
4151 #define   DVS_YUV_RANGE_CORRECTION_DISABLE      REG_BIT(27)
4152 #define   DVS_FORMAT_MASK               REG_GENMASK(26, 25)
4153 #define   DVS_FORMAT_YUV422             REG_FIELD_PREP(DVS_FORMAT_MASK, 0)
4154 #define   DVS_FORMAT_RGBX101010         REG_FIELD_PREP(DVS_FORMAT_MASK, 1)
4155 #define   DVS_FORMAT_RGBX888            REG_FIELD_PREP(DVS_FORMAT_MASK, 2)
4156 #define   DVS_FORMAT_RGBX161616         REG_FIELD_PREP(DVS_FORMAT_MASK, 3)
4157 #define   DVS_PIPE_CSC_ENABLE           REG_BIT(24)
4158 #define   DVS_SOURCE_KEY                REG_BIT(22)
4159 #define   DVS_RGB_ORDER_XBGR            REG_BIT(20)
4160 #define   DVS_YUV_FORMAT_BT709          REG_BIT(18)
4161 #define   DVS_YUV_ORDER_MASK            REG_GENMASK(17, 16)
4162 #define   DVS_YUV_ORDER_YUYV            REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 0)
4163 #define   DVS_YUV_ORDER_UYVY            REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 1)
4164 #define   DVS_YUV_ORDER_YVYU            REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 2)
4165 #define   DVS_YUV_ORDER_VYUY            REG_FIELD_PREP(DVS_YUV_ORDER_MASK, 3)
4166 #define   DVS_ROTATE_180                REG_BIT(15)
4167 #define   DVS_TRICKLE_FEED_DISABLE      REG_BIT(14)
4168 #define   DVS_TILED                     REG_BIT(10)
4169 #define   DVS_DEST_KEY                  REG_BIT(2)
4170 #define _DVSALINOFF             0x72184
4171 #define _DVSASTRIDE             0x72188
4172 #define _DVSAPOS                0x7218c
4173 #define   DVS_POS_Y_MASK                REG_GENMASK(31, 16)
4174 #define   DVS_POS_Y(y)                  REG_FIELD_PREP(DVS_POS_Y_MASK, (y))
4175 #define   DVS_POS_X_MASK                REG_GENMASK(15, 0)
4176 #define   DVS_POS_X(x)                  REG_FIELD_PREP(DVS_POS_X_MASK, (x))
4177 #define _DVSASIZE               0x72190
4178 #define   DVS_HEIGHT_MASK               REG_GENMASK(31, 16)
4179 #define   DVS_HEIGHT(h)                 REG_FIELD_PREP(DVS_HEIGHT_MASK, (h))
4180 #define   DVS_WIDTH_MASK                REG_GENMASK(15, 0)
4181 #define   DVS_WIDTH(w)                  REG_FIELD_PREP(DVS_WIDTH_MASK, (w))
4182 #define _DVSAKEYVAL             0x72194
4183 #define _DVSAKEYMSK             0x72198
4184 #define _DVSASURF               0x7219c
4185 #define   DVS_ADDR_MASK                 REG_GENMASK(31, 12)
4186 #define _DVSAKEYMAXVAL          0x721a0
4187 #define _DVSATILEOFF            0x721a4
4188 #define   DVS_OFFSET_Y_MASK             REG_GENMASK(31, 16)
4189 #define   DVS_OFFSET_Y(y)               REG_FIELD_PREP(DVS_OFFSET_Y_MASK, (y))
4190 #define   DVS_OFFSET_X_MASK             REG_GENMASK(15, 0)
4191 #define   DVS_OFFSET_X(x)               REG_FIELD_PREP(DVS_OFFSET_X_MASK, (x))
4192 #define _DVSASURFLIVE           0x721ac
4193 #define _DVSAGAMC_G4X           0x721e0 /* g4x */
4194 #define _DVSASCALE              0x72204
4195 #define   DVS_SCALE_ENABLE              REG_BIT(31)
4196 #define   DVS_FILTER_MASK               REG_GENMASK(30, 29)
4197 #define   DVS_FILTER_MEDIUM             REG_FIELD_PREP(DVS_FILTER_MASK, 0)
4198 #define   DVS_FILTER_ENHANCING          REG_FIELD_PREP(DVS_FILTER_MASK, 1)
4199 #define   DVS_FILTER_SOFTENING          REG_FIELD_PREP(DVS_FILTER_MASK, 2)
4200 #define   DVS_VERTICAL_OFFSET_HALF      REG_BIT(28) /* must be enabled below */
4201 #define   DVS_VERTICAL_OFFSET_ENABLE    REG_BIT(27)
4202 #define   DVS_SRC_WIDTH_MASK            REG_GENMASK(26, 16)
4203 #define   DVS_SRC_WIDTH(w)              REG_FIELD_PREP(DVS_SRC_WIDTH_MASK, (w))
4204 #define   DVS_SRC_HEIGHT_MASK           REG_GENMASK(10, 0)
4205 #define   DVS_SRC_HEIGHT(h)             REG_FIELD_PREP(DVS_SRC_HEIGHT_MASK, (h))
4206 #define _DVSAGAMC_ILK           0x72300 /* ilk/snb */
4207 #define _DVSAGAMCMAX_ILK        0x72340 /* ilk/snb */
4208
4209 #define _DVSBCNTR               0x73180
4210 #define _DVSBLINOFF             0x73184
4211 #define _DVSBSTRIDE             0x73188
4212 #define _DVSBPOS                0x7318c
4213 #define _DVSBSIZE               0x73190
4214 #define _DVSBKEYVAL             0x73194
4215 #define _DVSBKEYMSK             0x73198
4216 #define _DVSBSURF               0x7319c
4217 #define _DVSBKEYMAXVAL          0x731a0
4218 #define _DVSBTILEOFF            0x731a4
4219 #define _DVSBSURFLIVE           0x731ac
4220 #define _DVSBGAMC_G4X           0x731e0 /* g4x */
4221 #define _DVSBSCALE              0x73204
4222 #define _DVSBGAMC_ILK           0x73300 /* ilk/snb */
4223 #define _DVSBGAMCMAX_ILK        0x73340 /* ilk/snb */
4224
4225 #define DVSCNTR(pipe) _MMIO_PIPE(pipe, _DVSACNTR, _DVSBCNTR)
4226 #define DVSLINOFF(pipe) _MMIO_PIPE(pipe, _DVSALINOFF, _DVSBLINOFF)
4227 #define DVSSTRIDE(pipe) _MMIO_PIPE(pipe, _DVSASTRIDE, _DVSBSTRIDE)
4228 #define DVSPOS(pipe) _MMIO_PIPE(pipe, _DVSAPOS, _DVSBPOS)
4229 #define DVSSURF(pipe) _MMIO_PIPE(pipe, _DVSASURF, _DVSBSURF)
4230 #define DVSKEYMAX(pipe) _MMIO_PIPE(pipe, _DVSAKEYMAXVAL, _DVSBKEYMAXVAL)
4231 #define DVSSIZE(pipe) _MMIO_PIPE(pipe, _DVSASIZE, _DVSBSIZE)
4232 #define DVSSCALE(pipe) _MMIO_PIPE(pipe, _DVSASCALE, _DVSBSCALE)
4233 #define DVSTILEOFF(pipe) _MMIO_PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
4234 #define DVSKEYVAL(pipe) _MMIO_PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
4235 #define DVSKEYMSK(pipe) _MMIO_PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
4236 #define DVSSURFLIVE(pipe) _MMIO_PIPE(pipe, _DVSASURFLIVE, _DVSBSURFLIVE)
4237 #define DVSGAMC_G4X(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMC_G4X, _DVSBGAMC_G4X) + (5 - (i)) * 4) /* 6 x u0.8 */
4238 #define DVSGAMC_ILK(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMC_ILK, _DVSBGAMC_ILK) + (i) * 4) /* 16 x u0.10 */
4239 #define DVSGAMCMAX_ILK(pipe, i) _MMIO(_PIPE(pipe, _DVSAGAMCMAX_ILK, _DVSBGAMCMAX_ILK) + (i) * 4) /* 3 x u1.10 */
4240
4241 #define _SPRA_CTL               0x70280
4242 #define   SPRITE_ENABLE                         REG_BIT(31)
4243 #define   SPRITE_PIPE_GAMMA_ENABLE              REG_BIT(30)
4244 #define   SPRITE_YUV_RANGE_CORRECTION_DISABLE   REG_BIT(28)
4245 #define   SPRITE_FORMAT_MASK                    REG_GENMASK(27, 25)
4246 #define   SPRITE_FORMAT_YUV422                  REG_FIELD_PREP(SPRITE_FORMAT_MASK, 0)
4247 #define   SPRITE_FORMAT_RGBX101010              REG_FIELD_PREP(SPRITE_FORMAT_MASK, 1)
4248 #define   SPRITE_FORMAT_RGBX888                 REG_FIELD_PREP(SPRITE_FORMAT_MASK, 2)
4249 #define   SPRITE_FORMAT_RGBX161616              REG_FIELD_PREP(SPRITE_FORMAT_MASK, 3)
4250 #define   SPRITE_FORMAT_YUV444                  REG_FIELD_PREP(SPRITE_FORMAT_MASK, 4)
4251 #define   SPRITE_FORMAT_XR_BGR101010            REG_FIELD_PREP(SPRITE_FORMAT_MASK, 5) /* Extended range */
4252 #define   SPRITE_PIPE_CSC_ENABLE                REG_BIT(24)
4253 #define   SPRITE_SOURCE_KEY                     REG_BIT(22)
4254 #define   SPRITE_RGB_ORDER_RGBX                 REG_BIT(20) /* only for 888 and 161616 */
4255 #define   SPRITE_YUV_TO_RGB_CSC_DISABLE         REG_BIT(19)
4256 #define   SPRITE_YUV_TO_RGB_CSC_FORMAT_BT709    REG_BIT(18) /* 0 is BT601 */
4257 #define   SPRITE_YUV_ORDER_MASK                 REG_GENMASK(17, 16)
4258 #define   SPRITE_YUV_ORDER_YUYV                 REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 0)
4259 #define   SPRITE_YUV_ORDER_UYVY                 REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 1)
4260 #define   SPRITE_YUV_ORDER_YVYU                 REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 2)
4261 #define   SPRITE_YUV_ORDER_VYUY                 REG_FIELD_PREP(SPRITE_YUV_ORDER_MASK, 3)
4262 #define   SPRITE_ROTATE_180                     REG_BIT(15)
4263 #define   SPRITE_TRICKLE_FEED_DISABLE           REG_BIT(14)
4264 #define   SPRITE_PLANE_GAMMA_DISABLE            REG_BIT(13)
4265 #define   SPRITE_TILED                          REG_BIT(10)
4266 #define   SPRITE_DEST_KEY                       REG_BIT(2)
4267 #define _SPRA_LINOFF            0x70284
4268 #define _SPRA_STRIDE            0x70288
4269 #define _SPRA_POS               0x7028c
4270 #define   SPRITE_POS_Y_MASK     REG_GENMASK(31, 16)
4271 #define   SPRITE_POS_Y(y)       REG_FIELD_PREP(SPRITE_POS_Y_MASK, (y))
4272 #define   SPRITE_POS_X_MASK     REG_GENMASK(15, 0)
4273 #define   SPRITE_POS_X(x)       REG_FIELD_PREP(SPRITE_POS_X_MASK, (x))
4274 #define _SPRA_SIZE              0x70290
4275 #define   SPRITE_HEIGHT_MASK    REG_GENMASK(31, 16)
4276 #define   SPRITE_HEIGHT(h)      REG_FIELD_PREP(SPRITE_HEIGHT_MASK, (h))
4277 #define   SPRITE_WIDTH_MASK     REG_GENMASK(15, 0)
4278 #define   SPRITE_WIDTH(w)       REG_FIELD_PREP(SPRITE_WIDTH_MASK, (w))
4279 #define _SPRA_KEYVAL            0x70294
4280 #define _SPRA_KEYMSK            0x70298
4281 #define _SPRA_SURF              0x7029c
4282 #define   SPRITE_ADDR_MASK      REG_GENMASK(31, 12)
4283 #define _SPRA_KEYMAX            0x702a0
4284 #define _SPRA_TILEOFF           0x702a4
4285 #define   SPRITE_OFFSET_Y_MASK  REG_GENMASK(31, 16)
4286 #define   SPRITE_OFFSET_Y(y)    REG_FIELD_PREP(SPRITE_OFFSET_Y_MASK, (y))
4287 #define   SPRITE_OFFSET_X_MASK  REG_GENMASK(15, 0)
4288 #define   SPRITE_OFFSET_X(x)    REG_FIELD_PREP(SPRITE_OFFSET_X_MASK, (x))
4289 #define _SPRA_OFFSET            0x702a4
4290 #define _SPRA_SURFLIVE          0x702ac
4291 #define _SPRA_SCALE             0x70304
4292 #define   SPRITE_SCALE_ENABLE                   REG_BIT(31)
4293 #define   SPRITE_FILTER_MASK                    REG_GENMASK(30, 29)
4294 #define   SPRITE_FILTER_MEDIUM                  REG_FIELD_PREP(SPRITE_FILTER_MASK, 0)
4295 #define   SPRITE_FILTER_ENHANCING               REG_FIELD_PREP(SPRITE_FILTER_MASK, 1)
4296 #define   SPRITE_FILTER_SOFTENING               REG_FIELD_PREP(SPRITE_FILTER_MASK, 2)
4297 #define   SPRITE_VERTICAL_OFFSET_HALF           REG_BIT(28) /* must be enabled below */
4298 #define   SPRITE_VERTICAL_OFFSET_ENABLE         REG_BIT(27)
4299 #define   SPRITE_SRC_WIDTH_MASK                 REG_GENMASK(26, 16)
4300 #define   SPRITE_SRC_WIDTH(w)                   REG_FIELD_PREP(SPRITE_SRC_WIDTH_MASK, (w))
4301 #define   SPRITE_SRC_HEIGHT_MASK                REG_GENMASK(10, 0)
4302 #define   SPRITE_SRC_HEIGHT(h)                  REG_FIELD_PREP(SPRITE_SRC_HEIGHT_MASK, (h))
4303 #define _SPRA_GAMC              0x70400
4304 #define _SPRA_GAMC16            0x70440
4305 #define _SPRA_GAMC17            0x7044c
4306
4307 #define _SPRB_CTL               0x71280
4308 #define _SPRB_LINOFF            0x71284
4309 #define _SPRB_STRIDE            0x71288
4310 #define _SPRB_POS               0x7128c
4311 #define _SPRB_SIZE              0x71290
4312 #define _SPRB_KEYVAL            0x71294
4313 #define _SPRB_KEYMSK            0x71298
4314 #define _SPRB_SURF              0x7129c
4315 #define _SPRB_KEYMAX            0x712a0
4316 #define _SPRB_TILEOFF           0x712a4
4317 #define _SPRB_OFFSET            0x712a4
4318 #define _SPRB_SURFLIVE          0x712ac
4319 #define _SPRB_SCALE             0x71304
4320 #define _SPRB_GAMC              0x71400
4321 #define _SPRB_GAMC16            0x71440
4322 #define _SPRB_GAMC17            0x7144c
4323
4324 #define SPRCTL(pipe) _MMIO_PIPE(pipe, _SPRA_CTL, _SPRB_CTL)
4325 #define SPRLINOFF(pipe) _MMIO_PIPE(pipe, _SPRA_LINOFF, _SPRB_LINOFF)
4326 #define SPRSTRIDE(pipe) _MMIO_PIPE(pipe, _SPRA_STRIDE, _SPRB_STRIDE)
4327 #define SPRPOS(pipe) _MMIO_PIPE(pipe, _SPRA_POS, _SPRB_POS)
4328 #define SPRSIZE(pipe) _MMIO_PIPE(pipe, _SPRA_SIZE, _SPRB_SIZE)
4329 #define SPRKEYVAL(pipe) _MMIO_PIPE(pipe, _SPRA_KEYVAL, _SPRB_KEYVAL)
4330 #define SPRKEYMSK(pipe) _MMIO_PIPE(pipe, _SPRA_KEYMSK, _SPRB_KEYMSK)
4331 #define SPRSURF(pipe) _MMIO_PIPE(pipe, _SPRA_SURF, _SPRB_SURF)
4332 #define SPRKEYMAX(pipe) _MMIO_PIPE(pipe, _SPRA_KEYMAX, _SPRB_KEYMAX)
4333 #define SPRTILEOFF(pipe) _MMIO_PIPE(pipe, _SPRA_TILEOFF, _SPRB_TILEOFF)
4334 #define SPROFFSET(pipe) _MMIO_PIPE(pipe, _SPRA_OFFSET, _SPRB_OFFSET)
4335 #define SPRSCALE(pipe) _MMIO_PIPE(pipe, _SPRA_SCALE, _SPRB_SCALE)
4336 #define SPRGAMC(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC) + (i) * 4) /* 16 x u0.10 */
4337 #define SPRGAMC16(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC16, _SPRB_GAMC16) + (i) * 4) /* 3 x u1.10 */
4338 #define SPRGAMC17(pipe, i) _MMIO(_PIPE(pipe, _SPRA_GAMC17, _SPRB_GAMC17) + (i) * 4) /* 3 x u2.10 */
4339 #define SPRSURFLIVE(pipe) _MMIO_PIPE(pipe, _SPRA_SURFLIVE, _SPRB_SURFLIVE)
4340
4341 #define _SPACNTR                (VLV_DISPLAY_BASE + 0x72180)
4342 #define   SP_ENABLE                     REG_BIT(31)
4343 #define   SP_PIPE_GAMMA_ENABLE          REG_BIT(30)
4344 #define   SP_FORMAT_MASK                REG_GENMASK(29, 26)
4345 #define   SP_FORMAT_YUV422              REG_FIELD_PREP(SP_FORMAT_MASK, 0)
4346 #define   SP_FORMAT_8BPP                REG_FIELD_PREP(SP_FORMAT_MASK, 2)
4347 #define   SP_FORMAT_BGR565              REG_FIELD_PREP(SP_FORMAT_MASK, 5)
4348 #define   SP_FORMAT_BGRX8888            REG_FIELD_PREP(SP_FORMAT_MASK, 6)
4349 #define   SP_FORMAT_BGRA8888            REG_FIELD_PREP(SP_FORMAT_MASK, 7)
4350 #define   SP_FORMAT_RGBX1010102         REG_FIELD_PREP(SP_FORMAT_MASK, 8)
4351 #define   SP_FORMAT_RGBA1010102         REG_FIELD_PREP(SP_FORMAT_MASK, 9)
4352 #define   SP_FORMAT_BGRX1010102         REG_FIELD_PREP(SP_FORMAT_MASK, 10) /* CHV pipe B */
4353 #define   SP_FORMAT_BGRA1010102         REG_FIELD_PREP(SP_FORMAT_MASK, 11) /* CHV pipe B */
4354 #define   SP_FORMAT_RGBX8888            REG_FIELD_PREP(SP_FORMAT_MASK, 14)
4355 #define   SP_FORMAT_RGBA8888            REG_FIELD_PREP(SP_FORMAT_MASK, 15)
4356 #define   SP_ALPHA_PREMULTIPLY          REG_BIT(23) /* CHV pipe B */
4357 #define   SP_SOURCE_KEY                 REG_BIT(22)
4358 #define   SP_YUV_FORMAT_BT709           REG_BIT(18)
4359 #define   SP_YUV_ORDER_MASK             REG_GENMASK(17, 16)
4360 #define   SP_YUV_ORDER_YUYV             REG_FIELD_PREP(SP_YUV_ORDER_MASK, 0)
4361 #define   SP_YUV_ORDER_UYVY             REG_FIELD_PREP(SP_YUV_ORDER_MASK, 1)
4362 #define   SP_YUV_ORDER_YVYU             REG_FIELD_PREP(SP_YUV_ORDER_MASK, 2)
4363 #define   SP_YUV_ORDER_VYUY             REG_FIELD_PREP(SP_YUV_ORDER_MASK, 3)
4364 #define   SP_ROTATE_180                 REG_BIT(15)
4365 #define   SP_TILED                      REG_BIT(10)
4366 #define   SP_MIRROR                     REG_BIT(8) /* CHV pipe B */
4367 #define _SPALINOFF              (VLV_DISPLAY_BASE + 0x72184)
4368 #define _SPASTRIDE              (VLV_DISPLAY_BASE + 0x72188)
4369 #define _SPAPOS                 (VLV_DISPLAY_BASE + 0x7218c)
4370 #define   SP_POS_Y_MASK                 REG_GENMASK(31, 16)
4371 #define   SP_POS_Y(y)                   REG_FIELD_PREP(SP_POS_Y_MASK, (y))
4372 #define   SP_POS_X_MASK                 REG_GENMASK(15, 0)
4373 #define   SP_POS_X(x)                   REG_FIELD_PREP(SP_POS_X_MASK, (x))
4374 #define _SPASIZE                (VLV_DISPLAY_BASE + 0x72190)
4375 #define   SP_HEIGHT_MASK                REG_GENMASK(31, 16)
4376 #define   SP_HEIGHT(h)                  REG_FIELD_PREP(SP_HEIGHT_MASK, (h))
4377 #define   SP_WIDTH_MASK                 REG_GENMASK(15, 0)
4378 #define   SP_WIDTH(w)                   REG_FIELD_PREP(SP_WIDTH_MASK, (w))
4379 #define _SPAKEYMINVAL           (VLV_DISPLAY_BASE + 0x72194)
4380 #define _SPAKEYMSK              (VLV_DISPLAY_BASE + 0x72198)
4381 #define _SPASURF                (VLV_DISPLAY_BASE + 0x7219c)
4382 #define   SP_ADDR_MASK                  REG_GENMASK(31, 12)
4383 #define _SPAKEYMAXVAL           (VLV_DISPLAY_BASE + 0x721a0)
4384 #define _SPATILEOFF             (VLV_DISPLAY_BASE + 0x721a4)
4385 #define   SP_OFFSET_Y_MASK              REG_GENMASK(31, 16)
4386 #define   SP_OFFSET_Y(y)                REG_FIELD_PREP(SP_OFFSET_Y_MASK, (y))
4387 #define   SP_OFFSET_X_MASK              REG_GENMASK(15, 0)
4388 #define   SP_OFFSET_X(x)                REG_FIELD_PREP(SP_OFFSET_X_MASK, (x))
4389 #define _SPACONSTALPHA          (VLV_DISPLAY_BASE + 0x721a8)
4390 #define   SP_CONST_ALPHA_ENABLE         REG_BIT(31)
4391 #define   SP_CONST_ALPHA_MASK           REG_GENMASK(7, 0)
4392 #define   SP_CONST_ALPHA(alpha)         REG_FIELD_PREP(SP_CONST_ALPHA_MASK, (alpha))
4393 #define _SPACLRC0               (VLV_DISPLAY_BASE + 0x721d0)
4394 #define   SP_CONTRAST_MASK              REG_GENMASK(26, 18)
4395 #define   SP_CONTRAST(x)                REG_FIELD_PREP(SP_CONTRAST_MASK, (x)) /* u3.6 */
4396 #define   SP_BRIGHTNESS_MASK            REG_GENMASK(7, 0)
4397 #define   SP_BRIGHTNESS(x)              REG_FIELD_PREP(SP_BRIGHTNESS_MASK, (x)) /* s8 */
4398 #define _SPACLRC1               (VLV_DISPLAY_BASE + 0x721d4)
4399 #define   SP_SH_SIN_MASK                REG_GENMASK(26, 16)
4400 #define   SP_SH_SIN(x)                  REG_FIELD_PREP(SP_SH_SIN_MASK, (x)) /* s4.7 */
4401 #define   SP_SH_COS_MASK                REG_GENMASK(9, 0)
4402 #define   SP_SH_COS(x)                  REG_FIELD_PREP(SP_SH_COS_MASK, (x)) /* u3.7 */
4403 #define _SPAGAMC                (VLV_DISPLAY_BASE + 0x721e0)
4404
4405 #define _SPBCNTR                (VLV_DISPLAY_BASE + 0x72280)
4406 #define _SPBLINOFF              (VLV_DISPLAY_BASE + 0x72284)
4407 #define _SPBSTRIDE              (VLV_DISPLAY_BASE + 0x72288)
4408 #define _SPBPOS                 (VLV_DISPLAY_BASE + 0x7228c)
4409 #define _SPBSIZE                (VLV_DISPLAY_BASE + 0x72290)
4410 #define _SPBKEYMINVAL           (VLV_DISPLAY_BASE + 0x72294)
4411 #define _SPBKEYMSK              (VLV_DISPLAY_BASE + 0x72298)
4412 #define _SPBSURF                (VLV_DISPLAY_BASE + 0x7229c)
4413 #define _SPBKEYMAXVAL           (VLV_DISPLAY_BASE + 0x722a0)
4414 #define _SPBTILEOFF             (VLV_DISPLAY_BASE + 0x722a4)
4415 #define _SPBCONSTALPHA          (VLV_DISPLAY_BASE + 0x722a8)
4416 #define _SPBCLRC0               (VLV_DISPLAY_BASE + 0x722d0)
4417 #define _SPBCLRC1               (VLV_DISPLAY_BASE + 0x722d4)
4418 #define _SPBGAMC                (VLV_DISPLAY_BASE + 0x722e0)
4419
4420 #define _VLV_SPR(pipe, plane_id, reg_a, reg_b) \
4421         _PIPE((pipe) * 2 + (plane_id) - PLANE_SPRITE0, (reg_a), (reg_b))
4422 #define _MMIO_VLV_SPR(pipe, plane_id, reg_a, reg_b) \
4423         _MMIO(_VLV_SPR((pipe), (plane_id), (reg_a), (reg_b)))
4424
4425 #define SPCNTR(pipe, plane_id)          _MMIO_VLV_SPR((pipe), (plane_id), _SPACNTR, _SPBCNTR)
4426 #define SPLINOFF(pipe, plane_id)        _MMIO_VLV_SPR((pipe), (plane_id), _SPALINOFF, _SPBLINOFF)
4427 #define SPSTRIDE(pipe, plane_id)        _MMIO_VLV_SPR((pipe), (plane_id), _SPASTRIDE, _SPBSTRIDE)
4428 #define SPPOS(pipe, plane_id)           _MMIO_VLV_SPR((pipe), (plane_id), _SPAPOS, _SPBPOS)
4429 #define SPSIZE(pipe, plane_id)          _MMIO_VLV_SPR((pipe), (plane_id), _SPASIZE, _SPBSIZE)
4430 #define SPKEYMINVAL(pipe, plane_id)     _MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMINVAL, _SPBKEYMINVAL)
4431 #define SPKEYMSK(pipe, plane_id)        _MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMSK, _SPBKEYMSK)
4432 #define SPSURF(pipe, plane_id)          _MMIO_VLV_SPR((pipe), (plane_id), _SPASURF, _SPBSURF)
4433 #define SPKEYMAXVAL(pipe, plane_id)     _MMIO_VLV_SPR((pipe), (plane_id), _SPAKEYMAXVAL, _SPBKEYMAXVAL)
4434 #define SPTILEOFF(pipe, plane_id)       _MMIO_VLV_SPR((pipe), (plane_id), _SPATILEOFF, _SPBTILEOFF)
4435 #define SPCONSTALPHA(pipe, plane_id)    _MMIO_VLV_SPR((pipe), (plane_id), _SPACONSTALPHA, _SPBCONSTALPHA)
4436 #define SPCLRC0(pipe, plane_id)         _MMIO_VLV_SPR((pipe), (plane_id), _SPACLRC0, _SPBCLRC0)
4437 #define SPCLRC1(pipe, plane_id)         _MMIO_VLV_SPR((pipe), (plane_id), _SPACLRC1, _SPBCLRC1)
4438 #define SPGAMC(pipe, plane_id, i)       _MMIO(_VLV_SPR((pipe), (plane_id), _SPAGAMC, _SPBGAMC) + (5 - (i)) * 4) /* 6 x u0.10 */
4439
4440 /*
4441  * CHV pipe B sprite CSC
4442  *
4443  * |cr|   |c0 c1 c2|   |cr + cr_ioff|   |cr_ooff|
4444  * |yg| = |c3 c4 c5| x |yg + yg_ioff| + |yg_ooff|
4445  * |cb|   |c6 c7 c8|   |cb + cr_ioff|   |cb_ooff|
4446  */
4447 #define _MMIO_CHV_SPCSC(plane_id, reg) \
4448         _MMIO(VLV_DISPLAY_BASE + ((plane_id) - PLANE_SPRITE0) * 0x1000 + (reg))
4449
4450 #define SPCSCYGOFF(plane_id)    _MMIO_CHV_SPCSC(plane_id, 0x6d900)
4451 #define SPCSCCBOFF(plane_id)    _MMIO_CHV_SPCSC(plane_id, 0x6d904)
4452 #define SPCSCCROFF(plane_id)    _MMIO_CHV_SPCSC(plane_id, 0x6d908)
4453 #define  SPCSC_OOFF_MASK        REG_GENMASK(26, 16)
4454 #define  SPCSC_OOFF(x)          REG_FIELD_PREP(SPCSC_OOFF_MASK, (x) & 0x7ff) /* s11 */
4455 #define  SPCSC_IOFF_MASK        REG_GENMASK(10, 0)
4456 #define  SPCSC_IOFF(x)          REG_FIELD_PREP(SPCSC_IOFF_MASK, (x) & 0x7ff) /* s11 */
4457
4458 #define SPCSCC01(plane_id)      _MMIO_CHV_SPCSC(plane_id, 0x6d90c)
4459 #define SPCSCC23(plane_id)      _MMIO_CHV_SPCSC(plane_id, 0x6d910)
4460 #define SPCSCC45(plane_id)      _MMIO_CHV_SPCSC(plane_id, 0x6d914)
4461 #define SPCSCC67(plane_id)      _MMIO_CHV_SPCSC(plane_id, 0x6d918)
4462 #define SPCSCC8(plane_id)       _MMIO_CHV_SPCSC(plane_id, 0x6d91c)
4463 #define  SPCSC_C1_MASK          REG_GENMASK(30, 16)
4464 #define  SPCSC_C1(x)            REG_FIELD_PREP(SPCSC_C1_MASK, (x) & 0x7fff) /* s3.12 */
4465 #define  SPCSC_C0_MASK          REG_GENMASK(14, 0)
4466 #define  SPCSC_C0(x)            REG_FIELD_PREP(SPCSC_C0_MASK, (x) & 0x7fff) /* s3.12 */
4467
4468 #define SPCSCYGICLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d920)
4469 #define SPCSCCBICLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d924)
4470 #define SPCSCCRICLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d928)
4471 #define  SPCSC_IMAX_MASK        REG_GENMASK(26, 16)
4472 #define  SPCSC_IMAX(x)          REG_FIELD_PREP(SPCSC_IMAX_MASK, (x) & 0x7ff) /* s11 */
4473 #define  SPCSC_IMIN_MASK        REG_GENMASK(10, 0)
4474 #define  SPCSC_IMIN(x)          REG_FIELD_PREP(SPCSC_IMIN_MASK, (x) & 0x7ff) /* s11 */
4475
4476 #define SPCSCYGOCLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d92c)
4477 #define SPCSCCBOCLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d930)
4478 #define SPCSCCROCLAMP(plane_id) _MMIO_CHV_SPCSC(plane_id, 0x6d934)
4479 #define  SPCSC_OMAX_MASK        REG_GENMASK(25, 16)
4480 #define  SPCSC_OMAX(x)          REG_FIELD_PREP(SPCSC_OMAX_MASK, (x)) /* u10 */
4481 #define  SPCSC_OMIN_MASK        REG_GENMASK(9, 0)
4482 #define  SPCSC_OMIN(x)          REG_FIELD_PREP(SPCSC_OMIN_MASK, (x)) /* u10 */
4483
4484 /* Skylake plane registers */
4485
4486 #define _PLANE_CTL_1_A                          0x70180
4487 #define _PLANE_CTL_2_A                          0x70280
4488 #define _PLANE_CTL_3_A                          0x70380
4489 #define   PLANE_CTL_ENABLE                      REG_BIT(31)
4490 #define   PLANE_CTL_ARB_SLOTS_MASK              REG_GENMASK(30, 28) /* icl+ */
4491 #define   PLANE_CTL_ARB_SLOTS(x)                REG_FIELD_PREP(PLANE_CTL_ARB_SLOTS_MASK, (x)) /* icl+ */
4492 #define   PLANE_CTL_PIPE_GAMMA_ENABLE           REG_BIT(30) /* Pre-GLK */
4493 #define   PLANE_CTL_YUV_RANGE_CORRECTION_DISABLE        REG_BIT(28)
4494 /*
4495  * ICL+ uses the same PLANE_CTL_FORMAT bits, but the field definition
4496  * expanded to include bit 23 as well. However, the shift-24 based values
4497  * correctly map to the same formats in ICL, as long as bit 23 is set to 0
4498  */
4499 #define   PLANE_CTL_FORMAT_MASK_SKL             REG_GENMASK(27, 24) /* pre-icl */
4500 #define   PLANE_CTL_FORMAT_MASK_ICL             REG_GENMASK(27, 23) /* icl+ */
4501 #define   PLANE_CTL_FORMAT_YUV422               REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 0)
4502 #define   PLANE_CTL_FORMAT_NV12                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 1)
4503 #define   PLANE_CTL_FORMAT_XRGB_2101010         REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 2)
4504 #define   PLANE_CTL_FORMAT_P010                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 3)
4505 #define   PLANE_CTL_FORMAT_XRGB_8888            REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 4)
4506 #define   PLANE_CTL_FORMAT_P012                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 5)
4507 #define   PLANE_CTL_FORMAT_XRGB_16161616F       REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 6)
4508 #define   PLANE_CTL_FORMAT_P016                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 7)
4509 #define   PLANE_CTL_FORMAT_XYUV                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 8)
4510 #define   PLANE_CTL_FORMAT_INDEXED              REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 12)
4511 #define   PLANE_CTL_FORMAT_RGB_565              REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_SKL, 14)
4512 #define   PLANE_CTL_FORMAT_Y210                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 1)
4513 #define   PLANE_CTL_FORMAT_Y212                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 3)
4514 #define   PLANE_CTL_FORMAT_Y216                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 5)
4515 #define   PLANE_CTL_FORMAT_Y410                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 7)
4516 #define   PLANE_CTL_FORMAT_Y412                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 9)
4517 #define   PLANE_CTL_FORMAT_Y416                 REG_FIELD_PREP(PLANE_CTL_FORMAT_MASK_ICL, 11)
4518 #define   PLANE_CTL_PIPE_CSC_ENABLE             REG_BIT(23) /* Pre-GLK */
4519 #define   PLANE_CTL_KEY_ENABLE_MASK             REG_GENMASK(22, 21)
4520 #define   PLANE_CTL_KEY_ENABLE_SOURCE           REG_FIELD_PREP(PLANE_CTL_KEY_ENABLE_MASK, 1)
4521 #define   PLANE_CTL_KEY_ENABLE_DESTINATION      REG_FIELD_PREP(PLANE_CTL_KEY_ENABLE_MASK, 2)
4522 #define   PLANE_CTL_ORDER_RGBX                  REG_BIT(20)
4523 #define   PLANE_CTL_YUV420_Y_PLANE              REG_BIT(19)
4524 #define   PLANE_CTL_YUV_TO_RGB_CSC_FORMAT_BT709 REG_BIT(18)
4525 #define   PLANE_CTL_YUV422_ORDER_MASK           REG_GENMASK(17, 16)
4526 #define   PLANE_CTL_YUV422_ORDER_YUYV           REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 0)
4527 #define   PLANE_CTL_YUV422_ORDER_UYVY           REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 1)
4528 #define   PLANE_CTL_YUV422_ORDER_YVYU           REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 2)
4529 #define   PLANE_CTL_YUV422_ORDER_VYUY           REG_FIELD_PREP(PLANE_CTL_YUV422_ORDER_MASK, 3)
4530 #define   PLANE_CTL_RENDER_DECOMPRESSION_ENABLE REG_BIT(15)
4531 #define   PLANE_CTL_TRICKLE_FEED_DISABLE        REG_BIT(14)
4532 #define   PLANE_CTL_CLEAR_COLOR_DISABLE         REG_BIT(13) /* TGL+ */
4533 #define   PLANE_CTL_PLANE_GAMMA_DISABLE         REG_BIT(13) /* Pre-GLK */
4534 #define   PLANE_CTL_TILED_MASK                  REG_GENMASK(12, 10)
4535 #define   PLANE_CTL_TILED_LINEAR                REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 0)
4536 #define   PLANE_CTL_TILED_X                     REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 1)
4537 #define   PLANE_CTL_TILED_Y                     REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 4)
4538 #define   PLANE_CTL_TILED_YF                    REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 5)
4539 #define   PLANE_CTL_TILED_4                     REG_FIELD_PREP(PLANE_CTL_TILED_MASK, 5)
4540 #define   PLANE_CTL_ASYNC_FLIP                  REG_BIT(9)
4541 #define   PLANE_CTL_FLIP_HORIZONTAL             REG_BIT(8)
4542 #define   PLANE_CTL_MEDIA_DECOMPRESSION_ENABLE  REG_BIT(4) /* TGL+ */
4543 #define   PLANE_CTL_ALPHA_MASK                  REG_GENMASK(5, 4) /* Pre-GLK */
4544 #define   PLANE_CTL_ALPHA_DISABLE               REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 0)
4545 #define   PLANE_CTL_ALPHA_SW_PREMULTIPLY        REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 2)
4546 #define   PLANE_CTL_ALPHA_HW_PREMULTIPLY        REG_FIELD_PREP(PLANE_CTL_ALPHA_MASK, 3)
4547 #define   PLANE_CTL_ROTATE_MASK                 REG_GENMASK(1, 0)
4548 #define   PLANE_CTL_ROTATE_0                    REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 0)
4549 #define   PLANE_CTL_ROTATE_90                   REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 1)
4550 #define   PLANE_CTL_ROTATE_180                  REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 2)
4551 #define   PLANE_CTL_ROTATE_270                  REG_FIELD_PREP(PLANE_CTL_ROTATE_MASK, 3)
4552 #define _PLANE_STRIDE_1_A                       0x70188
4553 #define _PLANE_STRIDE_2_A                       0x70288
4554 #define _PLANE_STRIDE_3_A                       0x70388
4555 #define   PLANE_STRIDE__MASK                    REG_GENMASK(11, 0)
4556 #define   PLANE_STRIDE_(stride)                 REG_FIELD_PREP(PLANE_STRIDE__MASK, (stride))
4557 #define _PLANE_POS_1_A                          0x7018c
4558 #define _PLANE_POS_2_A                          0x7028c
4559 #define _PLANE_POS_3_A                          0x7038c
4560 #define   PLANE_POS_Y_MASK                      REG_GENMASK(31, 16)
4561 #define   PLANE_POS_Y(y)                        REG_FIELD_PREP(PLANE_POS_Y_MASK, (y))
4562 #define   PLANE_POS_X_MASK                      REG_GENMASK(15, 0)
4563 #define   PLANE_POS_X(x)                        REG_FIELD_PREP(PLANE_POS_X_MASK, (x))
4564 #define _PLANE_SIZE_1_A                         0x70190
4565 #define _PLANE_SIZE_2_A                         0x70290
4566 #define _PLANE_SIZE_3_A                         0x70390
4567 #define   PLANE_HEIGHT_MASK                     REG_GENMASK(31, 16)
4568 #define   PLANE_HEIGHT(h)                       REG_FIELD_PREP(PLANE_HEIGHT_MASK, (h))
4569 #define   PLANE_WIDTH_MASK                      REG_GENMASK(15, 0)
4570 #define   PLANE_WIDTH(w)                        REG_FIELD_PREP(PLANE_WIDTH_MASK, (w))
4571 #define _PLANE_SURF_1_A                         0x7019c
4572 #define _PLANE_SURF_2_A                         0x7029c
4573 #define _PLANE_SURF_3_A                         0x7039c
4574 #define   PLANE_SURF_ADDR_MASK                  REG_GENMASK(31, 12)
4575 #define   PLANE_SURF_DECRYPT                    REG_BIT(2)
4576 #define _PLANE_OFFSET_1_A                       0x701a4
4577 #define _PLANE_OFFSET_2_A                       0x702a4
4578 #define _PLANE_OFFSET_3_A                       0x703a4
4579 #define   PLANE_OFFSET_Y_MASK                   REG_GENMASK(31, 16)
4580 #define   PLANE_OFFSET_Y(y)                     REG_FIELD_PREP(PLANE_OFFSET_Y_MASK, (y))
4581 #define   PLANE_OFFSET_X_MASK                   REG_GENMASK(15, 0)
4582 #define   PLANE_OFFSET_X(x)                     REG_FIELD_PREP(PLANE_OFFSET_X_MASK, (x))
4583 #define _PLANE_KEYVAL_1_A                       0x70194
4584 #define _PLANE_KEYVAL_2_A                       0x70294
4585 #define _PLANE_KEYMSK_1_A                       0x70198
4586 #define _PLANE_KEYMSK_2_A                       0x70298
4587 #define  PLANE_KEYMSK_ALPHA_ENABLE              (1 << 31)
4588 #define _PLANE_KEYMAX_1_A                       0x701a0
4589 #define _PLANE_KEYMAX_2_A                       0x702a0
4590 #define  PLANE_KEYMAX_ALPHA(a)                  ((a) << 24)
4591 #define _PLANE_CC_VAL_1_A                       0x701b4
4592 #define _PLANE_CC_VAL_2_A                       0x702b4
4593 #define _PLANE_AUX_DIST_1_A                     0x701c0
4594 #define   PLANE_AUX_DISTANCE_MASK               REG_GENMASK(31, 12)
4595 #define   PLANE_AUX_STRIDE_MASK                 REG_GENMASK(11, 0)
4596 #define   PLANE_AUX_STRIDE(stride)              REG_FIELD_PREP(PLANE_AUX_STRIDE_MASK, (stride))
4597 #define _PLANE_AUX_DIST_2_A                     0x702c0
4598 #define _PLANE_AUX_OFFSET_1_A                   0x701c4
4599 #define _PLANE_AUX_OFFSET_2_A                   0x702c4
4600 #define _PLANE_CUS_CTL_1_A                      0x701c8
4601 #define _PLANE_CUS_CTL_2_A                      0x702c8
4602 #define   PLANE_CUS_ENABLE                      REG_BIT(31)
4603 #define   PLANE_CUS_Y_PLANE_MASK                        REG_BIT(30)
4604 #define   PLANE_CUS_Y_PLANE_4_RKL               REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 0)
4605 #define   PLANE_CUS_Y_PLANE_5_RKL               REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 1)
4606 #define   PLANE_CUS_Y_PLANE_6_ICL               REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 0)
4607 #define   PLANE_CUS_Y_PLANE_7_ICL               REG_FIELD_PREP(PLANE_CUS_Y_PLANE_MASK, 1)
4608 #define   PLANE_CUS_HPHASE_SIGN_NEGATIVE                REG_BIT(19)
4609 #define   PLANE_CUS_HPHASE_MASK                 REG_GENMASK(17, 16)
4610 #define   PLANE_CUS_HPHASE_0                    REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 0)
4611 #define   PLANE_CUS_HPHASE_0_25                 REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 1)
4612 #define   PLANE_CUS_HPHASE_0_5                  REG_FIELD_PREP(PLANE_CUS_HPHASE_MASK, 2)
4613 #define   PLANE_CUS_VPHASE_SIGN_NEGATIVE                REG_BIT(15)
4614 #define   PLANE_CUS_VPHASE_MASK                 REG_GENMASK(13, 12)
4615 #define   PLANE_CUS_VPHASE_0                    REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 0)
4616 #define   PLANE_CUS_VPHASE_0_25                 REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 1)
4617 #define   PLANE_CUS_VPHASE_0_5                  REG_FIELD_PREP(PLANE_CUS_VPHASE_MASK, 2)
4618 #define _PLANE_COLOR_CTL_1_A                    0x701CC /* GLK+ */
4619 #define _PLANE_COLOR_CTL_2_A                    0x702CC /* GLK+ */
4620 #define _PLANE_COLOR_CTL_3_A                    0x703CC /* GLK+ */
4621 #define   PLANE_COLOR_PIPE_GAMMA_ENABLE                 REG_BIT(30) /* Pre-ICL */
4622 #define   PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE      REG_BIT(28)
4623 #define   PLANE_COLOR_PIPE_CSC_ENABLE                   REG_BIT(23) /* Pre-ICL */
4624 #define   PLANE_COLOR_PLANE_CSC_ENABLE                  REG_BIT(21) /* ICL+ */
4625 #define   PLANE_COLOR_INPUT_CSC_ENABLE                  REG_BIT(20) /* ICL+ */
4626 #define   PLANE_COLOR_CSC_MODE_MASK                     REG_GENMASK(19, 17)
4627 #define   PLANE_COLOR_CSC_MODE_BYPASS                   REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 0)
4628 #define   PLANE_COLOR_CSC_MODE_YUV601_TO_RGB601         REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 1)
4629 #define   PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709         REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 2)
4630 #define   PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020       REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 3)
4631 #define   PLANE_COLOR_CSC_MODE_RGB709_TO_RGB2020        REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 4)
4632 #define   PLANE_COLOR_PLANE_GAMMA_DISABLE               REG_BIT(13)
4633 #define   PLANE_COLOR_ALPHA_MASK                        REG_GENMASK(5, 4)
4634 #define   PLANE_COLOR_ALPHA_DISABLE                     REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 0)
4635 #define   PLANE_COLOR_ALPHA_SW_PREMULTIPLY              REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 2)
4636 #define   PLANE_COLOR_ALPHA_HW_PREMULTIPLY              REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 3)
4637 #define _PLANE_BUF_CFG_1_A                      0x7027c
4638 #define _PLANE_BUF_CFG_2_A                      0x7037c
4639 #define _PLANE_NV12_BUF_CFG_1_A         0x70278
4640 #define _PLANE_NV12_BUF_CFG_2_A         0x70378
4641
4642 #define _PLANE_CC_VAL_1_B               0x711b4
4643 #define _PLANE_CC_VAL_2_B               0x712b4
4644 #define _PLANE_CC_VAL_1(pipe, dw)       (_PIPE(pipe, _PLANE_CC_VAL_1_A, _PLANE_CC_VAL_1_B) + (dw) * 4)
4645 #define _PLANE_CC_VAL_2(pipe, dw)       (_PIPE(pipe, _PLANE_CC_VAL_2_A, _PLANE_CC_VAL_2_B) + (dw) * 4)
4646 #define PLANE_CC_VAL(pipe, plane, dw) \
4647         _MMIO_PLANE((plane), _PLANE_CC_VAL_1((pipe), (dw)), _PLANE_CC_VAL_2((pipe), (dw)))
4648
4649 /* Input CSC Register Definitions */
4650 #define _PLANE_INPUT_CSC_RY_GY_1_A      0x701E0
4651 #define _PLANE_INPUT_CSC_RY_GY_2_A      0x702E0
4652
4653 #define _PLANE_INPUT_CSC_RY_GY_1_B      0x711E0
4654 #define _PLANE_INPUT_CSC_RY_GY_2_B      0x712E0
4655
4656 #define _PLANE_INPUT_CSC_RY_GY_1(pipe)  \
4657         _PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_1_A, \
4658              _PLANE_INPUT_CSC_RY_GY_1_B)
4659 #define _PLANE_INPUT_CSC_RY_GY_2(pipe)  \
4660         _PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_2_A, \
4661              _PLANE_INPUT_CSC_RY_GY_2_B)
4662
4663 #define PLANE_INPUT_CSC_COEFF(pipe, plane, index)       \
4664         _MMIO_PLANE(plane, _PLANE_INPUT_CSC_RY_GY_1(pipe) +  (index) * 4, \
4665                     _PLANE_INPUT_CSC_RY_GY_2(pipe) + (index) * 4)
4666
4667 #define _PLANE_INPUT_CSC_PREOFF_HI_1_A          0x701F8
4668 #define _PLANE_INPUT_CSC_PREOFF_HI_2_A          0x702F8
4669
4670 #define _PLANE_INPUT_CSC_PREOFF_HI_1_B          0x711F8
4671 #define _PLANE_INPUT_CSC_PREOFF_HI_2_B          0x712F8
4672
4673 #define _PLANE_INPUT_CSC_PREOFF_HI_1(pipe)      \
4674         _PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_1_A, \
4675              _PLANE_INPUT_CSC_PREOFF_HI_1_B)
4676 #define _PLANE_INPUT_CSC_PREOFF_HI_2(pipe)      \
4677         _PIPE(pipe, _PLANE_INPUT_CSC_PREOFF_HI_2_A, \
4678              _PLANE_INPUT_CSC_PREOFF_HI_2_B)
4679 #define PLANE_INPUT_CSC_PREOFF(pipe, plane, index)      \
4680         _MMIO_PLANE(plane, _PLANE_INPUT_CSC_PREOFF_HI_1(pipe) + (index) * 4, \
4681                     _PLANE_INPUT_CSC_PREOFF_HI_2(pipe) + (index) * 4)
4682
4683 #define _PLANE_INPUT_CSC_POSTOFF_HI_1_A         0x70204
4684 #define _PLANE_INPUT_CSC_POSTOFF_HI_2_A         0x70304
4685
4686 #define _PLANE_INPUT_CSC_POSTOFF_HI_1_B         0x71204
4687 #define _PLANE_INPUT_CSC_POSTOFF_HI_2_B         0x71304
4688
4689 #define _PLANE_INPUT_CSC_POSTOFF_HI_1(pipe)     \
4690         _PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_1_A, \
4691              _PLANE_INPUT_CSC_POSTOFF_HI_1_B)
4692 #define _PLANE_INPUT_CSC_POSTOFF_HI_2(pipe)     \
4693         _PIPE(pipe, _PLANE_INPUT_CSC_POSTOFF_HI_2_A, \
4694              _PLANE_INPUT_CSC_POSTOFF_HI_2_B)
4695 #define PLANE_INPUT_CSC_POSTOFF(pipe, plane, index)     \
4696         _MMIO_PLANE(plane, _PLANE_INPUT_CSC_POSTOFF_HI_1(pipe) + (index) * 4, \
4697                     _PLANE_INPUT_CSC_POSTOFF_HI_2(pipe) + (index) * 4)
4698
4699 #define _PLANE_CTL_1_B                          0x71180
4700 #define _PLANE_CTL_2_B                          0x71280
4701 #define _PLANE_CTL_3_B                          0x71380
4702 #define _PLANE_CTL_1(pipe)      _PIPE(pipe, _PLANE_CTL_1_A, _PLANE_CTL_1_B)
4703 #define _PLANE_CTL_2(pipe)      _PIPE(pipe, _PLANE_CTL_2_A, _PLANE_CTL_2_B)
4704 #define _PLANE_CTL_3(pipe)      _PIPE(pipe, _PLANE_CTL_3_A, _PLANE_CTL_3_B)
4705 #define PLANE_CTL(pipe, plane)  \
4706         _MMIO_PLANE(plane, _PLANE_CTL_1(pipe), _PLANE_CTL_2(pipe))
4707
4708 #define _PLANE_STRIDE_1_B                       0x71188
4709 #define _PLANE_STRIDE_2_B                       0x71288
4710 #define _PLANE_STRIDE_3_B                       0x71388
4711 #define _PLANE_STRIDE_1(pipe)   \
4712         _PIPE(pipe, _PLANE_STRIDE_1_A, _PLANE_STRIDE_1_B)
4713 #define _PLANE_STRIDE_2(pipe)   \
4714         _PIPE(pipe, _PLANE_STRIDE_2_A, _PLANE_STRIDE_2_B)
4715 #define _PLANE_STRIDE_3(pipe)   \
4716         _PIPE(pipe, _PLANE_STRIDE_3_A, _PLANE_STRIDE_3_B)
4717 #define PLANE_STRIDE(pipe, plane)       \
4718         _MMIO_PLANE(plane, _PLANE_STRIDE_1(pipe), _PLANE_STRIDE_2(pipe))
4719
4720 #define _PLANE_POS_1_B                          0x7118c
4721 #define _PLANE_POS_2_B                          0x7128c
4722 #define _PLANE_POS_3_B                          0x7138c
4723 #define _PLANE_POS_1(pipe)      _PIPE(pipe, _PLANE_POS_1_A, _PLANE_POS_1_B)
4724 #define _PLANE_POS_2(pipe)      _PIPE(pipe, _PLANE_POS_2_A, _PLANE_POS_2_B)
4725 #define _PLANE_POS_3(pipe)      _PIPE(pipe, _PLANE_POS_3_A, _PLANE_POS_3_B)
4726 #define PLANE_POS(pipe, plane)  \
4727         _MMIO_PLANE(plane, _PLANE_POS_1(pipe), _PLANE_POS_2(pipe))
4728
4729 #define _PLANE_SIZE_1_B                         0x71190
4730 #define _PLANE_SIZE_2_B                         0x71290
4731 #define _PLANE_SIZE_3_B                         0x71390
4732 #define _PLANE_SIZE_1(pipe)     _PIPE(pipe, _PLANE_SIZE_1_A, _PLANE_SIZE_1_B)
4733 #define _PLANE_SIZE_2(pipe)     _PIPE(pipe, _PLANE_SIZE_2_A, _PLANE_SIZE_2_B)
4734 #define _PLANE_SIZE_3(pipe)     _PIPE(pipe, _PLANE_SIZE_3_A, _PLANE_SIZE_3_B)
4735 #define PLANE_SIZE(pipe, plane) \
4736         _MMIO_PLANE(plane, _PLANE_SIZE_1(pipe), _PLANE_SIZE_2(pipe))
4737
4738 #define _PLANE_SURF_1_B                         0x7119c
4739 #define _PLANE_SURF_2_B                         0x7129c
4740 #define _PLANE_SURF_3_B                         0x7139c
4741 #define _PLANE_SURF_1(pipe)     _PIPE(pipe, _PLANE_SURF_1_A, _PLANE_SURF_1_B)
4742 #define _PLANE_SURF_2(pipe)     _PIPE(pipe, _PLANE_SURF_2_A, _PLANE_SURF_2_B)
4743 #define _PLANE_SURF_3(pipe)     _PIPE(pipe, _PLANE_SURF_3_A, _PLANE_SURF_3_B)
4744 #define PLANE_SURF(pipe, plane) \
4745         _MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
4746
4747 #define _PLANE_OFFSET_1_B                       0x711a4
4748 #define _PLANE_OFFSET_2_B                       0x712a4
4749 #define _PLANE_OFFSET_1(pipe) _PIPE(pipe, _PLANE_OFFSET_1_A, _PLANE_OFFSET_1_B)
4750 #define _PLANE_OFFSET_2(pipe) _PIPE(pipe, _PLANE_OFFSET_2_A, _PLANE_OFFSET_2_B)
4751 #define PLANE_OFFSET(pipe, plane)       \
4752         _MMIO_PLANE(plane, _PLANE_OFFSET_1(pipe), _PLANE_OFFSET_2(pipe))
4753
4754 #define _PLANE_KEYVAL_1_B                       0x71194
4755 #define _PLANE_KEYVAL_2_B                       0x71294
4756 #define _PLANE_KEYVAL_1(pipe) _PIPE(pipe, _PLANE_KEYVAL_1_A, _PLANE_KEYVAL_1_B)
4757 #define _PLANE_KEYVAL_2(pipe) _PIPE(pipe, _PLANE_KEYVAL_2_A, _PLANE_KEYVAL_2_B)
4758 #define PLANE_KEYVAL(pipe, plane)       \
4759         _MMIO_PLANE(plane, _PLANE_KEYVAL_1(pipe), _PLANE_KEYVAL_2(pipe))
4760
4761 #define _PLANE_KEYMSK_1_B                       0x71198
4762 #define _PLANE_KEYMSK_2_B                       0x71298
4763 #define _PLANE_KEYMSK_1(pipe) _PIPE(pipe, _PLANE_KEYMSK_1_A, _PLANE_KEYMSK_1_B)
4764 #define _PLANE_KEYMSK_2(pipe) _PIPE(pipe, _PLANE_KEYMSK_2_A, _PLANE_KEYMSK_2_B)
4765 #define PLANE_KEYMSK(pipe, plane)       \
4766         _MMIO_PLANE(plane, _PLANE_KEYMSK_1(pipe), _PLANE_KEYMSK_2(pipe))
4767
4768 #define _PLANE_KEYMAX_1_B                       0x711a0
4769 #define _PLANE_KEYMAX_2_B                       0x712a0
4770 #define _PLANE_KEYMAX_1(pipe) _PIPE(pipe, _PLANE_KEYMAX_1_A, _PLANE_KEYMAX_1_B)
4771 #define _PLANE_KEYMAX_2(pipe) _PIPE(pipe, _PLANE_KEYMAX_2_A, _PLANE_KEYMAX_2_B)
4772 #define PLANE_KEYMAX(pipe, plane)       \
4773         _MMIO_PLANE(plane, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))
4774
4775 #define _PLANE_BUF_CFG_1_B                      0x7127c
4776 #define _PLANE_BUF_CFG_2_B                      0x7137c
4777 /* skl+: 10 bits, icl+ 11 bits, adlp+ 12 bits */
4778 #define   PLANE_BUF_END_MASK            REG_GENMASK(27, 16)
4779 #define   PLANE_BUF_END(end)            REG_FIELD_PREP(PLANE_BUF_END_MASK, (end))
4780 #define   PLANE_BUF_START_MASK          REG_GENMASK(11, 0)
4781 #define   PLANE_BUF_START(start)        REG_FIELD_PREP(PLANE_BUF_START_MASK, (start))
4782 #define _PLANE_BUF_CFG_1(pipe)  \
4783         _PIPE(pipe, _PLANE_BUF_CFG_1_A, _PLANE_BUF_CFG_1_B)
4784 #define _PLANE_BUF_CFG_2(pipe)  \
4785         _PIPE(pipe, _PLANE_BUF_CFG_2_A, _PLANE_BUF_CFG_2_B)
4786 #define PLANE_BUF_CFG(pipe, plane)      \
4787         _MMIO_PLANE(plane, _PLANE_BUF_CFG_1(pipe), _PLANE_BUF_CFG_2(pipe))
4788
4789 #define _PLANE_NV12_BUF_CFG_1_B         0x71278
4790 #define _PLANE_NV12_BUF_CFG_2_B         0x71378
4791 #define _PLANE_NV12_BUF_CFG_1(pipe)     \
4792         _PIPE(pipe, _PLANE_NV12_BUF_CFG_1_A, _PLANE_NV12_BUF_CFG_1_B)
4793 #define _PLANE_NV12_BUF_CFG_2(pipe)     \
4794         _PIPE(pipe, _PLANE_NV12_BUF_CFG_2_A, _PLANE_NV12_BUF_CFG_2_B)
4795 #define PLANE_NV12_BUF_CFG(pipe, plane) \
4796         _MMIO_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe))
4797
4798 #define _PLANE_AUX_DIST_1_B             0x711c0
4799 #define _PLANE_AUX_DIST_2_B             0x712c0
4800 #define _PLANE_AUX_DIST_1(pipe) \
4801                         _PIPE(pipe, _PLANE_AUX_DIST_1_A, _PLANE_AUX_DIST_1_B)
4802 #define _PLANE_AUX_DIST_2(pipe) \
4803                         _PIPE(pipe, _PLANE_AUX_DIST_2_A, _PLANE_AUX_DIST_2_B)
4804 #define PLANE_AUX_DIST(pipe, plane)     \
4805         _MMIO_PLANE(plane, _PLANE_AUX_DIST_1(pipe), _PLANE_AUX_DIST_2(pipe))
4806
4807 #define _PLANE_AUX_OFFSET_1_B           0x711c4
4808 #define _PLANE_AUX_OFFSET_2_B           0x712c4
4809 #define _PLANE_AUX_OFFSET_1(pipe)       \
4810                 _PIPE(pipe, _PLANE_AUX_OFFSET_1_A, _PLANE_AUX_OFFSET_1_B)
4811 #define _PLANE_AUX_OFFSET_2(pipe)       \
4812                 _PIPE(pipe, _PLANE_AUX_OFFSET_2_A, _PLANE_AUX_OFFSET_2_B)
4813 #define PLANE_AUX_OFFSET(pipe, plane)   \
4814         _MMIO_PLANE(plane, _PLANE_AUX_OFFSET_1(pipe), _PLANE_AUX_OFFSET_2(pipe))
4815
4816 #define _PLANE_CUS_CTL_1_B              0x711c8
4817 #define _PLANE_CUS_CTL_2_B              0x712c8
4818 #define _PLANE_CUS_CTL_1(pipe)       \
4819                 _PIPE(pipe, _PLANE_CUS_CTL_1_A, _PLANE_CUS_CTL_1_B)
4820 #define _PLANE_CUS_CTL_2(pipe)       \
4821                 _PIPE(pipe, _PLANE_CUS_CTL_2_A, _PLANE_CUS_CTL_2_B)
4822 #define PLANE_CUS_CTL(pipe, plane)   \
4823         _MMIO_PLANE(plane, _PLANE_CUS_CTL_1(pipe), _PLANE_CUS_CTL_2(pipe))
4824
4825 #define _PLANE_COLOR_CTL_1_B                    0x711CC
4826 #define _PLANE_COLOR_CTL_2_B                    0x712CC
4827 #define _PLANE_COLOR_CTL_3_B                    0x713CC
4828 #define _PLANE_COLOR_CTL_1(pipe)        \
4829         _PIPE(pipe, _PLANE_COLOR_CTL_1_A, _PLANE_COLOR_CTL_1_B)
4830 #define _PLANE_COLOR_CTL_2(pipe)        \
4831         _PIPE(pipe, _PLANE_COLOR_CTL_2_A, _PLANE_COLOR_CTL_2_B)
4832 #define PLANE_COLOR_CTL(pipe, plane)    \
4833         _MMIO_PLANE(plane, _PLANE_COLOR_CTL_1(pipe), _PLANE_COLOR_CTL_2(pipe))
4834
4835 #define _SEL_FETCH_PLANE_BASE_1_A               0x70890
4836 #define _SEL_FETCH_PLANE_BASE_2_A               0x708B0
4837 #define _SEL_FETCH_PLANE_BASE_3_A               0x708D0
4838 #define _SEL_FETCH_PLANE_BASE_4_A               0x708F0
4839 #define _SEL_FETCH_PLANE_BASE_5_A               0x70920
4840 #define _SEL_FETCH_PLANE_BASE_6_A               0x70940
4841 #define _SEL_FETCH_PLANE_BASE_7_A               0x70960
4842 #define _SEL_FETCH_PLANE_BASE_CUR_A             0x70880
4843 #define _SEL_FETCH_PLANE_BASE_1_B               0x71890
4844
4845 #define _SEL_FETCH_PLANE_BASE_A(plane) _PICK(plane, \
4846                                              _SEL_FETCH_PLANE_BASE_1_A, \
4847                                              _SEL_FETCH_PLANE_BASE_2_A, \
4848                                              _SEL_FETCH_PLANE_BASE_3_A, \
4849                                              _SEL_FETCH_PLANE_BASE_4_A, \
4850                                              _SEL_FETCH_PLANE_BASE_5_A, \
4851                                              _SEL_FETCH_PLANE_BASE_6_A, \
4852                                              _SEL_FETCH_PLANE_BASE_7_A, \
4853                                              _SEL_FETCH_PLANE_BASE_CUR_A)
4854 #define _SEL_FETCH_PLANE_BASE_1(pipe) _PIPE(pipe, _SEL_FETCH_PLANE_BASE_1_A, _SEL_FETCH_PLANE_BASE_1_B)
4855 #define _SEL_FETCH_PLANE_BASE(pipe, plane) (_SEL_FETCH_PLANE_BASE_1(pipe) - \
4856                                             _SEL_FETCH_PLANE_BASE_1_A + \
4857                                             _SEL_FETCH_PLANE_BASE_A(plane))
4858
4859 #define _SEL_FETCH_PLANE_CTL_1_A                0x70890
4860 #define PLANE_SEL_FETCH_CTL(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
4861                                                _SEL_FETCH_PLANE_CTL_1_A - \
4862                                                _SEL_FETCH_PLANE_BASE_1_A)
4863 #define PLANE_SEL_FETCH_CTL_ENABLE              REG_BIT(31)
4864
4865 #define _SEL_FETCH_PLANE_POS_1_A                0x70894
4866 #define PLANE_SEL_FETCH_POS(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
4867                                                _SEL_FETCH_PLANE_POS_1_A - \
4868                                                _SEL_FETCH_PLANE_BASE_1_A)
4869
4870 #define _SEL_FETCH_PLANE_SIZE_1_A               0x70898
4871 #define PLANE_SEL_FETCH_SIZE(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
4872                                                 _SEL_FETCH_PLANE_SIZE_1_A - \
4873                                                 _SEL_FETCH_PLANE_BASE_1_A)
4874
4875 #define _SEL_FETCH_PLANE_OFFSET_1_A             0x7089C
4876 #define PLANE_SEL_FETCH_OFFSET(pipe, plane) _MMIO(_SEL_FETCH_PLANE_BASE(pipe, plane) + \
4877                                                   _SEL_FETCH_PLANE_OFFSET_1_A - \
4878                                                   _SEL_FETCH_PLANE_BASE_1_A)
4879
4880 /* SKL new cursor registers */
4881 #define _CUR_BUF_CFG_A                          0x7017c
4882 #define _CUR_BUF_CFG_B                          0x7117c
4883 #define CUR_BUF_CFG(pipe)       _MMIO_PIPE(pipe, _CUR_BUF_CFG_A, _CUR_BUF_CFG_B)
4884
4885 /* VBIOS regs */
4886 #define VGACNTRL                _MMIO(0x71400)
4887 # define VGA_DISP_DISABLE                       (1 << 31)
4888 # define VGA_2X_MODE                            (1 << 30)
4889 # define VGA_PIPE_B_SELECT                      (1 << 29)
4890
4891 #define VLV_VGACNTRL            _MMIO(VLV_DISPLAY_BASE + 0x71400)
4892
4893 /* Ironlake */
4894
4895 #define CPU_VGACNTRL    _MMIO(0x41000)
4896
4897 #define DIGITAL_PORT_HOTPLUG_CNTRL      _MMIO(0x44030)
4898 #define  DIGITAL_PORTA_HOTPLUG_ENABLE           (1 << 4)
4899 #define  DIGITAL_PORTA_PULSE_DURATION_2ms       (0 << 2) /* pre-HSW */
4900 #define  DIGITAL_PORTA_PULSE_DURATION_4_5ms     (1 << 2) /* pre-HSW */
4901 #define  DIGITAL_PORTA_PULSE_DURATION_6ms       (2 << 2) /* pre-HSW */
4902 #define  DIGITAL_PORTA_PULSE_DURATION_100ms     (3 << 2) /* pre-HSW */
4903 #define  DIGITAL_PORTA_PULSE_DURATION_MASK      (3 << 2) /* pre-HSW */
4904 #define  DIGITAL_PORTA_HOTPLUG_STATUS_MASK      (3 << 0)
4905 #define  DIGITAL_PORTA_HOTPLUG_NO_DETECT        (0 << 0)
4906 #define  DIGITAL_PORTA_HOTPLUG_SHORT_DETECT     (1 << 0)
4907 #define  DIGITAL_PORTA_HOTPLUG_LONG_DETECT      (2 << 0)
4908
4909 /* refresh rate hardware control */
4910 #define RR_HW_CTL       _MMIO(0x45300)
4911 #define  RR_HW_LOW_POWER_FRAMES_MASK    0xff
4912 #define  RR_HW_HIGH_POWER_FRAMES_MASK   0xff00
4913
4914 #define FDI_PLL_BIOS_0  _MMIO(0x46000)
4915 #define  FDI_PLL_FB_CLOCK_MASK  0xff
4916 #define FDI_PLL_BIOS_1  _MMIO(0x46004)
4917 #define FDI_PLL_BIOS_2  _MMIO(0x46008)
4918 #define DISPLAY_PORT_PLL_BIOS_0         _MMIO(0x4600c)
4919 #define DISPLAY_PORT_PLL_BIOS_1         _MMIO(0x46010)
4920 #define DISPLAY_PORT_PLL_BIOS_2         _MMIO(0x46014)
4921
4922 #define PCH_3DCGDIS0            _MMIO(0x46020)
4923 # define MARIUNIT_CLOCK_GATE_DISABLE            (1 << 18)
4924 # define SVSMUNIT_CLOCK_GATE_DISABLE            (1 << 1)
4925
4926 #define PCH_3DCGDIS1            _MMIO(0x46024)
4927 # define VFMUNIT_CLOCK_GATE_DISABLE             (1 << 11)
4928
4929 #define FDI_PLL_FREQ_CTL        _MMIO(0x46030)
4930 #define  FDI_PLL_FREQ_CHANGE_REQUEST    (1 << 24)
4931 #define  FDI_PLL_FREQ_LOCK_LIMIT_MASK   0xfff00
4932 #define  FDI_PLL_FREQ_DISABLE_COUNT_LIMIT_MASK  0xff
4933
4934
4935 #define _PIPEA_DATA_M1          0x60030
4936 #define _PIPEA_DATA_N1          0x60034
4937 #define _PIPEA_DATA_M2          0x60038
4938 #define _PIPEA_DATA_N2          0x6003c
4939 #define _PIPEA_LINK_M1          0x60040
4940 #define _PIPEA_LINK_N1          0x60044
4941 #define _PIPEA_LINK_M2          0x60048
4942 #define _PIPEA_LINK_N2          0x6004c
4943
4944 /* PIPEB timing regs are same start from 0x61000 */
4945
4946 #define _PIPEB_DATA_M1          0x61030
4947 #define _PIPEB_DATA_N1          0x61034
4948 #define _PIPEB_DATA_M2          0x61038
4949 #define _PIPEB_DATA_N2          0x6103c
4950 #define _PIPEB_LINK_M1          0x61040
4951 #define _PIPEB_LINK_N1          0x61044
4952 #define _PIPEB_LINK_M2          0x61048
4953 #define _PIPEB_LINK_N2          0x6104c
4954
4955 #define PIPE_DATA_M1(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_M1)
4956 #define PIPE_DATA_N1(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_N1)
4957 #define PIPE_DATA_M2(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_M2)
4958 #define PIPE_DATA_N2(tran) _MMIO_TRANS2(tran, _PIPEA_DATA_N2)
4959 #define PIPE_LINK_M1(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_M1)
4960 #define PIPE_LINK_N1(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_N1)
4961 #define PIPE_LINK_M2(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_M2)
4962 #define PIPE_LINK_N2(tran) _MMIO_TRANS2(tran, _PIPEA_LINK_N2)
4963
4964 /* CPU panel fitter */
4965 /* IVB+ has 3 fitters, 0 is 7x5 capable, the other two only 3x3 */
4966 #define _PFA_CTL_1               0x68080
4967 #define _PFB_CTL_1               0x68880
4968 #define  PF_ENABLE              (1 << 31)
4969 #define  PF_PIPE_SEL_MASK_IVB   (3 << 29)
4970 #define  PF_PIPE_SEL_IVB(pipe)  ((pipe) << 29)
4971 #define  PF_FILTER_MASK         (3 << 23)
4972 #define  PF_FILTER_PROGRAMMED   (0 << 23)
4973 #define  PF_FILTER_MED_3x3      (1 << 23)
4974 #define  PF_FILTER_EDGE_ENHANCE (2 << 23)
4975 #define  PF_FILTER_EDGE_SOFTEN  (3 << 23)
4976 #define _PFA_WIN_SZ             0x68074
4977 #define _PFB_WIN_SZ             0x68874
4978 #define _PFA_WIN_POS            0x68070
4979 #define _PFB_WIN_POS            0x68870
4980 #define _PFA_VSCALE             0x68084
4981 #define _PFB_VSCALE             0x68884
4982 #define _PFA_HSCALE             0x68090
4983 #define _PFB_HSCALE             0x68890
4984
4985 #define PF_CTL(pipe)            _MMIO_PIPE(pipe, _PFA_CTL_1, _PFB_CTL_1)
4986 #define PF_WIN_SZ(pipe)         _MMIO_PIPE(pipe, _PFA_WIN_SZ, _PFB_WIN_SZ)
4987 #define PF_WIN_POS(pipe)        _MMIO_PIPE(pipe, _PFA_WIN_POS, _PFB_WIN_POS)
4988 #define PF_VSCALE(pipe)         _MMIO_PIPE(pipe, _PFA_VSCALE, _PFB_VSCALE)
4989 #define PF_HSCALE(pipe)         _MMIO_PIPE(pipe, _PFA_HSCALE, _PFB_HSCALE)
4990
4991 #define _PSA_CTL                0x68180
4992 #define _PSB_CTL                0x68980
4993 #define PS_ENABLE               (1 << 31)
4994 #define _PSA_WIN_SZ             0x68174
4995 #define _PSB_WIN_SZ             0x68974
4996 #define _PSA_WIN_POS            0x68170
4997 #define _PSB_WIN_POS            0x68970
4998
4999 #define PS_CTL(pipe)            _MMIO_PIPE(pipe, _PSA_CTL, _PSB_CTL)
5000 #define PS_WIN_SZ(pipe)         _MMIO_PIPE(pipe, _PSA_WIN_SZ, _PSB_WIN_SZ)
5001 #define PS_WIN_POS(pipe)        _MMIO_PIPE(pipe, _PSA_WIN_POS, _PSB_WIN_POS)
5002
5003 /*
5004  * Skylake scalers
5005  */
5006 #define _PS_1A_CTRL      0x68180
5007 #define _PS_2A_CTRL      0x68280
5008 #define _PS_1B_CTRL      0x68980
5009 #define _PS_2B_CTRL      0x68A80
5010 #define _PS_1C_CTRL      0x69180
5011 #define PS_SCALER_EN        (1 << 31)
5012 #define SKL_PS_SCALER_MODE_MASK (3 << 28)
5013 #define SKL_PS_SCALER_MODE_DYN  (0 << 28)
5014 #define SKL_PS_SCALER_MODE_HQ  (1 << 28)
5015 #define SKL_PS_SCALER_MODE_NV12 (2 << 28)
5016 #define PS_SCALER_MODE_PLANAR (1 << 29)
5017 #define PS_SCALER_MODE_NORMAL (0 << 29)
5018 #define PS_PLANE_SEL_MASK  (7 << 25)
5019 #define PS_PLANE_SEL(plane) (((plane) + 1) << 25)
5020 #define PS_FILTER_MASK         (3 << 23)
5021 #define PS_FILTER_MEDIUM       (0 << 23)
5022 #define PS_FILTER_PROGRAMMED   (1 << 23)
5023 #define PS_FILTER_EDGE_ENHANCE (2 << 23)
5024 #define PS_FILTER_BILINEAR     (3 << 23)
5025 #define PS_VERT3TAP            (1 << 21)
5026 #define PS_VERT_INT_INVERT_FIELD1 (0 << 20)
5027 #define PS_VERT_INT_INVERT_FIELD0 (1 << 20)
5028 #define PS_PWRUP_PROGRESS         (1 << 17)
5029 #define PS_V_FILTER_BYPASS        (1 << 8)
5030 #define PS_VADAPT_EN              (1 << 7)
5031 #define PS_VADAPT_MODE_MASK        (3 << 5)
5032 #define PS_VADAPT_MODE_LEAST_ADAPT (0 << 5)
5033 #define PS_VADAPT_MODE_MOD_ADAPT   (1 << 5)
5034 #define PS_VADAPT_MODE_MOST_ADAPT  (3 << 5)
5035 #define PS_PLANE_Y_SEL_MASK  (7 << 5)
5036 #define PS_PLANE_Y_SEL(plane) (((plane) + 1) << 5)
5037 #define PS_Y_VERT_FILTER_SELECT(set)   ((set) << 4)
5038 #define PS_Y_HORZ_FILTER_SELECT(set)   ((set) << 3)
5039 #define PS_UV_VERT_FILTER_SELECT(set)  ((set) << 2)
5040 #define PS_UV_HORZ_FILTER_SELECT(set)  ((set) << 1)
5041
5042 #define _PS_PWR_GATE_1A     0x68160
5043 #define _PS_PWR_GATE_2A     0x68260
5044 #define _PS_PWR_GATE_1B     0x68960
5045 #define _PS_PWR_GATE_2B     0x68A60
5046 #define _PS_PWR_GATE_1C     0x69160
5047 #define PS_PWR_GATE_DIS_OVERRIDE       (1 << 31)
5048 #define PS_PWR_GATE_SETTLING_TIME_32   (0 << 3)
5049 #define PS_PWR_GATE_SETTLING_TIME_64   (1 << 3)
5050 #define PS_PWR_GATE_SETTLING_TIME_96   (2 << 3)
5051 #define PS_PWR_GATE_SETTLING_TIME_128  (3 << 3)
5052 #define PS_PWR_GATE_SLPEN_8             0
5053 #define PS_PWR_GATE_SLPEN_16            1
5054 #define PS_PWR_GATE_SLPEN_24            2
5055 #define PS_PWR_GATE_SLPEN_32            3
5056
5057 #define _PS_WIN_POS_1A      0x68170
5058 #define _PS_WIN_POS_2A      0x68270
5059 #define _PS_WIN_POS_1B      0x68970
5060 #define _PS_WIN_POS_2B      0x68A70
5061 #define _PS_WIN_POS_1C      0x69170
5062
5063 #define _PS_WIN_SZ_1A       0x68174
5064 #define _PS_WIN_SZ_2A       0x68274
5065 #define _PS_WIN_SZ_1B       0x68974
5066 #define _PS_WIN_SZ_2B       0x68A74
5067 #define _PS_WIN_SZ_1C       0x69174
5068
5069 #define _PS_VSCALE_1A       0x68184
5070 #define _PS_VSCALE_2A       0x68284
5071 #define _PS_VSCALE_1B       0x68984
5072 #define _PS_VSCALE_2B       0x68A84
5073 #define _PS_VSCALE_1C       0x69184
5074
5075 #define _PS_HSCALE_1A       0x68190
5076 #define _PS_HSCALE_2A       0x68290
5077 #define _PS_HSCALE_1B       0x68990
5078 #define _PS_HSCALE_2B       0x68A90
5079 #define _PS_HSCALE_1C       0x69190
5080
5081 #define _PS_VPHASE_1A       0x68188
5082 #define _PS_VPHASE_2A       0x68288
5083 #define _PS_VPHASE_1B       0x68988
5084 #define _PS_VPHASE_2B       0x68A88
5085 #define _PS_VPHASE_1C       0x69188
5086 #define  PS_Y_PHASE(x)          ((x) << 16)
5087 #define  PS_UV_RGB_PHASE(x)     ((x) << 0)
5088 #define   PS_PHASE_MASK (0x7fff << 1) /* u2.13 */
5089 #define   PS_PHASE_TRIP (1 << 0)
5090
5091 #define _PS_HPHASE_1A       0x68194
5092 #define _PS_HPHASE_2A       0x68294
5093 #define _PS_HPHASE_1B       0x68994
5094 #define _PS_HPHASE_2B       0x68A94
5095 #define _PS_HPHASE_1C       0x69194
5096
5097 #define _PS_ECC_STAT_1A     0x681D0
5098 #define _PS_ECC_STAT_2A     0x682D0
5099 #define _PS_ECC_STAT_1B     0x689D0
5100 #define _PS_ECC_STAT_2B     0x68AD0
5101 #define _PS_ECC_STAT_1C     0x691D0
5102
5103 #define _PS_COEF_SET0_INDEX_1A     0x68198
5104 #define _PS_COEF_SET0_INDEX_2A     0x68298
5105 #define _PS_COEF_SET0_INDEX_1B     0x68998
5106 #define _PS_COEF_SET0_INDEX_2B     0x68A98
5107 #define PS_COEE_INDEX_AUTO_INC     (1 << 10)
5108
5109 #define _PS_COEF_SET0_DATA_1A      0x6819C
5110 #define _PS_COEF_SET0_DATA_2A      0x6829C
5111 #define _PS_COEF_SET0_DATA_1B      0x6899C
5112 #define _PS_COEF_SET0_DATA_2B      0x68A9C
5113
5114 #define _ID(id, a, b) _PICK_EVEN(id, a, b)
5115 #define SKL_PS_CTRL(pipe, id) _MMIO_PIPE(pipe,        \
5116                         _ID(id, _PS_1A_CTRL, _PS_2A_CTRL),       \
5117                         _ID(id, _PS_1B_CTRL, _PS_2B_CTRL))
5118 #define SKL_PS_PWR_GATE(pipe, id) _MMIO_PIPE(pipe,    \
5119                         _ID(id, _PS_PWR_GATE_1A, _PS_PWR_GATE_2A), \
5120                         _ID(id, _PS_PWR_GATE_1B, _PS_PWR_GATE_2B))
5121 #define SKL_PS_WIN_POS(pipe, id) _MMIO_PIPE(pipe,     \
5122                         _ID(id, _PS_WIN_POS_1A, _PS_WIN_POS_2A), \
5123                         _ID(id, _PS_WIN_POS_1B, _PS_WIN_POS_2B))
5124 #define SKL_PS_WIN_SZ(pipe, id)  _MMIO_PIPE(pipe,     \
5125                         _ID(id, _PS_WIN_SZ_1A, _PS_WIN_SZ_2A),   \
5126                         _ID(id, _PS_WIN_SZ_1B, _PS_WIN_SZ_2B))
5127 #define SKL_PS_VSCALE(pipe, id)  _MMIO_PIPE(pipe,     \
5128                         _ID(id, _PS_VSCALE_1A, _PS_VSCALE_2A),   \
5129                         _ID(id, _PS_VSCALE_1B, _PS_VSCALE_2B))
5130 #define SKL_PS_HSCALE(pipe, id)  _MMIO_PIPE(pipe,     \
5131                         _ID(id, _PS_HSCALE_1A, _PS_HSCALE_2A),   \
5132                         _ID(id, _PS_HSCALE_1B, _PS_HSCALE_2B))
5133 #define SKL_PS_VPHASE(pipe, id)  _MMIO_PIPE(pipe,     \
5134                         _ID(id, _PS_VPHASE_1A, _PS_VPHASE_2A),   \
5135                         _ID(id, _PS_VPHASE_1B, _PS_VPHASE_2B))
5136 #define SKL_PS_HPHASE(pipe, id)  _MMIO_PIPE(pipe,     \
5137                         _ID(id, _PS_HPHASE_1A, _PS_HPHASE_2A),   \
5138                         _ID(id, _PS_HPHASE_1B, _PS_HPHASE_2B))
5139 #define SKL_PS_ECC_STAT(pipe, id)  _MMIO_PIPE(pipe,     \
5140                         _ID(id, _PS_ECC_STAT_1A, _PS_ECC_STAT_2A),   \
5141                         _ID(id, _PS_ECC_STAT_1B, _PS_ECC_STAT_2B))
5142 #define GLK_PS_COEF_INDEX_SET(pipe, id, set)  _MMIO_PIPE(pipe,    \
5143                         _ID(id, _PS_COEF_SET0_INDEX_1A, _PS_COEF_SET0_INDEX_2A) + (set) * 8, \
5144                         _ID(id, _PS_COEF_SET0_INDEX_1B, _PS_COEF_SET0_INDEX_2B) + (set) * 8)
5145
5146 #define GLK_PS_COEF_DATA_SET(pipe, id, set)  _MMIO_PIPE(pipe,     \
5147                         _ID(id, _PS_COEF_SET0_DATA_1A, _PS_COEF_SET0_DATA_2A) + (set) * 8, \
5148                         _ID(id, _PS_COEF_SET0_DATA_1B, _PS_COEF_SET0_DATA_2B) + (set) * 8)
5149 /* legacy palette */
5150 #define _LGC_PALETTE_A           0x4a000
5151 #define _LGC_PALETTE_B           0x4a800
5152 /* see PALETTE_* for the bits */
5153 #define LGC_PALETTE(pipe, i) _MMIO(_PIPE(pipe, _LGC_PALETTE_A, _LGC_PALETTE_B) + (i) * 4)
5154
5155 /* ilk/snb precision palette */
5156 #define _PREC_PALETTE_A           0x4b000
5157 #define _PREC_PALETTE_B           0x4c000
5158 /* 10bit mode */
5159 #define   PREC_PALETTE_10_RED_MASK              REG_GENMASK(29, 20)
5160 #define   PREC_PALETTE_10_GREEN_MASK            REG_GENMASK(19, 10)
5161 #define   PREC_PALETTE_10_BLUE_MASK             REG_GENMASK(9, 0)
5162 /* 12.4 interpolated mode ldw */
5163 #define   PREC_PALETTE_12P4_RED_LDW_MASK        REG_GENMASK(29, 24)
5164 #define   PREC_PALETTE_12P4_GREEN_LDW_MASK      REG_GENMASK(19, 14)
5165 #define   PREC_PALETTE_12P4_BLUE_LDW_MASK       REG_GENMASK(9, 4)
5166 /* 12.4 interpolated mode udw */
5167 #define   PREC_PALETTE_12P4_RED_UDW_MASK        REG_GENMASK(29, 20)
5168 #define   PREC_PALETTE_12P4_GREEN_UDW_MASK      REG_GENMASK(19, 10)
5169 #define   PREC_PALETTE_12P4_BLUE_UDW_MASK       REG_GENMASK(9, 0)
5170 #define PREC_PALETTE(pipe, i) _MMIO(_PIPE(pipe, _PREC_PALETTE_A, _PREC_PALETTE_B) + (i) * 4)
5171
5172 #define  _PREC_PIPEAGCMAX              0x4d000
5173 #define  _PREC_PIPEBGCMAX              0x4d010
5174 #define PREC_PIPEGCMAX(pipe, i)        _MMIO(_PIPE(pipe, _PIPEAGCMAX, _PIPEBGCMAX) + (i) * 4) /* u1.16 */
5175
5176 #define _GAMMA_MODE_A           0x4a480
5177 #define _GAMMA_MODE_B           0x4ac80
5178 #define GAMMA_MODE(pipe) _MMIO_PIPE(pipe, _GAMMA_MODE_A, _GAMMA_MODE_B)
5179 #define  PRE_CSC_GAMMA_ENABLE                   REG_BIT(31) /* icl+ */
5180 #define  POST_CSC_GAMMA_ENABLE                  REG_BIT(30) /* icl+ */
5181 #define  PALETTE_ANTICOL_DISABLE                REG_BIT(15) /* skl+ */
5182 #define  GAMMA_MODE_MODE_MASK                   REG_GENMASK(1, 0)
5183 #define  GAMMA_MODE_MODE_8BIT                   REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 0)
5184 #define  GAMMA_MODE_MODE_10BIT                  REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 1)
5185 #define  GAMMA_MODE_MODE_12BIT                  REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 2)
5186 #define  GAMMA_MODE_MODE_SPLIT                  REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 3) /* ivb-bdw */
5187 #define  GAMMA_MODE_MODE_12BIT_MULTI_SEG        REG_FIELD_PREP(GAMMA_MODE_MODE_MASK, 3) /* icl-tgl */
5188
5189 /* Display Internal Timeout Register */
5190 #define RM_TIMEOUT              _MMIO(0x42060)
5191 #define  MMIO_TIMEOUT_US(us)    ((us) << 0)
5192
5193 /* interrupts */
5194 #define DE_MASTER_IRQ_CONTROL   (1 << 31)
5195 #define DE_SPRITEB_FLIP_DONE    (1 << 29)
5196 #define DE_SPRITEA_FLIP_DONE    (1 << 28)
5197 #define DE_PLANEB_FLIP_DONE     (1 << 27)
5198 #define DE_PLANEA_FLIP_DONE     (1 << 26)
5199 #define DE_PLANE_FLIP_DONE(plane) (1 << (26 + (plane)))
5200 #define DE_PCU_EVENT            (1 << 25)
5201 #define DE_GTT_FAULT            (1 << 24)
5202 #define DE_POISON               (1 << 23)
5203 #define DE_PERFORM_COUNTER      (1 << 22)
5204 #define DE_PCH_EVENT            (1 << 21)
5205 #define DE_AUX_CHANNEL_A        (1 << 20)
5206 #define DE_DP_A_HOTPLUG         (1 << 19)
5207 #define DE_GSE                  (1 << 18)
5208 #define DE_PIPEB_VBLANK         (1 << 15)
5209 #define DE_PIPEB_EVEN_FIELD     (1 << 14)
5210 #define DE_PIPEB_ODD_FIELD      (1 << 13)
5211 #define DE_PIPEB_LINE_COMPARE   (1 << 12)
5212 #define DE_PIPEB_VSYNC          (1 << 11)
5213 #define DE_PIPEB_CRC_DONE       (1 << 10)
5214 #define DE_PIPEB_FIFO_UNDERRUN  (1 << 8)
5215 #define DE_PIPEA_VBLANK         (1 << 7)
5216 #define DE_PIPE_VBLANK(pipe)    (1 << (7 + 8 * (pipe)))
5217 #define DE_PIPEA_EVEN_FIELD     (1 << 6)
5218 #define DE_PIPEA_ODD_FIELD      (1 << 5)
5219 #define DE_PIPEA_LINE_COMPARE   (1 << 4)
5220 #define DE_PIPEA_VSYNC          (1 << 3)
5221 #define DE_PIPEA_CRC_DONE       (1 << 2)
5222 #define DE_PIPE_CRC_DONE(pipe)  (1 << (2 + 8 * (pipe)))
5223 #define DE_PIPEA_FIFO_UNDERRUN  (1 << 0)
5224 #define DE_PIPE_FIFO_UNDERRUN(pipe)  (1 << (8 * (pipe)))
5225
5226 /* More Ivybridge lolz */
5227 #define DE_ERR_INT_IVB                  (1 << 30)
5228 #define DE_GSE_IVB                      (1 << 29)
5229 #define DE_PCH_EVENT_IVB                (1 << 28)
5230 #define DE_DP_A_HOTPLUG_IVB             (1 << 27)
5231 #define DE_AUX_CHANNEL_A_IVB            (1 << 26)
5232 #define DE_EDP_PSR_INT_HSW              (1 << 19)
5233 #define DE_SPRITEC_FLIP_DONE_IVB        (1 << 14)
5234 #define DE_PLANEC_FLIP_DONE_IVB         (1 << 13)
5235 #define DE_PIPEC_VBLANK_IVB             (1 << 10)
5236 #define DE_SPRITEB_FLIP_DONE_IVB        (1 << 9)
5237 #define DE_PLANEB_FLIP_DONE_IVB         (1 << 8)
5238 #define DE_PIPEB_VBLANK_IVB             (1 << 5)
5239 #define DE_SPRITEA_FLIP_DONE_IVB        (1 << 4)
5240 #define DE_PLANEA_FLIP_DONE_IVB         (1 << 3)
5241 #define DE_PLANE_FLIP_DONE_IVB(plane)   (1 << (3 + 5 * (plane)))
5242 #define DE_PIPEA_VBLANK_IVB             (1 << 0)
5243 #define DE_PIPE_VBLANK_IVB(pipe)        (1 << ((pipe) * 5))
5244
5245 #define VLV_MASTER_IER                  _MMIO(0x4400c) /* Gunit master IER */
5246 #define   MASTER_INTERRUPT_ENABLE       (1 << 31)
5247
5248 #define DEISR   _MMIO(0x44000)
5249 #define DEIMR   _MMIO(0x44004)
5250 #define DEIIR   _MMIO(0x44008)
5251 #define DEIER   _MMIO(0x4400c)
5252
5253 #define GTISR   _MMIO(0x44010)
5254 #define GTIMR   _MMIO(0x44014)
5255 #define GTIIR   _MMIO(0x44018)
5256 #define GTIER   _MMIO(0x4401c)
5257
5258 #define GEN8_MASTER_IRQ                 _MMIO(0x44200)
5259 #define  GEN8_MASTER_IRQ_CONTROL        (1 << 31)
5260 #define  GEN8_PCU_IRQ                   (1 << 30)
5261 #define  GEN8_DE_PCH_IRQ                (1 << 23)
5262 #define  GEN8_DE_MISC_IRQ               (1 << 22)
5263 #define  GEN8_DE_PORT_IRQ               (1 << 20)
5264 #define  GEN8_DE_PIPE_C_IRQ             (1 << 18)
5265 #define  GEN8_DE_PIPE_B_IRQ             (1 << 17)
5266 #define  GEN8_DE_PIPE_A_IRQ             (1 << 16)
5267 #define  GEN8_DE_PIPE_IRQ(pipe)         (1 << (16 + (pipe)))
5268 #define  GEN8_GT_VECS_IRQ               (1 << 6)
5269 #define  GEN8_GT_GUC_IRQ                (1 << 5)
5270 #define  GEN8_GT_PM_IRQ                 (1 << 4)
5271 #define  GEN8_GT_VCS1_IRQ               (1 << 3) /* NB: VCS2 in bspec! */
5272 #define  GEN8_GT_VCS0_IRQ               (1 << 2) /* NB: VCS1 in bpsec! */
5273 #define  GEN8_GT_BCS_IRQ                (1 << 1)
5274 #define  GEN8_GT_RCS_IRQ                (1 << 0)
5275
5276 #define XELPD_DISPLAY_ERR_FATAL_MASK    _MMIO(0x4421c)
5277
5278 #define GEN8_GT_ISR(which) _MMIO(0x44300 + (0x10 * (which)))
5279 #define GEN8_GT_IMR(which) _MMIO(0x44304 + (0x10 * (which)))
5280 #define GEN8_GT_IIR(which) _MMIO(0x44308 + (0x10 * (which)))
5281 #define GEN8_GT_IER(which) _MMIO(0x4430c + (0x10 * (which)))
5282
5283 #define GEN8_RCS_IRQ_SHIFT 0
5284 #define GEN8_BCS_IRQ_SHIFT 16
5285 #define GEN8_VCS0_IRQ_SHIFT 0  /* NB: VCS1 in bspec! */
5286 #define GEN8_VCS1_IRQ_SHIFT 16 /* NB: VCS2 in bpsec! */
5287 #define GEN8_VECS_IRQ_SHIFT 0
5288 #define GEN8_WD_IRQ_SHIFT 16
5289
5290 #define GEN8_DE_PIPE_ISR(pipe) _MMIO(0x44400 + (0x10 * (pipe)))
5291 #define GEN8_DE_PIPE_IMR(pipe) _MMIO(0x44404 + (0x10 * (pipe)))
5292 #define GEN8_DE_PIPE_IIR(pipe) _MMIO(0x44408 + (0x10 * (pipe)))
5293 #define GEN8_DE_PIPE_IER(pipe) _MMIO(0x4440c + (0x10 * (pipe)))
5294 #define  GEN8_PIPE_FIFO_UNDERRUN        (1 << 31)
5295 #define  GEN8_PIPE_CDCLK_CRC_ERROR      (1 << 29)
5296 #define  GEN8_PIPE_CDCLK_CRC_DONE       (1 << 28)
5297 #define  XELPD_PIPE_SOFT_UNDERRUN       (1 << 22)
5298 #define  XELPD_PIPE_HARD_UNDERRUN       (1 << 21)
5299 #define  GEN12_PIPE_VBLANK_UNMOD        (1 << 19)
5300 #define  GEN8_PIPE_CURSOR_FAULT         (1 << 10)
5301 #define  GEN8_PIPE_SPRITE_FAULT         (1 << 9)
5302 #define  GEN8_PIPE_PRIMARY_FAULT        (1 << 8)
5303 #define  GEN8_PIPE_SPRITE_FLIP_DONE     (1 << 5)
5304 #define  GEN8_PIPE_PRIMARY_FLIP_DONE    (1 << 4)
5305 #define  GEN8_PIPE_SCAN_LINE_EVENT      (1 << 2)
5306 #define  GEN8_PIPE_VSYNC                (1 << 1)
5307 #define  GEN8_PIPE_VBLANK               (1 << 0)
5308 #define  GEN9_PIPE_CURSOR_FAULT         (1 << 11)
5309 #define  GEN11_PIPE_PLANE7_FAULT        (1 << 22)
5310 #define  GEN11_PIPE_PLANE6_FAULT        (1 << 21)
5311 #define  GEN11_PIPE_PLANE5_FAULT        (1 << 20)
5312 #define  GEN9_PIPE_PLANE4_FAULT         (1 << 10)
5313 #define  GEN9_PIPE_PLANE3_FAULT         (1 << 9)
5314 #define  GEN9_PIPE_PLANE2_FAULT         (1 << 8)
5315 #define  GEN9_PIPE_PLANE1_FAULT         (1 << 7)
5316 #define  GEN9_PIPE_PLANE4_FLIP_DONE     (1 << 6)
5317 #define  GEN9_PIPE_PLANE3_FLIP_DONE     (1 << 5)
5318 #define  GEN9_PIPE_PLANE2_FLIP_DONE     (1 << 4)
5319 #define  GEN9_PIPE_PLANE1_FLIP_DONE     (1 << 3)
5320 #define  GEN9_PIPE_PLANE_FLIP_DONE(p)   (1 << (3 + (p)))
5321 #define GEN8_DE_PIPE_IRQ_FAULT_ERRORS \
5322         (GEN8_PIPE_CURSOR_FAULT | \
5323          GEN8_PIPE_SPRITE_FAULT | \
5324          GEN8_PIPE_PRIMARY_FAULT)
5325 #define GEN9_DE_PIPE_IRQ_FAULT_ERRORS \
5326         (GEN9_PIPE_CURSOR_FAULT | \
5327          GEN9_PIPE_PLANE4_FAULT | \
5328          GEN9_PIPE_PLANE3_FAULT | \
5329          GEN9_PIPE_PLANE2_FAULT | \
5330          GEN9_PIPE_PLANE1_FAULT)
5331 #define GEN11_DE_PIPE_IRQ_FAULT_ERRORS \
5332         (GEN9_DE_PIPE_IRQ_FAULT_ERRORS | \
5333          GEN11_PIPE_PLANE7_FAULT | \
5334          GEN11_PIPE_PLANE6_FAULT | \
5335          GEN11_PIPE_PLANE5_FAULT)
5336 #define RKL_DE_PIPE_IRQ_FAULT_ERRORS \
5337         (GEN9_DE_PIPE_IRQ_FAULT_ERRORS | \
5338          GEN11_PIPE_PLANE5_FAULT)
5339
5340 #define _HPD_PIN_DDI(hpd_pin)   ((hpd_pin) - HPD_PORT_A)
5341 #define _HPD_PIN_TC(hpd_pin)    ((hpd_pin) - HPD_PORT_TC1)
5342
5343 #define GEN8_DE_PORT_ISR _MMIO(0x44440)
5344 #define GEN8_DE_PORT_IMR _MMIO(0x44444)
5345 #define GEN8_DE_PORT_IIR _MMIO(0x44448)
5346 #define GEN8_DE_PORT_IER _MMIO(0x4444c)
5347 #define  DSI1_NON_TE                    (1 << 31)
5348 #define  DSI0_NON_TE                    (1 << 30)
5349 #define  ICL_AUX_CHANNEL_E              (1 << 29)
5350 #define  ICL_AUX_CHANNEL_F              (1 << 28)
5351 #define  GEN9_AUX_CHANNEL_D             (1 << 27)
5352 #define  GEN9_AUX_CHANNEL_C             (1 << 26)
5353 #define  GEN9_AUX_CHANNEL_B             (1 << 25)
5354 #define  DSI1_TE                        (1 << 24)
5355 #define  DSI0_TE                        (1 << 23)
5356 #define  GEN8_DE_PORT_HOTPLUG(hpd_pin)  REG_BIT(3 + _HPD_PIN_DDI(hpd_pin))
5357 #define  BXT_DE_PORT_HOTPLUG_MASK       (GEN8_DE_PORT_HOTPLUG(HPD_PORT_A) | \
5358                                          GEN8_DE_PORT_HOTPLUG(HPD_PORT_B) | \
5359                                          GEN8_DE_PORT_HOTPLUG(HPD_PORT_C))
5360 #define  BDW_DE_PORT_HOTPLUG_MASK       GEN8_DE_PORT_HOTPLUG(HPD_PORT_A)
5361 #define  BXT_DE_PORT_GMBUS              (1 << 1)
5362 #define  GEN8_AUX_CHANNEL_A             (1 << 0)
5363 #define  TGL_DE_PORT_AUX_USBC6          REG_BIT(13)
5364 #define  XELPD_DE_PORT_AUX_DDIE         REG_BIT(13)
5365 #define  TGL_DE_PORT_AUX_USBC5          REG_BIT(12)
5366 #define  XELPD_DE_PORT_AUX_DDID         REG_BIT(12)
5367 #define  TGL_DE_PORT_AUX_USBC4          REG_BIT(11)
5368 #define  TGL_DE_PORT_AUX_USBC3          REG_BIT(10)
5369 #define  TGL_DE_PORT_AUX_USBC2          REG_BIT(9)
5370 #define  TGL_DE_PORT_AUX_USBC1          REG_BIT(8)
5371 #define  TGL_DE_PORT_AUX_DDIC           REG_BIT(2)
5372 #define  TGL_DE_PORT_AUX_DDIB           REG_BIT(1)
5373 #define  TGL_DE_PORT_AUX_DDIA           REG_BIT(0)
5374
5375 #define GEN8_DE_MISC_ISR _MMIO(0x44460)
5376 #define GEN8_DE_MISC_IMR _MMIO(0x44464)
5377 #define GEN8_DE_MISC_IIR _MMIO(0x44468)
5378 #define GEN8_DE_MISC_IER _MMIO(0x4446c)
5379 #define  GEN8_DE_MISC_GSE               (1 << 27)
5380 #define  GEN8_DE_EDP_PSR                (1 << 19)
5381
5382 #define GEN8_PCU_ISR _MMIO(0x444e0)
5383 #define GEN8_PCU_IMR _MMIO(0x444e4)
5384 #define GEN8_PCU_IIR _MMIO(0x444e8)
5385 #define GEN8_PCU_IER _MMIO(0x444ec)
5386
5387 #define GEN11_GU_MISC_ISR       _MMIO(0x444f0)
5388 #define GEN11_GU_MISC_IMR       _MMIO(0x444f4)
5389 #define GEN11_GU_MISC_IIR       _MMIO(0x444f8)
5390 #define GEN11_GU_MISC_IER       _MMIO(0x444fc)
5391 #define  GEN11_GU_MISC_GSE      (1 << 27)
5392
5393 #define GEN11_GFX_MSTR_IRQ              _MMIO(0x190010)
5394 #define  GEN11_MASTER_IRQ               (1 << 31)
5395 #define  GEN11_PCU_IRQ                  (1 << 30)
5396 #define  GEN11_GU_MISC_IRQ              (1 << 29)
5397 #define  GEN11_DISPLAY_IRQ              (1 << 16)
5398 #define  GEN11_GT_DW_IRQ(x)             (1 << (x))
5399 #define  GEN11_GT_DW1_IRQ               (1 << 1)
5400 #define  GEN11_GT_DW0_IRQ               (1 << 0)
5401
5402 #define DG1_MSTR_TILE_INTR              _MMIO(0x190008)
5403 #define   DG1_MSTR_IRQ                  REG_BIT(31)
5404 #define   DG1_MSTR_TILE(t)              REG_BIT(t)
5405
5406 #define GEN11_DISPLAY_INT_CTL           _MMIO(0x44200)
5407 #define  GEN11_DISPLAY_IRQ_ENABLE       (1 << 31)
5408 #define  GEN11_AUDIO_CODEC_IRQ          (1 << 24)
5409 #define  GEN11_DE_PCH_IRQ               (1 << 23)
5410 #define  GEN11_DE_MISC_IRQ              (1 << 22)
5411 #define  GEN11_DE_HPD_IRQ               (1 << 21)
5412 #define  GEN11_DE_PORT_IRQ              (1 << 20)
5413 #define  GEN11_DE_PIPE_C                (1 << 18)
5414 #define  GEN11_DE_PIPE_B                (1 << 17)
5415 #define  GEN11_DE_PIPE_A                (1 << 16)
5416
5417 #define GEN11_DE_HPD_ISR                _MMIO(0x44470)
5418 #define GEN11_DE_HPD_IMR                _MMIO(0x44474)
5419 #define GEN11_DE_HPD_IIR                _MMIO(0x44478)
5420 #define GEN11_DE_HPD_IER                _MMIO(0x4447c)
5421 #define  GEN11_TC_HOTPLUG(hpd_pin)              REG_BIT(16 + _HPD_PIN_TC(hpd_pin))
5422 #define  GEN11_DE_TC_HOTPLUG_MASK               (GEN11_TC_HOTPLUG(HPD_PORT_TC6) | \
5423                                                  GEN11_TC_HOTPLUG(HPD_PORT_TC5) | \
5424                                                  GEN11_TC_HOTPLUG(HPD_PORT_TC4) | \
5425                                                  GEN11_TC_HOTPLUG(HPD_PORT_TC3) | \
5426                                                  GEN11_TC_HOTPLUG(HPD_PORT_TC2) | \
5427                                                  GEN11_TC_HOTPLUG(HPD_PORT_TC1))
5428 #define  GEN11_TBT_HOTPLUG(hpd_pin)             REG_BIT(_HPD_PIN_TC(hpd_pin))
5429 #define  GEN11_DE_TBT_HOTPLUG_MASK              (GEN11_TBT_HOTPLUG(HPD_PORT_TC6) | \
5430                                                  GEN11_TBT_HOTPLUG(HPD_PORT_TC5) | \
5431                                                  GEN11_TBT_HOTPLUG(HPD_PORT_TC4) | \
5432                                                  GEN11_TBT_HOTPLUG(HPD_PORT_TC3) | \
5433                                                  GEN11_TBT_HOTPLUG(HPD_PORT_TC2) | \
5434                                                  GEN11_TBT_HOTPLUG(HPD_PORT_TC1))
5435
5436 #define GEN11_TBT_HOTPLUG_CTL                           _MMIO(0x44030)
5437 #define GEN11_TC_HOTPLUG_CTL                            _MMIO(0x44038)
5438 #define  GEN11_HOTPLUG_CTL_ENABLE(hpd_pin)              (8 << (_HPD_PIN_TC(hpd_pin) * 4))
5439 #define  GEN11_HOTPLUG_CTL_LONG_DETECT(hpd_pin)         (2 << (_HPD_PIN_TC(hpd_pin) * 4))
5440 #define  GEN11_HOTPLUG_CTL_SHORT_DETECT(hpd_pin)        (1 << (_HPD_PIN_TC(hpd_pin) * 4))
5441 #define  GEN11_HOTPLUG_CTL_NO_DETECT(hpd_pin)           (0 << (_HPD_PIN_TC(hpd_pin) * 4))
5442
5443 #define ILK_DISPLAY_CHICKEN2    _MMIO(0x42004)
5444 /* Required on all Ironlake and Sandybridge according to the B-Spec. */
5445 #define  ILK_ELPIN_409_SELECT   (1 << 25)
5446 #define  ILK_DPARB_GATE (1 << 22)
5447 #define  ILK_VSDPFD_FULL        (1 << 21)
5448 #define FUSE_STRAP                      _MMIO(0x42014)
5449 #define  ILK_INTERNAL_GRAPHICS_DISABLE  (1 << 31)
5450 #define  ILK_INTERNAL_DISPLAY_DISABLE   (1 << 30)
5451 #define  ILK_DISPLAY_DEBUG_DISABLE      (1 << 29)
5452 #define  IVB_PIPE_C_DISABLE             (1 << 28)
5453 #define  ILK_HDCP_DISABLE               (1 << 25)
5454 #define  ILK_eDP_A_DISABLE              (1 << 24)
5455 #define  HSW_CDCLK_LIMIT                (1 << 24)
5456 #define  ILK_DESKTOP                    (1 << 23)
5457 #define  HSW_CPU_SSC_ENABLE             (1 << 21)
5458
5459 #define FUSE_STRAP3                     _MMIO(0x42020)
5460 #define  HSW_REF_CLK_SELECT             (1 << 1)
5461
5462 #define ILK_DSPCLK_GATE_D                       _MMIO(0x42020)
5463 #define   ILK_VRHUNIT_CLOCK_GATE_DISABLE        (1 << 28)
5464 #define   ILK_DPFCUNIT_CLOCK_GATE_DISABLE       (1 << 9)
5465 #define   ILK_DPFCRUNIT_CLOCK_GATE_DISABLE      (1 << 8)
5466 #define   ILK_DPFDUNIT_CLOCK_GATE_ENABLE        (1 << 7)
5467 #define   ILK_DPARBUNIT_CLOCK_GATE_ENABLE       (1 << 5)
5468
5469 #define IVB_CHICKEN3    _MMIO(0x4200c)
5470 # define CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE      (1 << 5)
5471 # define CHICKEN3_DGMG_DONE_FIX_DISABLE         (1 << 2)
5472
5473 #define CHICKEN_PAR1_1                  _MMIO(0x42080)
5474 #define  IGNORE_KVMR_PIPE_A             REG_BIT(23)
5475 #define  KBL_ARB_FILL_SPARE_22          REG_BIT(22)
5476 #define  DIS_RAM_BYPASS_PSR2_MAN_TRACK  (1 << 16)
5477 #define  SKL_DE_COMPRESSED_HASH_MODE    (1 << 15)
5478 #define  DPA_MASK_VBLANK_SRD            (1 << 15)
5479 #define  FORCE_ARB_IDLE_PLANES          (1 << 14)
5480 #define  SKL_EDP_PSR_FIX_RDWRAP         (1 << 3)
5481 #define  IGNORE_PSR2_HW_TRACKING        (1 << 1)
5482
5483 #define CHICKEN_PAR2_1          _MMIO(0x42090)
5484 #define  KVM_CONFIG_CHANGE_NOTIFICATION_SELECT  (1 << 14)
5485
5486 #define CHICKEN_MISC_2          _MMIO(0x42084)
5487 #define  KBL_ARB_FILL_SPARE_14  REG_BIT(14)
5488 #define  KBL_ARB_FILL_SPARE_13  REG_BIT(13)
5489 #define  GLK_CL2_PWR_DOWN       (1 << 12)
5490 #define  GLK_CL1_PWR_DOWN       (1 << 11)
5491 #define  GLK_CL0_PWR_DOWN       (1 << 10)
5492
5493 #define CHICKEN_MISC_4          _MMIO(0x4208c)
5494 #define   CHICKEN_FBC_STRIDE_OVERRIDE   REG_BIT(13)
5495 #define   CHICKEN_FBC_STRIDE_MASK       REG_GENMASK(12, 0)
5496 #define   CHICKEN_FBC_STRIDE(x)         REG_FIELD_PREP(CHICKEN_FBC_STRIDE_MASK, (x))
5497
5498 #define _CHICKEN_PIPESL_1_A     0x420b0
5499 #define _CHICKEN_PIPESL_1_B     0x420b4
5500 #define  HSW_PRI_STRETCH_MAX_MASK       REG_GENMASK(28, 27)
5501 #define  HSW_PRI_STRETCH_MAX_X8         REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 0)
5502 #define  HSW_PRI_STRETCH_MAX_X4         REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 1)
5503 #define  HSW_PRI_STRETCH_MAX_X2         REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 2)
5504 #define  HSW_PRI_STRETCH_MAX_X1         REG_FIELD_PREP(HSW_PRI_STRETCH_MAX_MASK, 3)
5505 #define  HSW_SPR_STRETCH_MAX_MASK       REG_GENMASK(26, 25)
5506 #define  HSW_SPR_STRETCH_MAX_X8         REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 0)
5507 #define  HSW_SPR_STRETCH_MAX_X4         REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 1)
5508 #define  HSW_SPR_STRETCH_MAX_X2         REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 2)
5509 #define  HSW_SPR_STRETCH_MAX_X1         REG_FIELD_PREP(HSW_SPR_STRETCH_MAX_MASK, 3)
5510 #define  HSW_FBCQ_DIS                   (1 << 22)
5511 #define  BDW_DPRS_MASK_VBLANK_SRD       (1 << 0)
5512 #define  SKL_PLANE1_STRETCH_MAX_MASK    REG_GENMASK(1, 0)
5513 #define  SKL_PLANE1_STRETCH_MAX_X8      REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 0)
5514 #define  SKL_PLANE1_STRETCH_MAX_X4      REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 1)
5515 #define  SKL_PLANE1_STRETCH_MAX_X2      REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 2)
5516 #define  SKL_PLANE1_STRETCH_MAX_X1      REG_FIELD_PREP(SKL_PLANE1_STRETCH_MAX_MASK, 3)
5517 #define CHICKEN_PIPESL_1(pipe) _MMIO_PIPE(pipe, _CHICKEN_PIPESL_1_A, _CHICKEN_PIPESL_1_B)
5518
5519 #define _CHICKEN_TRANS_A        0x420c0
5520 #define _CHICKEN_TRANS_B        0x420c4
5521 #define _CHICKEN_TRANS_C        0x420c8
5522 #define _CHICKEN_TRANS_EDP      0x420cc
5523 #define _CHICKEN_TRANS_D        0x420d8
5524 #define CHICKEN_TRANS(trans)    _MMIO(_PICK((trans), \
5525                                             [TRANSCODER_EDP] = _CHICKEN_TRANS_EDP, \
5526                                             [TRANSCODER_A] = _CHICKEN_TRANS_A, \
5527                                             [TRANSCODER_B] = _CHICKEN_TRANS_B, \
5528                                             [TRANSCODER_C] = _CHICKEN_TRANS_C, \
5529                                             [TRANSCODER_D] = _CHICKEN_TRANS_D))
5530
5531 #define _MTL_CHICKEN_TRANS_A    0x604e0
5532 #define _MTL_CHICKEN_TRANS_B    0x614e0
5533 #define MTL_CHICKEN_TRANS(trans)        _MMIO_TRANS((trans), \
5534                                                     _MTL_CHICKEN_TRANS_A, \
5535                                                     _MTL_CHICKEN_TRANS_B)
5536
5537 #define  HSW_FRAME_START_DELAY_MASK     REG_GENMASK(28, 27)
5538 #define  HSW_FRAME_START_DELAY(x)       REG_FIELD_PREP(HSW_FRAME_START_DELAY_MASK, x)
5539 #define  VSC_DATA_SEL_SOFTWARE_CONTROL  REG_BIT(25) /* GLK */
5540 #define  FECSTALL_DIS_DPTSTREAM_DPTTG   REG_BIT(23)
5541 #define  DDI_TRAINING_OVERRIDE_ENABLE   REG_BIT(19)
5542 #define  ADLP_1_BASED_X_GRANULARITY     REG_BIT(18)
5543 #define  DDI_TRAINING_OVERRIDE_VALUE    REG_BIT(18)
5544 #define  DDIE_TRAINING_OVERRIDE_ENABLE  REG_BIT(17) /* CHICKEN_TRANS_A only */
5545 #define  DDIE_TRAINING_OVERRIDE_VALUE   REG_BIT(16) /* CHICKEN_TRANS_A only */
5546 #define  PSR2_ADD_VERTICAL_LINE_COUNT   REG_BIT(15)
5547 #define  PSR2_VSC_ENABLE_PROG_HEADER    REG_BIT(12)
5548
5549 #define DISP_ARB_CTL    _MMIO(0x45000)
5550 #define  DISP_FBC_MEMORY_WAKE           (1 << 31)
5551 #define  DISP_TILE_SURFACE_SWIZZLING    (1 << 13)
5552 #define  DISP_FBC_WM_DIS                (1 << 15)
5553 #define DISP_ARB_CTL2   _MMIO(0x45004)
5554 #define  DISP_DATA_PARTITION_5_6        (1 << 6)
5555 #define  DISP_IPC_ENABLE                (1 << 3)
5556
5557 /*
5558  * The below are numbered starting from "S1" on gen11/gen12, but starting
5559  * with display 13, the bspec switches to a 0-based numbering scheme
5560  * (although the addresses stay the same so new S0 = old S1, new S1 = old S2).
5561  * We'll just use the 0-based numbering here for all platforms since it's the
5562  * way things will be named by the hardware team going forward, plus it's more
5563  * consistent with how most of the rest of our registers are named.
5564  */
5565 #define _DBUF_CTL_S0                            0x45008
5566 #define _DBUF_CTL_S1                            0x44FE8
5567 #define _DBUF_CTL_S2                            0x44300
5568 #define _DBUF_CTL_S3                            0x44304
5569 #define DBUF_CTL_S(slice)                       _MMIO(_PICK(slice, \
5570                                                             _DBUF_CTL_S0, \
5571                                                             _DBUF_CTL_S1, \
5572                                                             _DBUF_CTL_S2, \
5573                                                             _DBUF_CTL_S3))
5574 #define  DBUF_POWER_REQUEST                     REG_BIT(31)
5575 #define  DBUF_POWER_STATE                       REG_BIT(30)
5576 #define  DBUF_TRACKER_STATE_SERVICE_MASK        REG_GENMASK(23, 19)
5577 #define  DBUF_TRACKER_STATE_SERVICE(x)          REG_FIELD_PREP(DBUF_TRACKER_STATE_SERVICE_MASK, x)
5578 #define  DBUF_MIN_TRACKER_STATE_SERVICE_MASK    REG_GENMASK(18, 16) /* ADL-P+ */
5579 #define  DBUF_MIN_TRACKER_STATE_SERVICE(x)              REG_FIELD_PREP(DBUF_MIN_TRACKER_STATE_SERVICE_MASK, x) /* ADL-P+ */
5580
5581 #define GEN7_MSG_CTL    _MMIO(0x45010)
5582 #define  WAIT_FOR_PCH_RESET_ACK         (1 << 1)
5583 #define  WAIT_FOR_PCH_FLR_ACK           (1 << 0)
5584
5585 #define _BW_BUDDY0_CTL                  0x45130
5586 #define _BW_BUDDY1_CTL                  0x45140
5587 #define BW_BUDDY_CTL(x)                 _MMIO(_PICK_EVEN(x, \
5588                                                          _BW_BUDDY0_CTL, \
5589                                                          _BW_BUDDY1_CTL))
5590 #define   BW_BUDDY_DISABLE              REG_BIT(31)
5591 #define   BW_BUDDY_TLB_REQ_TIMER_MASK   REG_GENMASK(21, 16)
5592 #define   BW_BUDDY_TLB_REQ_TIMER(x)     REG_FIELD_PREP(BW_BUDDY_TLB_REQ_TIMER_MASK, x)
5593
5594 #define _BW_BUDDY0_PAGE_MASK            0x45134
5595 #define _BW_BUDDY1_PAGE_MASK            0x45144
5596 #define BW_BUDDY_PAGE_MASK(x)           _MMIO(_PICK_EVEN(x, \
5597                                                          _BW_BUDDY0_PAGE_MASK, \
5598                                                          _BW_BUDDY1_PAGE_MASK))
5599
5600 #define HSW_NDE_RSTWRN_OPT      _MMIO(0x46408)
5601 #define  MTL_RESET_PICA_HANDSHAKE_EN    REG_BIT(6)
5602 #define  RESET_PCH_HANDSHAKE_ENABLE     REG_BIT(4)
5603
5604 #define GEN8_CHICKEN_DCPR_1                     _MMIO(0x46430)
5605 #define   LATENCY_REPORTING_REMOVED_PIPE_D      REG_BIT(31)
5606 #define   SKL_SELECT_ALTERNATE_DC_EXIT          REG_BIT(30)
5607 #define   LATENCY_REPORTING_REMOVED_PIPE_C      REG_BIT(25)
5608 #define   LATENCY_REPORTING_REMOVED_PIPE_B      REG_BIT(24)
5609 #define   LATENCY_REPORTING_REMOVED_PIPE_A      REG_BIT(23)
5610 #define   ICL_DELAY_PMRSP                       REG_BIT(22)
5611 #define   DISABLE_FLR_SRC                       REG_BIT(15)
5612 #define   MASK_WAKEMEM                          REG_BIT(13)
5613 #define   DDI_CLOCK_REG_ACCESS                  REG_BIT(7)
5614
5615 #define GEN11_CHICKEN_DCPR_2                    _MMIO(0x46434)
5616 #define   DCPR_MASK_MAXLATENCY_MEMUP_CLR        REG_BIT(27)
5617 #define   DCPR_MASK_LPMODE                      REG_BIT(26)
5618 #define   DCPR_SEND_RESP_IMM                    REG_BIT(25)
5619 #define   DCPR_CLEAR_MEMSTAT_DIS                REG_BIT(24)
5620
5621 #define SKL_DFSM                        _MMIO(0x51000)
5622 #define   SKL_DFSM_DISPLAY_PM_DISABLE   (1 << 27)
5623 #define   SKL_DFSM_DISPLAY_HDCP_DISABLE (1 << 25)
5624 #define   SKL_DFSM_CDCLK_LIMIT_MASK     (3 << 23)
5625 #define   SKL_DFSM_CDCLK_LIMIT_675      (0 << 23)
5626 #define   SKL_DFSM_CDCLK_LIMIT_540      (1 << 23)
5627 #define   SKL_DFSM_CDCLK_LIMIT_450      (2 << 23)
5628 #define   SKL_DFSM_CDCLK_LIMIT_337_5    (3 << 23)
5629 #define   ICL_DFSM_DMC_DISABLE          (1 << 23)
5630 #define   SKL_DFSM_PIPE_A_DISABLE       (1 << 30)
5631 #define   SKL_DFSM_PIPE_B_DISABLE       (1 << 21)
5632 #define   SKL_DFSM_PIPE_C_DISABLE       (1 << 28)
5633 #define   TGL_DFSM_PIPE_D_DISABLE       (1 << 22)
5634 #define   GLK_DFSM_DISPLAY_DSC_DISABLE  (1 << 7)
5635
5636 #define SKL_DSSM                                _MMIO(0x51004)
5637 #define ICL_DSSM_CDCLK_PLL_REFCLK_MASK          (7 << 29)
5638 #define ICL_DSSM_CDCLK_PLL_REFCLK_24MHz         (0 << 29)
5639 #define ICL_DSSM_CDCLK_PLL_REFCLK_19_2MHz       (1 << 29)
5640 #define ICL_DSSM_CDCLK_PLL_REFCLK_38_4MHz       (2 << 29)
5641
5642 #define GMD_ID_DISPLAY                          _MMIO(0x510a0)
5643 #define   GMD_ID_ARCH_MASK                      REG_GENMASK(31, 22)
5644 #define   GMD_ID_RELEASE_MASK                   REG_GENMASK(21, 14)
5645 #define   GMD_ID_STEP                           REG_GENMASK(5, 0)
5646
5647 /*GEN11 chicken */
5648 #define _PIPEA_CHICKEN                          0x70038
5649 #define _PIPEB_CHICKEN                          0x71038
5650 #define _PIPEC_CHICKEN                          0x72038
5651 #define PIPE_CHICKEN(pipe)                      _MMIO_PIPE(pipe, _PIPEA_CHICKEN,\
5652                                                            _PIPEB_CHICKEN)
5653 #define   UNDERRUN_RECOVERY_DISABLE_ADLP        REG_BIT(30)
5654 #define   UNDERRUN_RECOVERY_ENABLE_DG2          REG_BIT(30)
5655 #define   PIXEL_ROUNDING_TRUNC_FB_PASSTHRU      REG_BIT(15)
5656 #define   DG2_RENDER_CCSTAG_4_3_EN              REG_BIT(12)
5657 #define   PER_PIXEL_ALPHA_BYPASS_EN             REG_BIT(7)
5658
5659 /* PCH */
5660
5661 #define PCH_DISPLAY_BASE        0xc0000u
5662
5663 /* south display engine interrupt: IBX */
5664 #define SDE_AUDIO_POWER_D       (1 << 27)
5665 #define SDE_AUDIO_POWER_C       (1 << 26)
5666 #define SDE_AUDIO_POWER_B       (1 << 25)
5667 #define SDE_AUDIO_POWER_SHIFT   (25)
5668 #define SDE_AUDIO_POWER_MASK    (7 << SDE_AUDIO_POWER_SHIFT)
5669 #define SDE_GMBUS               (1 << 24)
5670 #define SDE_AUDIO_HDCP_TRANSB   (1 << 23)
5671 #define SDE_AUDIO_HDCP_TRANSA   (1 << 22)
5672 #define SDE_AUDIO_HDCP_MASK     (3 << 22)
5673 #define SDE_AUDIO_TRANSB        (1 << 21)
5674 #define SDE_AUDIO_TRANSA        (1 << 20)
5675 #define SDE_AUDIO_TRANS_MASK    (3 << 20)
5676 #define SDE_POISON              (1 << 19)
5677 /* 18 reserved */
5678 #define SDE_FDI_RXB             (1 << 17)
5679 #define SDE_FDI_RXA             (1 << 16)
5680 #define SDE_FDI_MASK            (3 << 16)
5681 #define SDE_AUXD                (1 << 15)
5682 #define SDE_AUXC                (1 << 14)
5683 #define SDE_AUXB                (1 << 13)
5684 #define SDE_AUX_MASK            (7 << 13)
5685 /* 12 reserved */
5686 #define SDE_CRT_HOTPLUG         (1 << 11)
5687 #define SDE_PORTD_HOTPLUG       (1 << 10)
5688 #define SDE_PORTC_HOTPLUG       (1 << 9)
5689 #define SDE_PORTB_HOTPLUG       (1 << 8)
5690 #define SDE_SDVOB_HOTPLUG       (1 << 6)
5691 #define SDE_HOTPLUG_MASK        (SDE_CRT_HOTPLUG | \
5692                                  SDE_SDVOB_HOTPLUG |    \
5693                                  SDE_PORTB_HOTPLUG |    \
5694                                  SDE_PORTC_HOTPLUG |    \
5695                                  SDE_PORTD_HOTPLUG)
5696 #define SDE_TRANSB_CRC_DONE     (1 << 5)
5697 #define SDE_TRANSB_CRC_ERR      (1 << 4)
5698 #define SDE_TRANSB_FIFO_UNDER   (1 << 3)
5699 #define SDE_TRANSA_CRC_DONE     (1 << 2)
5700 #define SDE_TRANSA_CRC_ERR      (1 << 1)
5701 #define SDE_TRANSA_FIFO_UNDER   (1 << 0)
5702 #define SDE_TRANS_MASK          (0x3f)
5703
5704 /* south display engine interrupt: CPT - CNP */
5705 #define SDE_AUDIO_POWER_D_CPT   (1 << 31)
5706 #define SDE_AUDIO_POWER_C_CPT   (1 << 30)
5707 #define SDE_AUDIO_POWER_B_CPT   (1 << 29)
5708 #define SDE_AUDIO_POWER_SHIFT_CPT   29
5709 #define SDE_AUDIO_POWER_MASK_CPT    (7 << 29)
5710 #define SDE_AUXD_CPT            (1 << 27)
5711 #define SDE_AUXC_CPT            (1 << 26)
5712 #define SDE_AUXB_CPT            (1 << 25)
5713 #define SDE_AUX_MASK_CPT        (7 << 25)
5714 #define SDE_PORTE_HOTPLUG_SPT   (1 << 25)
5715 #define SDE_PORTA_HOTPLUG_SPT   (1 << 24)
5716 #define SDE_PORTD_HOTPLUG_CPT   (1 << 23)
5717 #define SDE_PORTC_HOTPLUG_CPT   (1 << 22)
5718 #define SDE_PORTB_HOTPLUG_CPT   (1 << 21)
5719 #define SDE_CRT_HOTPLUG_CPT     (1 << 19)
5720 #define SDE_SDVOB_HOTPLUG_CPT   (1 << 18)
5721 #define SDE_HOTPLUG_MASK_CPT    (SDE_CRT_HOTPLUG_CPT |          \
5722                                  SDE_SDVOB_HOTPLUG_CPT |        \
5723                                  SDE_PORTD_HOTPLUG_CPT |        \
5724                                  SDE_PORTC_HOTPLUG_CPT |        \
5725                                  SDE_PORTB_HOTPLUG_CPT)
5726 #define SDE_HOTPLUG_MASK_SPT    (SDE_PORTE_HOTPLUG_SPT |        \
5727                                  SDE_PORTD_HOTPLUG_CPT |        \
5728                                  SDE_PORTC_HOTPLUG_CPT |        \
5729                                  SDE_PORTB_HOTPLUG_CPT |        \
5730                                  SDE_PORTA_HOTPLUG_SPT)
5731 #define SDE_GMBUS_CPT           (1 << 17)
5732 #define SDE_ERROR_CPT           (1 << 16)
5733 #define SDE_AUDIO_CP_REQ_C_CPT  (1 << 10)
5734 #define SDE_AUDIO_CP_CHG_C_CPT  (1 << 9)
5735 #define SDE_FDI_RXC_CPT         (1 << 8)
5736 #define SDE_AUDIO_CP_REQ_B_CPT  (1 << 6)
5737 #define SDE_AUDIO_CP_CHG_B_CPT  (1 << 5)
5738 #define SDE_FDI_RXB_CPT         (1 << 4)
5739 #define SDE_AUDIO_CP_REQ_A_CPT  (1 << 2)
5740 #define SDE_AUDIO_CP_CHG_A_CPT  (1 << 1)
5741 #define SDE_FDI_RXA_CPT         (1 << 0)
5742 #define SDE_AUDIO_CP_REQ_CPT    (SDE_AUDIO_CP_REQ_C_CPT | \
5743                                  SDE_AUDIO_CP_REQ_B_CPT | \
5744                                  SDE_AUDIO_CP_REQ_A_CPT)
5745 #define SDE_AUDIO_CP_CHG_CPT    (SDE_AUDIO_CP_CHG_C_CPT | \
5746                                  SDE_AUDIO_CP_CHG_B_CPT | \
5747                                  SDE_AUDIO_CP_CHG_A_CPT)
5748 #define SDE_FDI_MASK_CPT        (SDE_FDI_RXC_CPT | \
5749                                  SDE_FDI_RXB_CPT | \
5750                                  SDE_FDI_RXA_CPT)
5751
5752 /* south display engine interrupt: ICP/TGP */
5753 #define SDE_GMBUS_ICP                   (1 << 23)
5754 #define SDE_TC_HOTPLUG_ICP(hpd_pin)     REG_BIT(24 + _HPD_PIN_TC(hpd_pin))
5755 #define SDE_TC_HOTPLUG_DG2(hpd_pin)     REG_BIT(25 + _HPD_PIN_TC(hpd_pin)) /* sigh */
5756 #define SDE_DDI_HOTPLUG_ICP(hpd_pin)    REG_BIT(16 + _HPD_PIN_DDI(hpd_pin))
5757 #define SDE_DDI_HOTPLUG_MASK_ICP        (SDE_DDI_HOTPLUG_ICP(HPD_PORT_D) | \
5758                                          SDE_DDI_HOTPLUG_ICP(HPD_PORT_C) | \
5759                                          SDE_DDI_HOTPLUG_ICP(HPD_PORT_B) | \
5760                                          SDE_DDI_HOTPLUG_ICP(HPD_PORT_A))
5761 #define SDE_TC_HOTPLUG_MASK_ICP         (SDE_TC_HOTPLUG_ICP(HPD_PORT_TC6) | \
5762                                          SDE_TC_HOTPLUG_ICP(HPD_PORT_TC5) | \
5763                                          SDE_TC_HOTPLUG_ICP(HPD_PORT_TC4) | \
5764                                          SDE_TC_HOTPLUG_ICP(HPD_PORT_TC3) | \
5765                                          SDE_TC_HOTPLUG_ICP(HPD_PORT_TC2) | \
5766                                          SDE_TC_HOTPLUG_ICP(HPD_PORT_TC1))
5767
5768 #define SDEISR  _MMIO(0xc4000)
5769 #define SDEIMR  _MMIO(0xc4004)
5770 #define SDEIIR  _MMIO(0xc4008)
5771 #define SDEIER  _MMIO(0xc400c)
5772
5773 #define SERR_INT                        _MMIO(0xc4040)
5774 #define  SERR_INT_POISON                (1 << 31)
5775 #define  SERR_INT_TRANS_FIFO_UNDERRUN(pipe)     (1 << ((pipe) * 3))
5776
5777 /* digital port hotplug */
5778 #define PCH_PORT_HOTPLUG                _MMIO(0xc4030)  /* SHOTPLUG_CTL */
5779 #define  PORTA_HOTPLUG_ENABLE           (1 << 28) /* LPT:LP+ & BXT */
5780 #define  BXT_DDIA_HPD_INVERT            (1 << 27)
5781 #define  PORTA_HOTPLUG_STATUS_MASK      (3 << 24) /* SPT+ & BXT */
5782 #define  PORTA_HOTPLUG_NO_DETECT        (0 << 24) /* SPT+ & BXT */
5783 #define  PORTA_HOTPLUG_SHORT_DETECT     (1 << 24) /* SPT+ & BXT */
5784 #define  PORTA_HOTPLUG_LONG_DETECT      (2 << 24) /* SPT+ & BXT */
5785 #define  PORTD_HOTPLUG_ENABLE           (1 << 20)
5786 #define  PORTD_PULSE_DURATION_2ms       (0 << 18) /* pre-LPT */
5787 #define  PORTD_PULSE_DURATION_4_5ms     (1 << 18) /* pre-LPT */
5788 #define  PORTD_PULSE_DURATION_6ms       (2 << 18) /* pre-LPT */
5789 #define  PORTD_PULSE_DURATION_100ms     (3 << 18) /* pre-LPT */
5790 #define  PORTD_PULSE_DURATION_MASK      (3 << 18) /* pre-LPT */
5791 #define  PORTD_HOTPLUG_STATUS_MASK      (3 << 16)
5792 #define  PORTD_HOTPLUG_NO_DETECT        (0 << 16)
5793 #define  PORTD_HOTPLUG_SHORT_DETECT     (1 << 16)
5794 #define  PORTD_HOTPLUG_LONG_DETECT      (2 << 16)
5795 #define  PORTC_HOTPLUG_ENABLE           (1 << 12)
5796 #define  BXT_DDIC_HPD_INVERT            (1 << 11)
5797 #define  PORTC_PULSE_DURATION_2ms       (0 << 10) /* pre-LPT */
5798 #define  PORTC_PULSE_DURATION_4_5ms     (1 << 10) /* pre-LPT */
5799 #define  PORTC_PULSE_DURATION_6ms       (2 << 10) /* pre-LPT */
5800 #define  PORTC_PULSE_DURATION_100ms     (3 << 10) /* pre-LPT */
5801 #define  PORTC_PULSE_DURATION_MASK      (3 << 10) /* pre-LPT */
5802 #define  PORTC_HOTPLUG_STATUS_MASK      (3 << 8)
5803 #define  PORTC_HOTPLUG_NO_DETECT        (0 << 8)
5804 #define  PORTC_HOTPLUG_SHORT_DETECT     (1 << 8)
5805 #define  PORTC_HOTPLUG_LONG_DETECT      (2 << 8)
5806 #define  PORTB_HOTPLUG_ENABLE           (1 << 4)
5807 #define  BXT_DDIB_HPD_INVERT            (1 << 3)
5808 #define  PORTB_PULSE_DURATION_2ms       (0 << 2) /* pre-LPT */
5809 #define  PORTB_PULSE_DURATION_4_5ms     (1 << 2) /* pre-LPT */
5810 #define  PORTB_PULSE_DURATION_6ms       (2 << 2) /* pre-LPT */
5811 #define  PORTB_PULSE_DURATION_100ms     (3 << 2) /* pre-LPT */
5812 #define  PORTB_PULSE_DURATION_MASK      (3 << 2) /* pre-LPT */
5813 #define  PORTB_HOTPLUG_STATUS_MASK      (3 << 0)
5814 #define  PORTB_HOTPLUG_NO_DETECT        (0 << 0)
5815 #define  PORTB_HOTPLUG_SHORT_DETECT     (1 << 0)
5816 #define  PORTB_HOTPLUG_LONG_DETECT      (2 << 0)
5817 #define  BXT_DDI_HPD_INVERT_MASK        (BXT_DDIA_HPD_INVERT | \
5818                                         BXT_DDIB_HPD_INVERT | \
5819                                         BXT_DDIC_HPD_INVERT)
5820
5821 #define PCH_PORT_HOTPLUG2               _MMIO(0xc403C)  /* SHOTPLUG_CTL2 SPT+ */
5822 #define  PORTE_HOTPLUG_ENABLE           (1 << 4)
5823 #define  PORTE_HOTPLUG_STATUS_MASK      (3 << 0)
5824 #define  PORTE_HOTPLUG_NO_DETECT        (0 << 0)
5825 #define  PORTE_HOTPLUG_SHORT_DETECT     (1 << 0)
5826 #define  PORTE_HOTPLUG_LONG_DETECT      (2 << 0)
5827
5828 /* This register is a reuse of PCH_PORT_HOTPLUG register. The
5829  * functionality covered in PCH_PORT_HOTPLUG is split into
5830  * SHOTPLUG_CTL_DDI and SHOTPLUG_CTL_TC.
5831  */
5832
5833 #define SHOTPLUG_CTL_DDI                                _MMIO(0xc4030)
5834 #define   SHOTPLUG_CTL_DDI_HPD_ENABLE(hpd_pin)                  (0x8 << (_HPD_PIN_DDI(hpd_pin) * 4))
5835 #define   SHOTPLUG_CTL_DDI_HPD_OUTPUT_DATA(hpd_pin)             (0x4 << (_HPD_PIN_DDI(hpd_pin) * 4))
5836 #define   SHOTPLUG_CTL_DDI_HPD_STATUS_MASK(hpd_pin)             (0x3 << (_HPD_PIN_DDI(hpd_pin) * 4))
5837 #define   SHOTPLUG_CTL_DDI_HPD_NO_DETECT(hpd_pin)               (0x0 << (_HPD_PIN_DDI(hpd_pin) * 4))
5838 #define   SHOTPLUG_CTL_DDI_HPD_SHORT_DETECT(hpd_pin)            (0x1 << (_HPD_PIN_DDI(hpd_pin) * 4))
5839 #define   SHOTPLUG_CTL_DDI_HPD_LONG_DETECT(hpd_pin)             (0x2 << (_HPD_PIN_DDI(hpd_pin) * 4))
5840 #define   SHOTPLUG_CTL_DDI_HPD_SHORT_LONG_DETECT(hpd_pin)       (0x3 << (_HPD_PIN_DDI(hpd_pin) * 4))
5841
5842 #define SHOTPLUG_CTL_TC                         _MMIO(0xc4034)
5843 #define   ICP_TC_HPD_ENABLE(hpd_pin)            (8 << (_HPD_PIN_TC(hpd_pin) * 4))
5844 #define   ICP_TC_HPD_LONG_DETECT(hpd_pin)       (2 << (_HPD_PIN_TC(hpd_pin) * 4))
5845 #define   ICP_TC_HPD_SHORT_DETECT(hpd_pin)      (1 << (_HPD_PIN_TC(hpd_pin) * 4))
5846
5847 #define SHPD_FILTER_CNT                         _MMIO(0xc4038)
5848 #define   SHPD_FILTER_CNT_500_ADJ               0x001D9
5849
5850 #define _PCH_DPLL_A              0xc6014
5851 #define _PCH_DPLL_B              0xc6018
5852 #define PCH_DPLL(pll) _MMIO((pll) == 0 ? _PCH_DPLL_A : _PCH_DPLL_B)
5853
5854 #define _PCH_FPA0                0xc6040
5855 #define  FP_CB_TUNE             (0x3 << 22)
5856 #define _PCH_FPA1                0xc6044
5857 #define _PCH_FPB0                0xc6048
5858 #define _PCH_FPB1                0xc604c
5859 #define PCH_FP0(pll) _MMIO((pll) == 0 ? _PCH_FPA0 : _PCH_FPB0)
5860 #define PCH_FP1(pll) _MMIO((pll) == 0 ? _PCH_FPA1 : _PCH_FPB1)
5861
5862 #define PCH_DPLL_TEST           _MMIO(0xc606c)
5863
5864 #define PCH_DREF_CONTROL        _MMIO(0xC6200)
5865 #define  DREF_CONTROL_MASK      0x7fc3
5866 #define  DREF_CPU_SOURCE_OUTPUT_DISABLE         (0 << 13)
5867 #define  DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD      (2 << 13)
5868 #define  DREF_CPU_SOURCE_OUTPUT_NONSPREAD       (3 << 13)
5869 #define  DREF_CPU_SOURCE_OUTPUT_MASK            (3 << 13)
5870 #define  DREF_SSC_SOURCE_DISABLE                (0 << 11)
5871 #define  DREF_SSC_SOURCE_ENABLE                 (2 << 11)
5872 #define  DREF_SSC_SOURCE_MASK                   (3 << 11)
5873 #define  DREF_NONSPREAD_SOURCE_DISABLE          (0 << 9)
5874 #define  DREF_NONSPREAD_CK505_ENABLE            (1 << 9)
5875 #define  DREF_NONSPREAD_SOURCE_ENABLE           (2 << 9)
5876 #define  DREF_NONSPREAD_SOURCE_MASK             (3 << 9)
5877 #define  DREF_SUPERSPREAD_SOURCE_DISABLE        (0 << 7)
5878 #define  DREF_SUPERSPREAD_SOURCE_ENABLE         (2 << 7)
5879 #define  DREF_SUPERSPREAD_SOURCE_MASK           (3 << 7)
5880 #define  DREF_SSC4_DOWNSPREAD                   (0 << 6)
5881 #define  DREF_SSC4_CENTERSPREAD                 (1 << 6)
5882 #define  DREF_SSC1_DISABLE                      (0 << 1)
5883 #define  DREF_SSC1_ENABLE                       (1 << 1)
5884 #define  DREF_SSC4_DISABLE                      (0)
5885 #define  DREF_SSC4_ENABLE                       (1)
5886
5887 #define PCH_RAWCLK_FREQ         _MMIO(0xc6204)
5888 #define  FDL_TP1_TIMER_SHIFT    12
5889 #define  FDL_TP1_TIMER_MASK     (3 << 12)
5890 #define  FDL_TP2_TIMER_SHIFT    10
5891 #define  FDL_TP2_TIMER_MASK     (3 << 10)
5892 #define  RAWCLK_FREQ_MASK       0x3ff
5893 #define  CNP_RAWCLK_DIV_MASK    (0x3ff << 16)
5894 #define  CNP_RAWCLK_DIV(div)    ((div) << 16)
5895 #define  CNP_RAWCLK_FRAC_MASK   (0xf << 26)
5896 #define  CNP_RAWCLK_DEN(den)    ((den) << 26)
5897 #define  ICP_RAWCLK_NUM(num)    ((num) << 11)
5898
5899 #define PCH_DPLL_TMR_CFG        _MMIO(0xc6208)
5900
5901 #define PCH_SSC4_PARMS          _MMIO(0xc6210)
5902 #define PCH_SSC4_AUX_PARMS      _MMIO(0xc6214)
5903
5904 #define PCH_DPLL_SEL            _MMIO(0xc7000)
5905 #define  TRANS_DPLLB_SEL(pipe)          (1 << ((pipe) * 4))
5906 #define  TRANS_DPLLA_SEL(pipe)          0
5907 #define  TRANS_DPLL_ENABLE(pipe)        (1 << ((pipe) * 4 + 3))
5908
5909 /* transcoder */
5910
5911 #define _PCH_TRANS_HTOTAL_A             0xe0000
5912 #define  TRANS_HTOTAL_SHIFT             16
5913 #define  TRANS_HACTIVE_SHIFT            0
5914 #define _PCH_TRANS_HBLANK_A             0xe0004
5915 #define  TRANS_HBLANK_END_SHIFT         16
5916 #define  TRANS_HBLANK_START_SHIFT       0
5917 #define _PCH_TRANS_HSYNC_A              0xe0008
5918 #define  TRANS_HSYNC_END_SHIFT          16
5919 #define  TRANS_HSYNC_START_SHIFT        0
5920 #define _PCH_TRANS_VTOTAL_A             0xe000c
5921 #define  TRANS_VTOTAL_SHIFT             16
5922 #define  TRANS_VACTIVE_SHIFT            0
5923 #define _PCH_TRANS_VBLANK_A             0xe0010
5924 #define  TRANS_VBLANK_END_SHIFT         16
5925 #define  TRANS_VBLANK_START_SHIFT       0
5926 #define _PCH_TRANS_VSYNC_A              0xe0014
5927 #define  TRANS_VSYNC_END_SHIFT          16
5928 #define  TRANS_VSYNC_START_SHIFT        0
5929 #define _PCH_TRANS_VSYNCSHIFT_A         0xe0028
5930
5931 #define _PCH_TRANSA_DATA_M1     0xe0030
5932 #define _PCH_TRANSA_DATA_N1     0xe0034
5933 #define _PCH_TRANSA_DATA_M2     0xe0038
5934 #define _PCH_TRANSA_DATA_N2     0xe003c
5935 #define _PCH_TRANSA_LINK_M1     0xe0040
5936 #define _PCH_TRANSA_LINK_N1     0xe0044
5937 #define _PCH_TRANSA_LINK_M2     0xe0048
5938 #define _PCH_TRANSA_LINK_N2     0xe004c
5939
5940 /* Per-transcoder DIP controls (PCH) */
5941 #define _VIDEO_DIP_CTL_A         0xe0200
5942 #define _VIDEO_DIP_DATA_A        0xe0208
5943 #define _VIDEO_DIP_GCP_A         0xe0210
5944 #define  GCP_COLOR_INDICATION           (1 << 2)
5945 #define  GCP_DEFAULT_PHASE_ENABLE       (1 << 1)
5946 #define  GCP_AV_MUTE                    (1 << 0)
5947
5948 #define _VIDEO_DIP_CTL_B         0xe1200
5949 #define _VIDEO_DIP_DATA_B        0xe1208
5950 #define _VIDEO_DIP_GCP_B         0xe1210
5951
5952 #define TVIDEO_DIP_CTL(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_CTL_A, _VIDEO_DIP_CTL_B)
5953 #define TVIDEO_DIP_DATA(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_DATA_A, _VIDEO_DIP_DATA_B)
5954 #define TVIDEO_DIP_GCP(pipe) _MMIO_PIPE(pipe, _VIDEO_DIP_GCP_A, _VIDEO_DIP_GCP_B)
5955
5956 /* Per-transcoder DIP controls (VLV) */
5957 #define _VLV_VIDEO_DIP_CTL_A            (VLV_DISPLAY_BASE + 0x60200)
5958 #define _VLV_VIDEO_DIP_DATA_A           (VLV_DISPLAY_BASE + 0x60208)
5959 #define _VLV_VIDEO_DIP_GDCP_PAYLOAD_A   (VLV_DISPLAY_BASE + 0x60210)
5960
5961 #define _VLV_VIDEO_DIP_CTL_B            (VLV_DISPLAY_BASE + 0x61170)
5962 #define _VLV_VIDEO_DIP_DATA_B           (VLV_DISPLAY_BASE + 0x61174)
5963 #define _VLV_VIDEO_DIP_GDCP_PAYLOAD_B   (VLV_DISPLAY_BASE + 0x61178)
5964
5965 #define _CHV_VIDEO_DIP_CTL_C            (VLV_DISPLAY_BASE + 0x611f0)
5966 #define _CHV_VIDEO_DIP_DATA_C           (VLV_DISPLAY_BASE + 0x611f4)
5967 #define _CHV_VIDEO_DIP_GDCP_PAYLOAD_C   (VLV_DISPLAY_BASE + 0x611f8)
5968
5969 #define VLV_TVIDEO_DIP_CTL(pipe) \
5970         _MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_CTL_A, \
5971                _VLV_VIDEO_DIP_CTL_B, _CHV_VIDEO_DIP_CTL_C)
5972 #define VLV_TVIDEO_DIP_DATA(pipe) \
5973         _MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_DATA_A, \
5974                _VLV_VIDEO_DIP_DATA_B, _CHV_VIDEO_DIP_DATA_C)
5975 #define VLV_TVIDEO_DIP_GCP(pipe) \
5976         _MMIO_PIPE3((pipe), _VLV_VIDEO_DIP_GDCP_PAYLOAD_A, \
5977                 _VLV_VIDEO_DIP_GDCP_PAYLOAD_B, _CHV_VIDEO_DIP_GDCP_PAYLOAD_C)
5978
5979 /* Haswell DIP controls */
5980
5981 #define _HSW_VIDEO_DIP_CTL_A            0x60200
5982 #define _HSW_VIDEO_DIP_AVI_DATA_A       0x60220
5983 #define _HSW_VIDEO_DIP_VS_DATA_A        0x60260
5984 #define _HSW_VIDEO_DIP_SPD_DATA_A       0x602A0
5985 #define _HSW_VIDEO_DIP_GMP_DATA_A       0x602E0
5986 #define _HSW_VIDEO_DIP_VSC_DATA_A       0x60320
5987 #define _GLK_VIDEO_DIP_DRM_DATA_A       0x60440
5988 #define _HSW_VIDEO_DIP_AVI_ECC_A        0x60240
5989 #define _HSW_VIDEO_DIP_VS_ECC_A         0x60280
5990 #define _HSW_VIDEO_DIP_SPD_ECC_A        0x602C0
5991 #define _HSW_VIDEO_DIP_GMP_ECC_A        0x60300
5992 #define _HSW_VIDEO_DIP_VSC_ECC_A        0x60344
5993 #define _HSW_VIDEO_DIP_GCP_A            0x60210
5994
5995 #define _HSW_VIDEO_DIP_CTL_B            0x61200
5996 #define _HSW_VIDEO_DIP_AVI_DATA_B       0x61220
5997 #define _HSW_VIDEO_DIP_VS_DATA_B        0x61260
5998 #define _HSW_VIDEO_DIP_SPD_DATA_B       0x612A0
5999 #define _HSW_VIDEO_DIP_GMP_DATA_B       0x612E0
6000 #define _HSW_VIDEO_DIP_VSC_DATA_B       0x61320
6001 #define _GLK_VIDEO_DIP_DRM_DATA_B       0x61440
6002 #define _HSW_VIDEO_DIP_BVI_ECC_B        0x61240
6003 #define _HSW_VIDEO_DIP_VS_ECC_B         0x61280
6004 #define _HSW_VIDEO_DIP_SPD_ECC_B        0x612C0
6005 #define _HSW_VIDEO_DIP_GMP_ECC_B        0x61300
6006 #define _HSW_VIDEO_DIP_VSC_ECC_B        0x61344
6007 #define _HSW_VIDEO_DIP_GCP_B            0x61210
6008
6009 /* Icelake PPS_DATA and _ECC DIP Registers.
6010  * These are available for transcoders B,C and eDP.
6011  * Adding the _A so as to reuse the _MMIO_TRANS2
6012  * definition, with which it offsets to the right location.
6013  */
6014
6015 #define _ICL_VIDEO_DIP_PPS_DATA_A       0x60350
6016 #define _ICL_VIDEO_DIP_PPS_DATA_B       0x61350
6017 #define _ICL_VIDEO_DIP_PPS_ECC_A        0x603D4
6018 #define _ICL_VIDEO_DIP_PPS_ECC_B        0x613D4
6019
6020 #define HSW_TVIDEO_DIP_CTL(trans)               _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_CTL_A)
6021 #define HSW_TVIDEO_DIP_GCP(trans)               _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GCP_A)
6022 #define HSW_TVIDEO_DIP_AVI_DATA(trans, i)       _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_AVI_DATA_A + (i) * 4)
6023 #define HSW_TVIDEO_DIP_VS_DATA(trans, i)        _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VS_DATA_A + (i) * 4)
6024 #define HSW_TVIDEO_DIP_SPD_DATA(trans, i)       _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_SPD_DATA_A + (i) * 4)
6025 #define HSW_TVIDEO_DIP_GMP_DATA(trans, i)       _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GMP_DATA_A + (i) * 4)
6026 #define HSW_TVIDEO_DIP_VSC_DATA(trans, i)       _MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VSC_DATA_A + (i) * 4)
6027 #define GLK_TVIDEO_DIP_DRM_DATA(trans, i)       _MMIO_TRANS2(trans, _GLK_VIDEO_DIP_DRM_DATA_A + (i) * 4)
6028 #define ICL_VIDEO_DIP_PPS_DATA(trans, i)        _MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_DATA_A + (i) * 4)
6029 #define ICL_VIDEO_DIP_PPS_ECC(trans, i)         _MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_ECC_A + (i) * 4)
6030
6031 #define _HSW_STEREO_3D_CTL_A            0x70020
6032 #define   S3D_ENABLE                    (1 << 31)
6033 #define _HSW_STEREO_3D_CTL_B            0x71020
6034
6035 #define HSW_STEREO_3D_CTL(trans)        _MMIO_PIPE2(trans, _HSW_STEREO_3D_CTL_A)
6036
6037 #define _PCH_TRANS_HTOTAL_B          0xe1000
6038 #define _PCH_TRANS_HBLANK_B          0xe1004
6039 #define _PCH_TRANS_HSYNC_B           0xe1008
6040 #define _PCH_TRANS_VTOTAL_B          0xe100c
6041 #define _PCH_TRANS_VBLANK_B          0xe1010
6042 #define _PCH_TRANS_VSYNC_B           0xe1014
6043 #define _PCH_TRANS_VSYNCSHIFT_B 0xe1028
6044
6045 #define PCH_TRANS_HTOTAL(pipe)          _MMIO_PIPE(pipe, _PCH_TRANS_HTOTAL_A, _PCH_TRANS_HTOTAL_B)
6046 #define PCH_TRANS_HBLANK(pipe)          _MMIO_PIPE(pipe, _PCH_TRANS_HBLANK_A, _PCH_TRANS_HBLANK_B)
6047 #define PCH_TRANS_HSYNC(pipe)           _MMIO_PIPE(pipe, _PCH_TRANS_HSYNC_A, _PCH_TRANS_HSYNC_B)
6048 #define PCH_TRANS_VTOTAL(pipe)          _MMIO_PIPE(pipe, _PCH_TRANS_VTOTAL_A, _PCH_TRANS_VTOTAL_B)
6049 #define PCH_TRANS_VBLANK(pipe)          _MMIO_PIPE(pipe, _PCH_TRANS_VBLANK_A, _PCH_TRANS_VBLANK_B)
6050 #define PCH_TRANS_VSYNC(pipe)           _MMIO_PIPE(pipe, _PCH_TRANS_VSYNC_A, _PCH_TRANS_VSYNC_B)
6051 #define PCH_TRANS_VSYNCSHIFT(pipe)      _MMIO_PIPE(pipe, _PCH_TRANS_VSYNCSHIFT_A, _PCH_TRANS_VSYNCSHIFT_B)
6052
6053 #define _PCH_TRANSB_DATA_M1     0xe1030
6054 #define _PCH_TRANSB_DATA_N1     0xe1034
6055 #define _PCH_TRANSB_DATA_M2     0xe1038
6056 #define _PCH_TRANSB_DATA_N2     0xe103c
6057 #define _PCH_TRANSB_LINK_M1     0xe1040
6058 #define _PCH_TRANSB_LINK_N1     0xe1044
6059 #define _PCH_TRANSB_LINK_M2     0xe1048
6060 #define _PCH_TRANSB_LINK_N2     0xe104c
6061
6062 #define PCH_TRANS_DATA_M1(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_DATA_M1, _PCH_TRANSB_DATA_M1)
6063 #define PCH_TRANS_DATA_N1(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_DATA_N1, _PCH_TRANSB_DATA_N1)
6064 #define PCH_TRANS_DATA_M2(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_DATA_M2, _PCH_TRANSB_DATA_M2)
6065 #define PCH_TRANS_DATA_N2(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_DATA_N2, _PCH_TRANSB_DATA_N2)
6066 #define PCH_TRANS_LINK_M1(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_LINK_M1, _PCH_TRANSB_LINK_M1)
6067 #define PCH_TRANS_LINK_N1(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_LINK_N1, _PCH_TRANSB_LINK_N1)
6068 #define PCH_TRANS_LINK_M2(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_LINK_M2, _PCH_TRANSB_LINK_M2)
6069 #define PCH_TRANS_LINK_N2(pipe) _MMIO_PIPE(pipe, _PCH_TRANSA_LINK_N2, _PCH_TRANSB_LINK_N2)
6070
6071 #define _PCH_TRANSACONF              0xf0008
6072 #define _PCH_TRANSBCONF              0xf1008
6073 #define PCH_TRANSCONF(pipe)     _MMIO_PIPE(pipe, _PCH_TRANSACONF, _PCH_TRANSBCONF)
6074 #define LPT_TRANSCONF           PCH_TRANSCONF(PIPE_A) /* lpt has only one transcoder */
6075 #define  TRANS_ENABLE                   REG_BIT(31)
6076 #define  TRANS_STATE_ENABLE             REG_BIT(30)
6077 #define  TRANS_FRAME_START_DELAY_MASK   REG_GENMASK(28, 27) /* ibx */
6078 #define  TRANS_FRAME_START_DELAY(x)     REG_FIELD_PREP(TRANS_FRAME_START_DELAY_MASK, (x)) /* ibx: 0-3 */
6079 #define  TRANS_INTERLACE_MASK           REG_GENMASK(23, 21)
6080 #define  TRANS_INTERLACE_PROGRESSIVE    REG_FIELD_PREP(TRANS_INTERLACE_MASK, 0)
6081 #define  TRANS_INTERLACE_LEGACY_VSYNC_IBX       REG_FIELD_PREP(TRANS_INTERLACE_MASK, 2) /* ibx */
6082 #define  TRANS_INTERLACE_INTERLACED     REG_FIELD_PREP(TRANS_INTERLACE_MASK, 3)
6083 #define  TRANS_BPC_MASK                 REG_GENMASK(7, 5) /* ibx */
6084 #define  TRANS_BPC_8                    REG_FIELD_PREP(TRANS_BPC_MASK, 0)
6085 #define  TRANS_BPC_10                   REG_FIELD_PREP(TRANS_BPC_MASK, 1)
6086 #define  TRANS_BPC_6                    REG_FIELD_PREP(TRANS_BPC_MASK, 2)
6087 #define  TRANS_BPC_12                   REG_FIELD_PREP(TRANS_BPC_MASK, 3)
6088 #define _TRANSA_CHICKEN1         0xf0060
6089 #define _TRANSB_CHICKEN1         0xf1060
6090 #define TRANS_CHICKEN1(pipe)    _MMIO_PIPE(pipe, _TRANSA_CHICKEN1, _TRANSB_CHICKEN1)
6091 #define  TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE     (1 << 10)
6092 #define  TRANS_CHICKEN1_DP0UNIT_GC_DISABLE      (1 << 4)
6093 #define _TRANSA_CHICKEN2         0xf0064
6094 #define _TRANSB_CHICKEN2         0xf1064
6095 #define TRANS_CHICKEN2(pipe)    _MMIO_PIPE(pipe, _TRANSA_CHICKEN2, _TRANSB_CHICKEN2)
6096 #define  TRANS_CHICKEN2_TIMING_OVERRIDE                 (1 << 31)
6097 #define  TRANS_CHICKEN2_FDI_POLARITY_REVERSED           (1 << 29)
6098 #define  TRANS_CHICKEN2_FRAME_START_DELAY_MASK          (3 << 27)
6099 #define  TRANS_CHICKEN2_FRAME_START_DELAY(x)            ((x) << 27) /* 0-3 */
6100 #define  TRANS_CHICKEN2_DISABLE_DEEP_COLOR_COUNTER      (1 << 26)
6101 #define  TRANS_CHICKEN2_DISABLE_DEEP_COLOR_MODESWITCH   (1 << 25)
6102
6103 #define SOUTH_CHICKEN1          _MMIO(0xc2000)
6104 #define  FDIA_PHASE_SYNC_SHIFT_OVR      19
6105 #define  FDIA_PHASE_SYNC_SHIFT_EN       18
6106 #define  INVERT_DDID_HPD                        (1 << 18)
6107 #define  INVERT_DDIC_HPD                        (1 << 17)
6108 #define  INVERT_DDIB_HPD                        (1 << 16)
6109 #define  INVERT_DDIA_HPD                        (1 << 15)
6110 #define  FDI_PHASE_SYNC_OVR(pipe) (1 << (FDIA_PHASE_SYNC_SHIFT_OVR - ((pipe) * 2)))
6111 #define  FDI_PHASE_SYNC_EN(pipe) (1 << (FDIA_PHASE_SYNC_SHIFT_EN - ((pipe) * 2)))
6112 #define  FDI_BC_BIFURCATION_SELECT      (1 << 12)
6113 #define  CHASSIS_CLK_REQ_DURATION_MASK  (0xf << 8)
6114 #define  CHASSIS_CLK_REQ_DURATION(x)    ((x) << 8)
6115 #define  SBCLK_RUN_REFCLK_DIS           (1 << 7)
6116 #define  ICP_SECOND_PPS_IO_SELECT       REG_BIT(2)
6117 #define  SPT_PWM_GRANULARITY            (1 << 0)
6118 #define SOUTH_CHICKEN2          _MMIO(0xc2004)
6119 #define  FDI_MPHY_IOSFSB_RESET_STATUS   (1 << 13)
6120 #define  FDI_MPHY_IOSFSB_RESET_CTL      (1 << 12)
6121 #define  LPT_PWM_GRANULARITY            (1 << 5)
6122 #define  DPLS_EDP_PPS_FIX_DIS           (1 << 0)
6123
6124 #define _FDI_RXA_CHICKEN        0xc200c
6125 #define _FDI_RXB_CHICKEN        0xc2010
6126 #define  FDI_RX_PHASE_SYNC_POINTER_OVR  (1 << 1)
6127 #define  FDI_RX_PHASE_SYNC_POINTER_EN   (1 << 0)
6128 #define FDI_RX_CHICKEN(pipe)    _MMIO_PIPE(pipe, _FDI_RXA_CHICKEN, _FDI_RXB_CHICKEN)
6129
6130 #define SOUTH_DSPCLK_GATE_D     _MMIO(0xc2020)
6131 #define  PCH_GMBUSUNIT_CLOCK_GATE_DISABLE (1 << 31)
6132 #define  PCH_DPLUNIT_CLOCK_GATE_DISABLE (1 << 30)
6133 #define  PCH_DPLSUNIT_CLOCK_GATE_DISABLE (1 << 29)
6134 #define  PCH_DPMGUNIT_CLOCK_GATE_DISABLE (1 << 15)
6135 #define  PCH_CPUNIT_CLOCK_GATE_DISABLE (1 << 14)
6136 #define  CNP_PWM_CGE_GATING_DISABLE (1 << 13)
6137 #define  PCH_LP_PARTITION_LEVEL_DISABLE  (1 << 12)
6138
6139 /* CPU: FDI_TX */
6140 #define _FDI_TXA_CTL            0x60100
6141 #define _FDI_TXB_CTL            0x61100
6142 #define FDI_TX_CTL(pipe)        _MMIO_PIPE(pipe, _FDI_TXA_CTL, _FDI_TXB_CTL)
6143 #define  FDI_TX_DISABLE         (0 << 31)
6144 #define  FDI_TX_ENABLE          (1 << 31)
6145 #define  FDI_LINK_TRAIN_PATTERN_1       (0 << 28)
6146 #define  FDI_LINK_TRAIN_PATTERN_2       (1 << 28)
6147 #define  FDI_LINK_TRAIN_PATTERN_IDLE    (2 << 28)
6148 #define  FDI_LINK_TRAIN_NONE            (3 << 28)
6149 #define  FDI_LINK_TRAIN_VOLTAGE_0_4V    (0 << 25)
6150 #define  FDI_LINK_TRAIN_VOLTAGE_0_6V    (1 << 25)
6151 #define  FDI_LINK_TRAIN_VOLTAGE_0_8V    (2 << 25)
6152 #define  FDI_LINK_TRAIN_VOLTAGE_1_2V    (3 << 25)
6153 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_NONE (0 << 22)
6154 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_1_5X (1 << 22)
6155 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_2X   (2 << 22)
6156 #define  FDI_LINK_TRAIN_PRE_EMPHASIS_3X   (3 << 22)
6157 /* ILK always use 400mV 0dB for voltage swing and pre-emphasis level.
6158    SNB has different settings. */
6159 /* SNB A-stepping */
6160 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_A         (0x38 << 22)
6161 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_A         (0x02 << 22)
6162 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_A       (0x01 << 22)
6163 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_A         (0x0 << 22)
6164 /* SNB B-stepping */
6165 #define  FDI_LINK_TRAIN_400MV_0DB_SNB_B         (0x0 << 22)
6166 #define  FDI_LINK_TRAIN_400MV_6DB_SNB_B         (0x3a << 22)
6167 #define  FDI_LINK_TRAIN_600MV_3_5DB_SNB_B       (0x39 << 22)
6168 #define  FDI_LINK_TRAIN_800MV_0DB_SNB_B         (0x38 << 22)
6169 #define  FDI_LINK_TRAIN_VOL_EMP_MASK            (0x3f << 22)
6170 #define  FDI_DP_PORT_WIDTH_SHIFT                19
6171 #define  FDI_DP_PORT_WIDTH_MASK                 (7 << FDI_DP_PORT_WIDTH_SHIFT)
6172 #define  FDI_DP_PORT_WIDTH(width)           (((width) - 1) << FDI_DP_PORT_WIDTH_SHIFT)
6173 #define  FDI_TX_ENHANCE_FRAME_ENABLE    (1 << 18)
6174 /* Ironlake: hardwired to 1 */
6175 #define  FDI_TX_PLL_ENABLE              (1 << 14)
6176
6177 /* Ivybridge has different bits for lolz */
6178 #define  FDI_LINK_TRAIN_PATTERN_1_IVB       (0 << 8)
6179 #define  FDI_LINK_TRAIN_PATTERN_2_IVB       (1 << 8)
6180 #define  FDI_LINK_TRAIN_PATTERN_IDLE_IVB    (2 << 8)
6181 #define  FDI_LINK_TRAIN_NONE_IVB            (3 << 8)
6182
6183 /* both Tx and Rx */
6184 #define  FDI_COMPOSITE_SYNC             (1 << 11)
6185 #define  FDI_LINK_TRAIN_AUTO            (1 << 10)
6186 #define  FDI_SCRAMBLING_ENABLE          (0 << 7)
6187 #define  FDI_SCRAMBLING_DISABLE         (1 << 7)
6188
6189 /* FDI_RX, FDI_X is hard-wired to Transcoder_X */
6190 #define _FDI_RXA_CTL             0xf000c
6191 #define _FDI_RXB_CTL             0xf100c
6192 #define FDI_RX_CTL(pipe)        _MMIO_PIPE(pipe, _FDI_RXA_CTL, _FDI_RXB_CTL)
6193 #define  FDI_RX_ENABLE          (1 << 31)
6194 /* train, dp width same as FDI_TX */
6195 #define  FDI_FS_ERRC_ENABLE             (1 << 27)
6196 #define  FDI_FE_ERRC_ENABLE             (1 << 26)
6197 #define  FDI_RX_POLARITY_REVERSED_LPT   (1 << 16)
6198 #define  FDI_8BPC                       (0 << 16)
6199 #define  FDI_10BPC                      (1 << 16)
6200 #define  FDI_6BPC                       (2 << 16)
6201 #define  FDI_12BPC                      (3 << 16)
6202 #define  FDI_RX_LINK_REVERSAL_OVERRIDE  (1 << 15)
6203 #define  FDI_DMI_LINK_REVERSE_MASK      (1 << 14)
6204 #define  FDI_RX_PLL_ENABLE              (1 << 13)
6205 #define  FDI_FS_ERR_CORRECT_ENABLE      (1 << 11)
6206 #define  FDI_FE_ERR_CORRECT_ENABLE      (1 << 10)
6207 #define  FDI_FS_ERR_REPORT_ENABLE       (1 << 9)
6208 #define  FDI_FE_ERR_REPORT_ENABLE       (1 << 8)
6209 #define  FDI_RX_ENHANCE_FRAME_ENABLE    (1 << 6)
6210 #define  FDI_PCDCLK                     (1 << 4)
6211 /* CPT */
6212 #define  FDI_AUTO_TRAINING                      (1 << 10)
6213 #define  FDI_LINK_TRAIN_PATTERN_1_CPT           (0 << 8)
6214 #define  FDI_LINK_TRAIN_PATTERN_2_CPT           (1 << 8)
6215 #define  FDI_LINK_TRAIN_PATTERN_IDLE_CPT        (2 << 8)
6216 #define  FDI_LINK_TRAIN_NORMAL_CPT              (3 << 8)
6217 #define  FDI_LINK_TRAIN_PATTERN_MASK_CPT        (3 << 8)
6218
6219 #define _FDI_RXA_MISC                   0xf0010
6220 #define _FDI_RXB_MISC                   0xf1010
6221 #define  FDI_RX_PWRDN_LANE1_MASK        (3 << 26)
6222 #define  FDI_RX_PWRDN_LANE1_VAL(x)      ((x) << 26)
6223 #define  FDI_RX_PWRDN_LANE0_MASK        (3 << 24)
6224 #define  FDI_RX_PWRDN_LANE0_VAL(x)      ((x) << 24)
6225 #define  FDI_RX_TP1_TO_TP2_48           (2 << 20)
6226 #define  FDI_RX_TP1_TO_TP2_64           (3 << 20)
6227 #define  FDI_RX_FDI_DELAY_90            (0x90 << 0)
6228 #define FDI_RX_MISC(pipe)       _MMIO_PIPE(pipe, _FDI_RXA_MISC, _FDI_RXB_MISC)
6229
6230 #define _FDI_RXA_TUSIZE1        0xf0030
6231 #define _FDI_RXA_TUSIZE2        0xf0038
6232 #define _FDI_RXB_TUSIZE1        0xf1030
6233 #define _FDI_RXB_TUSIZE2        0xf1038
6234 #define FDI_RX_TUSIZE1(pipe)    _MMIO_PIPE(pipe, _FDI_RXA_TUSIZE1, _FDI_RXB_TUSIZE1)
6235 #define FDI_RX_TUSIZE2(pipe)    _MMIO_PIPE(pipe, _FDI_RXA_TUSIZE2, _FDI_RXB_TUSIZE2)
6236
6237 /* FDI_RX interrupt register format */
6238 #define FDI_RX_INTER_LANE_ALIGN         (1 << 10)
6239 #define FDI_RX_SYMBOL_LOCK              (1 << 9) /* train 2 */
6240 #define FDI_RX_BIT_LOCK                 (1 << 8) /* train 1 */
6241 #define FDI_RX_TRAIN_PATTERN_2_FAIL     (1 << 7)
6242 #define FDI_RX_FS_CODE_ERR              (1 << 6)
6243 #define FDI_RX_FE_CODE_ERR              (1 << 5)
6244 #define FDI_RX_SYMBOL_ERR_RATE_ABOVE    (1 << 4)
6245 #define FDI_RX_HDCP_LINK_FAIL           (1 << 3)
6246 #define FDI_RX_PIXEL_FIFO_OVERFLOW      (1 << 2)
6247 #define FDI_RX_CROSS_CLOCK_OVERFLOW     (1 << 1)
6248 #define FDI_RX_SYMBOL_QUEUE_OVERFLOW    (1 << 0)
6249
6250 #define _FDI_RXA_IIR            0xf0014
6251 #define _FDI_RXA_IMR            0xf0018
6252 #define _FDI_RXB_IIR            0xf1014
6253 #define _FDI_RXB_IMR            0xf1018
6254 #define FDI_RX_IIR(pipe)        _MMIO_PIPE(pipe, _FDI_RXA_IIR, _FDI_RXB_IIR)
6255 #define FDI_RX_IMR(pipe)        _MMIO_PIPE(pipe, _FDI_RXA_IMR, _FDI_RXB_IMR)
6256
6257 #define FDI_PLL_CTL_1           _MMIO(0xfe000)
6258 #define FDI_PLL_CTL_2           _MMIO(0xfe004)
6259
6260 #define _PCH_DP_B               0xe4100
6261 #define PCH_DP_B                _MMIO(_PCH_DP_B)
6262 #define _PCH_DPB_AUX_CH_CTL     0xe4110
6263 #define _PCH_DPB_AUX_CH_DATA1   0xe4114
6264 #define _PCH_DPB_AUX_CH_DATA2   0xe4118
6265 #define _PCH_DPB_AUX_CH_DATA3   0xe411c
6266 #define _PCH_DPB_AUX_CH_DATA4   0xe4120
6267 #define _PCH_DPB_AUX_CH_DATA5   0xe4124
6268
6269 #define _PCH_DP_C               0xe4200
6270 #define PCH_DP_C                _MMIO(_PCH_DP_C)
6271 #define _PCH_DPC_AUX_CH_CTL     0xe4210
6272 #define _PCH_DPC_AUX_CH_DATA1   0xe4214
6273 #define _PCH_DPC_AUX_CH_DATA2   0xe4218
6274 #define _PCH_DPC_AUX_CH_DATA3   0xe421c
6275 #define _PCH_DPC_AUX_CH_DATA4   0xe4220
6276 #define _PCH_DPC_AUX_CH_DATA5   0xe4224
6277
6278 #define _PCH_DP_D               0xe4300
6279 #define PCH_DP_D                _MMIO(_PCH_DP_D)
6280 #define _PCH_DPD_AUX_CH_CTL     0xe4310
6281 #define _PCH_DPD_AUX_CH_DATA1   0xe4314
6282 #define _PCH_DPD_AUX_CH_DATA2   0xe4318
6283 #define _PCH_DPD_AUX_CH_DATA3   0xe431c
6284 #define _PCH_DPD_AUX_CH_DATA4   0xe4320
6285 #define _PCH_DPD_AUX_CH_DATA5   0xe4324
6286
6287 #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)
6288 #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 */
6289
6290 /* CPT */
6291 #define _TRANS_DP_CTL_A         0xe0300
6292 #define _TRANS_DP_CTL_B         0xe1300
6293 #define _TRANS_DP_CTL_C         0xe2300
6294 #define TRANS_DP_CTL(pipe)      _MMIO_PIPE(pipe, _TRANS_DP_CTL_A, _TRANS_DP_CTL_B)
6295 #define  TRANS_DP_OUTPUT_ENABLE         REG_BIT(31)
6296 #define  TRANS_DP_PORT_SEL_MASK         REG_GENMASK(30, 29)
6297 #define  TRANS_DP_PORT_SEL_NONE         REG_FIELD_PREP(TRANS_DP_PORT_SEL_MASK, 3)
6298 #define  TRANS_DP_PORT_SEL(port)        REG_FIELD_PREP(TRANS_DP_PORT_SEL_MASK, (port) - PORT_B)
6299 #define  TRANS_DP_AUDIO_ONLY            REG_BIT(26)
6300 #define  TRANS_DP_ENH_FRAMING           REG_BIT(18)
6301 #define  TRANS_DP_BPC_MASK              REG_GENMASK(10, 9)
6302 #define  TRANS_DP_BPC_8                 REG_FIELD_PREP(TRANS_DP_BPC_MASK, 0)
6303 #define  TRANS_DP_BPC_10                REG_FIELD_PREP(TRANS_DP_BPC_MASK, 1)
6304 #define  TRANS_DP_BPC_6                 REG_FIELD_PREP(TRANS_DP_BPC_MASK, 2)
6305 #define  TRANS_DP_BPC_12                REG_FIELD_PREP(TRANS_DP_BPC_MASK, 3)
6306 #define  TRANS_DP_VSYNC_ACTIVE_HIGH     REG_BIT(4)
6307 #define  TRANS_DP_HSYNC_ACTIVE_HIGH     REG_BIT(3)
6308
6309 #define _TRANS_DP2_CTL_A                        0x600a0
6310 #define _TRANS_DP2_CTL_B                        0x610a0
6311 #define _TRANS_DP2_CTL_C                        0x620a0
6312 #define _TRANS_DP2_CTL_D                        0x630a0
6313 #define TRANS_DP2_CTL(trans)                    _MMIO_TRANS(trans, _TRANS_DP2_CTL_A, _TRANS_DP2_CTL_B)
6314 #define  TRANS_DP2_128B132B_CHANNEL_CODING      REG_BIT(31)
6315 #define  TRANS_DP2_PANEL_REPLAY_ENABLE          REG_BIT(30)
6316 #define  TRANS_DP2_DEBUG_ENABLE                 REG_BIT(23)
6317
6318 #define _TRANS_DP2_VFREQHIGH_A                  0x600a4
6319 #define _TRANS_DP2_VFREQHIGH_B                  0x610a4
6320 #define _TRANS_DP2_VFREQHIGH_C                  0x620a4
6321 #define _TRANS_DP2_VFREQHIGH_D                  0x630a4
6322 #define TRANS_DP2_VFREQHIGH(trans)              _MMIO_TRANS(trans, _TRANS_DP2_VFREQHIGH_A, _TRANS_DP2_VFREQHIGH_B)
6323 #define  TRANS_DP2_VFREQ_PIXEL_CLOCK_MASK       REG_GENMASK(31, 8)
6324 #define  TRANS_DP2_VFREQ_PIXEL_CLOCK(clk_hz)    REG_FIELD_PREP(TRANS_DP2_VFREQ_PIXEL_CLOCK_MASK, (clk_hz))
6325
6326 #define _TRANS_DP2_VFREQLOW_A                   0x600a8
6327 #define _TRANS_DP2_VFREQLOW_B                   0x610a8
6328 #define _TRANS_DP2_VFREQLOW_C                   0x620a8
6329 #define _TRANS_DP2_VFREQLOW_D                   0x630a8
6330 #define TRANS_DP2_VFREQLOW(trans)               _MMIO_TRANS(trans, _TRANS_DP2_VFREQLOW_A, _TRANS_DP2_VFREQLOW_B)
6331
6332 /* SNB eDP training params */
6333 /* SNB A-stepping */
6334 #define  EDP_LINK_TRAIN_400MV_0DB_SNB_A         (0x38 << 22)
6335 #define  EDP_LINK_TRAIN_400MV_6DB_SNB_A         (0x02 << 22)
6336 #define  EDP_LINK_TRAIN_600MV_3_5DB_SNB_A       (0x01 << 22)
6337 #define  EDP_LINK_TRAIN_800MV_0DB_SNB_A         (0x0 << 22)
6338 /* SNB B-stepping */
6339 #define  EDP_LINK_TRAIN_400_600MV_0DB_SNB_B     (0x0 << 22)
6340 #define  EDP_LINK_TRAIN_400MV_3_5DB_SNB_B       (0x1 << 22)
6341 #define  EDP_LINK_TRAIN_400_600MV_6DB_SNB_B     (0x3a << 22)
6342 #define  EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B   (0x39 << 22)
6343 #define  EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B    (0x38 << 22)
6344 #define  EDP_LINK_TRAIN_VOL_EMP_MASK_SNB        (0x3f << 22)
6345
6346 /* IVB */
6347 #define EDP_LINK_TRAIN_400MV_0DB_IVB            (0x24 << 22)
6348 #define EDP_LINK_TRAIN_400MV_3_5DB_IVB          (0x2a << 22)
6349 #define EDP_LINK_TRAIN_400MV_6DB_IVB            (0x2f << 22)
6350 #define EDP_LINK_TRAIN_600MV_0DB_IVB            (0x30 << 22)
6351 #define EDP_LINK_TRAIN_600MV_3_5DB_IVB          (0x36 << 22)
6352 #define EDP_LINK_TRAIN_800MV_0DB_IVB            (0x38 << 22)
6353 #define EDP_LINK_TRAIN_800MV_3_5DB_IVB          (0x3e << 22)
6354
6355 /* legacy values */
6356 #define EDP_LINK_TRAIN_500MV_0DB_IVB            (0x00 << 22)
6357 #define EDP_LINK_TRAIN_1000MV_0DB_IVB           (0x20 << 22)
6358 #define EDP_LINK_TRAIN_500MV_3_5DB_IVB          (0x02 << 22)
6359 #define EDP_LINK_TRAIN_1000MV_3_5DB_IVB         (0x22 << 22)
6360 #define EDP_LINK_TRAIN_1000MV_6DB_IVB           (0x23 << 22)
6361
6362 #define  EDP_LINK_TRAIN_VOL_EMP_MASK_IVB        (0x3f << 22)
6363
6364 #define  VLV_PMWGICZ                            _MMIO(0x1300a4)
6365
6366 #define  HSW_EDRAM_CAP                          _MMIO(0x120010)
6367 #define    EDRAM_ENABLED                        0x1
6368 #define    EDRAM_NUM_BANKS(cap)                 (((cap) >> 1) & 0xf)
6369 #define    EDRAM_WAYS_IDX(cap)                  (((cap) >> 5) & 0x7)
6370 #define    EDRAM_SETS_IDX(cap)                  (((cap) >> 8) & 0x3)
6371
6372 #define VLV_CHICKEN_3                           _MMIO(VLV_DISPLAY_BASE + 0x7040C)
6373 #define  PIXEL_OVERLAP_CNT_MASK                 (3 << 30)
6374 #define  PIXEL_OVERLAP_CNT_SHIFT                30
6375
6376 #define GEN6_PCODE_MAILBOX                      _MMIO(0x138124)
6377 #define   GEN6_PCODE_READY                      (1 << 31)
6378 #define   GEN6_PCODE_MB_PARAM2                  REG_GENMASK(23, 16)
6379 #define   GEN6_PCODE_MB_PARAM1                  REG_GENMASK(15, 8)
6380 #define   GEN6_PCODE_MB_COMMAND                 REG_GENMASK(7, 0)
6381 #define   GEN6_PCODE_ERROR_MASK                 0xFF
6382 #define     GEN6_PCODE_SUCCESS                  0x0
6383 #define     GEN6_PCODE_ILLEGAL_CMD              0x1
6384 #define     GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x2
6385 #define     GEN6_PCODE_TIMEOUT                  0x3
6386 #define     GEN6_PCODE_UNIMPLEMENTED_CMD        0xFF
6387 #define     GEN7_PCODE_TIMEOUT                  0x2
6388 #define     GEN7_PCODE_ILLEGAL_DATA             0x3
6389 #define     GEN11_PCODE_ILLEGAL_SUBCOMMAND      0x4
6390 #define     GEN11_PCODE_LOCKED                  0x6
6391 #define     GEN11_PCODE_REJECTED                0x11
6392 #define     GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x10
6393 #define   GEN6_PCODE_WRITE_RC6VIDS              0x4
6394 #define   GEN6_PCODE_READ_RC6VIDS               0x5
6395 #define     GEN6_ENCODE_RC6_VID(mv)             (((mv) - 245) / 5)
6396 #define     GEN6_DECODE_RC6_VID(vids)           (((vids) * 5) + 245)
6397 #define   BDW_PCODE_DISPLAY_FREQ_CHANGE_REQ     0x18
6398 #define   GEN9_PCODE_READ_MEM_LATENCY           0x6
6399 #define     GEN9_MEM_LATENCY_LEVEL_3_7_MASK     REG_GENMASK(31, 24)
6400 #define     GEN9_MEM_LATENCY_LEVEL_2_6_MASK     REG_GENMASK(23, 16)
6401 #define     GEN9_MEM_LATENCY_LEVEL_1_5_MASK     REG_GENMASK(15, 8)
6402 #define     GEN9_MEM_LATENCY_LEVEL_0_4_MASK     REG_GENMASK(7, 0)
6403 #define   SKL_PCODE_LOAD_HDCP_KEYS              0x5
6404 #define   SKL_PCODE_CDCLK_CONTROL               0x7
6405 #define     SKL_CDCLK_PREPARE_FOR_CHANGE        0x3
6406 #define     SKL_CDCLK_READY_FOR_CHANGE          0x1
6407 #define   GEN6_PCODE_WRITE_MIN_FREQ_TABLE       0x8
6408 #define   GEN6_PCODE_READ_MIN_FREQ_TABLE        0x9
6409 #define   GEN6_READ_OC_PARAMS                   0xc
6410 #define   ICL_PCODE_MEM_SUBSYSYSTEM_INFO        0xd
6411 #define     ICL_PCODE_MEM_SS_READ_GLOBAL_INFO   (0x0 << 8)
6412 #define     ICL_PCODE_MEM_SS_READ_QGV_POINT_INFO(point) (((point) << 16) | (0x1 << 8))
6413 #define     ADL_PCODE_MEM_SS_READ_PSF_GV_INFO   ((0) | (0x2 << 8))
6414 #define   ICL_PCODE_SAGV_DE_MEM_SS_CONFIG       0xe
6415 #define     ICL_PCODE_REP_QGV_MASK              REG_GENMASK(1, 0)
6416 #define     ICL_PCODE_REP_QGV_SAFE              REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 0)
6417 #define     ICL_PCODE_REP_QGV_POLL              REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 1)
6418 #define     ICL_PCODE_REP_QGV_REJECTED          REG_FIELD_PREP(ICL_PCODE_REP_QGV_MASK, 2)
6419 #define     ADLS_PCODE_REP_PSF_MASK             REG_GENMASK(3, 2)
6420 #define     ADLS_PCODE_REP_PSF_SAFE             REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 0)
6421 #define     ADLS_PCODE_REP_PSF_POLL             REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 1)
6422 #define     ADLS_PCODE_REP_PSF_REJECTED         REG_FIELD_PREP(ADLS_PCODE_REP_PSF_MASK, 2)
6423 #define     ICL_PCODE_REQ_QGV_PT_MASK           REG_GENMASK(7, 0)
6424 #define     ICL_PCODE_REQ_QGV_PT(x)             REG_FIELD_PREP(ICL_PCODE_REQ_QGV_PT_MASK, (x))
6425 #define     ADLS_PCODE_REQ_PSF_PT_MASK          REG_GENMASK(10, 8)
6426 #define     ADLS_PCODE_REQ_PSF_PT(x)            REG_FIELD_PREP(ADLS_PCODE_REQ_PSF_PT_MASK, (x))
6427 #define   GEN6_PCODE_READ_D_COMP                0x10
6428 #define   GEN6_PCODE_WRITE_D_COMP               0x11
6429 #define   ICL_PCODE_EXIT_TCCOLD                 0x12
6430 #define   HSW_PCODE_DE_WRITE_FREQ_REQ           0x17
6431 #define   DISPLAY_IPS_CONTROL                   0x19
6432 #define   TGL_PCODE_TCCOLD                      0x26
6433 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_EXIT_FAILED    REG_BIT(0)
6434 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_BLOCK_REQ      0
6435 #define     TGL_PCODE_EXIT_TCCOLD_DATA_L_UNBLOCK_REQ    REG_BIT(0)
6436             /* See also IPS_CTL */
6437 #define     IPS_PCODE_CONTROL                   (1 << 30)
6438 #define   HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL  0x1A
6439 #define   GEN9_PCODE_SAGV_CONTROL               0x21
6440 #define     GEN9_SAGV_DISABLE                   0x0
6441 #define     GEN9_SAGV_IS_DISABLED               0x1
6442 #define     GEN9_SAGV_ENABLE                    0x3
6443 #define   DG1_PCODE_STATUS                      0x7E
6444 #define     DG1_UNCORE_GET_INIT_STATUS          0x0
6445 #define     DG1_UNCORE_INIT_STATUS_COMPLETE     0x1
6446 #define   PCODE_POWER_SETUP                     0x7C
6447 #define     POWER_SETUP_SUBCOMMAND_READ_I1      0x4
6448 #define     POWER_SETUP_SUBCOMMAND_WRITE_I1     0x5
6449 #define     POWER_SETUP_I1_WATTS                REG_BIT(31)
6450 #define     POWER_SETUP_I1_SHIFT                6       /* 10.6 fixed point format */
6451 #define     POWER_SETUP_I1_DATA_MASK            REG_GENMASK(15, 0)
6452 #define GEN12_PCODE_READ_SAGV_BLOCK_TIME_US     0x23
6453 #define   XEHP_PCODE_FREQUENCY_CONFIG           0x6e    /* xehpsdv, pvc */
6454 /* XEHP_PCODE_FREQUENCY_CONFIG sub-commands (param1) */
6455 #define     PCODE_MBOX_FC_SC_READ_FUSED_P0      0x0
6456 #define     PCODE_MBOX_FC_SC_READ_FUSED_PN      0x1
6457 /* PCODE_MBOX_DOMAIN_* - mailbox domain IDs */
6458 /*   XEHP_PCODE_FREQUENCY_CONFIG param2 */
6459 #define     PCODE_MBOX_DOMAIN_NONE              0x0
6460 #define     PCODE_MBOX_DOMAIN_MEDIAFF           0x3
6461
6462 /* Wa_14017210380: mtl */
6463 #define   PCODE_MBOX_GT_STATE                   0x50
6464 /* sub-commands (param1) */
6465 #define     PCODE_MBOX_GT_STATE_MEDIA_BUSY      0x1
6466 #define     PCODE_MBOX_GT_STATE_MEDIA_NOT_BUSY  0x2
6467 /* param2 */
6468 #define     PCODE_MBOX_GT_STATE_DOMAIN_MEDIA    0x1
6469
6470 #define GEN6_PCODE_DATA                         _MMIO(0x138128)
6471 #define   GEN6_PCODE_FREQ_IA_RATIO_SHIFT        8
6472 #define   GEN6_PCODE_FREQ_RING_RATIO_SHIFT      16
6473 #define GEN6_PCODE_DATA1                        _MMIO(0x13812C)
6474
6475 /* IVYBRIDGE DPF */
6476 #define GEN7_L3CDERRST1(slice)          _MMIO(0xB008 + (slice) * 0x200) /* L3CD Error Status 1 */
6477 #define   GEN7_L3CDERRST1_ROW_MASK      (0x7ff << 14)
6478 #define   GEN7_PARITY_ERROR_VALID       (1 << 13)
6479 #define   GEN7_L3CDERRST1_BANK_MASK     (3 << 11)
6480 #define   GEN7_L3CDERRST1_SUBBANK_MASK  (7 << 8)
6481 #define GEN7_PARITY_ERROR_ROW(reg) \
6482                 (((reg) & GEN7_L3CDERRST1_ROW_MASK) >> 14)
6483 #define GEN7_PARITY_ERROR_BANK(reg) \
6484                 (((reg) & GEN7_L3CDERRST1_BANK_MASK) >> 11)
6485 #define GEN7_PARITY_ERROR_SUBBANK(reg) \
6486                 (((reg) & GEN7_L3CDERRST1_SUBBANK_MASK) >> 8)
6487 #define   GEN7_L3CDERRST1_ENABLE        (1 << 7)
6488
6489 /* These are the 4 32-bit write offset registers for each stream
6490  * output buffer.  It determines the offset from the
6491  * 3DSTATE_SO_BUFFERs that the next streamed vertex output goes to.
6492  */
6493 #define GEN7_SO_WRITE_OFFSET(n)         _MMIO(0x5280 + (n) * 4)
6494
6495 /*
6496  * HSW - ICL power wells
6497  *
6498  * Platforms have up to 3 power well control register sets, each set
6499  * controlling up to 16 power wells via a request/status HW flag tuple:
6500  * - main (HSW_PWR_WELL_CTL[1-4])
6501  * - AUX  (ICL_PWR_WELL_CTL_AUX[1-4])
6502  * - DDI  (ICL_PWR_WELL_CTL_DDI[1-4])
6503  * Each control register set consists of up to 4 registers used by different
6504  * sources that can request a power well to be enabled:
6505  * - BIOS   (HSW_PWR_WELL_CTL1/ICL_PWR_WELL_CTL_AUX1/ICL_PWR_WELL_CTL_DDI1)
6506  * - DRIVER (HSW_PWR_WELL_CTL2/ICL_PWR_WELL_CTL_AUX2/ICL_PWR_WELL_CTL_DDI2)
6507  * - KVMR   (HSW_PWR_WELL_CTL3)   (only in the main register set)
6508  * - DEBUG  (HSW_PWR_WELL_CTL4/ICL_PWR_WELL_CTL_AUX4/ICL_PWR_WELL_CTL_DDI4)
6509  */
6510 #define HSW_PWR_WELL_CTL1                       _MMIO(0x45400)
6511 #define HSW_PWR_WELL_CTL2                       _MMIO(0x45404)
6512 #define HSW_PWR_WELL_CTL3                       _MMIO(0x45408)
6513 #define HSW_PWR_WELL_CTL4                       _MMIO(0x4540C)
6514 #define   HSW_PWR_WELL_CTL_REQ(pw_idx)          (0x2 << ((pw_idx) * 2))
6515 #define   HSW_PWR_WELL_CTL_STATE(pw_idx)        (0x1 << ((pw_idx) * 2))
6516
6517 /* HSW/BDW power well */
6518 #define   HSW_PW_CTL_IDX_GLOBAL                 15
6519
6520 /* SKL/BXT/GLK power wells */
6521 #define   SKL_PW_CTL_IDX_PW_2                   15
6522 #define   SKL_PW_CTL_IDX_PW_1                   14
6523 #define   GLK_PW_CTL_IDX_AUX_C                  10
6524 #define   GLK_PW_CTL_IDX_AUX_B                  9
6525 #define   GLK_PW_CTL_IDX_AUX_A                  8
6526 #define   SKL_PW_CTL_IDX_DDI_D                  4
6527 #define   SKL_PW_CTL_IDX_DDI_C                  3
6528 #define   SKL_PW_CTL_IDX_DDI_B                  2
6529 #define   SKL_PW_CTL_IDX_DDI_A_E                1
6530 #define   GLK_PW_CTL_IDX_DDI_A                  1
6531 #define   SKL_PW_CTL_IDX_MISC_IO                0
6532
6533 /* ICL/TGL - power wells */
6534 #define   TGL_PW_CTL_IDX_PW_5                   4
6535 #define   ICL_PW_CTL_IDX_PW_4                   3
6536 #define   ICL_PW_CTL_IDX_PW_3                   2
6537 #define   ICL_PW_CTL_IDX_PW_2                   1
6538 #define   ICL_PW_CTL_IDX_PW_1                   0
6539
6540 /* XE_LPD - power wells */
6541 #define   XELPD_PW_CTL_IDX_PW_D                 8
6542 #define   XELPD_PW_CTL_IDX_PW_C                 7
6543 #define   XELPD_PW_CTL_IDX_PW_B                 6
6544 #define   XELPD_PW_CTL_IDX_PW_A                 5
6545
6546 #define ICL_PWR_WELL_CTL_AUX1                   _MMIO(0x45440)
6547 #define ICL_PWR_WELL_CTL_AUX2                   _MMIO(0x45444)
6548 #define ICL_PWR_WELL_CTL_AUX4                   _MMIO(0x4544C)
6549 #define   TGL_PW_CTL_IDX_AUX_TBT6               14
6550 #define   TGL_PW_CTL_IDX_AUX_TBT5               13
6551 #define   TGL_PW_CTL_IDX_AUX_TBT4               12
6552 #define   ICL_PW_CTL_IDX_AUX_TBT4               11
6553 #define   TGL_PW_CTL_IDX_AUX_TBT3               11
6554 #define   ICL_PW_CTL_IDX_AUX_TBT3               10
6555 #define   TGL_PW_CTL_IDX_AUX_TBT2               10
6556 #define   ICL_PW_CTL_IDX_AUX_TBT2               9
6557 #define   TGL_PW_CTL_IDX_AUX_TBT1               9
6558 #define   ICL_PW_CTL_IDX_AUX_TBT1               8
6559 #define   TGL_PW_CTL_IDX_AUX_TC6                8
6560 #define   XELPD_PW_CTL_IDX_AUX_E                        8
6561 #define   TGL_PW_CTL_IDX_AUX_TC5                7
6562 #define   XELPD_PW_CTL_IDX_AUX_D                        7
6563 #define   TGL_PW_CTL_IDX_AUX_TC4                6
6564 #define   ICL_PW_CTL_IDX_AUX_F                  5
6565 #define   TGL_PW_CTL_IDX_AUX_TC3                5
6566 #define   ICL_PW_CTL_IDX_AUX_E                  4
6567 #define   TGL_PW_CTL_IDX_AUX_TC2                4
6568 #define   ICL_PW_CTL_IDX_AUX_D                  3
6569 #define   TGL_PW_CTL_IDX_AUX_TC1                3
6570 #define   ICL_PW_CTL_IDX_AUX_C                  2
6571 #define   ICL_PW_CTL_IDX_AUX_B                  1
6572 #define   ICL_PW_CTL_IDX_AUX_A                  0
6573
6574 #define ICL_PWR_WELL_CTL_DDI1                   _MMIO(0x45450)
6575 #define ICL_PWR_WELL_CTL_DDI2                   _MMIO(0x45454)
6576 #define ICL_PWR_WELL_CTL_DDI4                   _MMIO(0x4545C)
6577 #define   XELPD_PW_CTL_IDX_DDI_E                        8
6578 #define   TGL_PW_CTL_IDX_DDI_TC6                8
6579 #define   XELPD_PW_CTL_IDX_DDI_D                        7
6580 #define   TGL_PW_CTL_IDX_DDI_TC5                7
6581 #define   TGL_PW_CTL_IDX_DDI_TC4                6
6582 #define   ICL_PW_CTL_IDX_DDI_F                  5
6583 #define   TGL_PW_CTL_IDX_DDI_TC3                5
6584 #define   ICL_PW_CTL_IDX_DDI_E                  4
6585 #define   TGL_PW_CTL_IDX_DDI_TC2                4
6586 #define   ICL_PW_CTL_IDX_DDI_D                  3
6587 #define   TGL_PW_CTL_IDX_DDI_TC1                3
6588 #define   ICL_PW_CTL_IDX_DDI_C                  2
6589 #define   ICL_PW_CTL_IDX_DDI_B                  1
6590 #define   ICL_PW_CTL_IDX_DDI_A                  0
6591
6592 /* HSW - power well misc debug registers */
6593 #define HSW_PWR_WELL_CTL5                       _MMIO(0x45410)
6594 #define   HSW_PWR_WELL_ENABLE_SINGLE_STEP       (1 << 31)
6595 #define   HSW_PWR_WELL_PWR_GATE_OVERRIDE        (1 << 20)
6596 #define   HSW_PWR_WELL_FORCE_ON                 (1 << 19)
6597 #define HSW_PWR_WELL_CTL6                       _MMIO(0x45414)
6598
6599 /* SKL Fuse Status */
6600 enum skl_power_gate {
6601         SKL_PG0,
6602         SKL_PG1,
6603         SKL_PG2,
6604         ICL_PG3,
6605         ICL_PG4,
6606 };
6607
6608 #define SKL_FUSE_STATUS                         _MMIO(0x42000)
6609 #define  SKL_FUSE_DOWNLOAD_STATUS               (1 << 31)
6610 /*
6611  * PG0 is HW controlled, so doesn't have a corresponding power well control knob
6612  * SKL_DISP_PW1_IDX..SKL_DISP_PW2_IDX -> PG1..PG2
6613  */
6614 #define  SKL_PW_CTL_IDX_TO_PG(pw_idx)           \
6615         ((pw_idx) - SKL_PW_CTL_IDX_PW_1 + SKL_PG1)
6616 /*
6617  * PG0 is HW controlled, so doesn't have a corresponding power well control knob
6618  * ICL_DISP_PW1_IDX..ICL_DISP_PW4_IDX -> PG1..PG4
6619  */
6620 #define  ICL_PW_CTL_IDX_TO_PG(pw_idx)           \
6621         ((pw_idx) - ICL_PW_CTL_IDX_PW_1 + SKL_PG1)
6622 #define  SKL_FUSE_PG_DIST_STATUS(pg)            (1 << (27 - (pg)))
6623
6624 #define _ICL_AUX_REG_IDX(pw_idx)        ((pw_idx) - ICL_PW_CTL_IDX_AUX_A)
6625 #define _ICL_AUX_ANAOVRD1_A             0x162398
6626 #define _ICL_AUX_ANAOVRD1_B             0x6C398
6627 #define ICL_AUX_ANAOVRD1(pw_idx)        _MMIO(_PICK(_ICL_AUX_REG_IDX(pw_idx), \
6628                                                     _ICL_AUX_ANAOVRD1_A, \
6629                                                     _ICL_AUX_ANAOVRD1_B))
6630 #define   ICL_AUX_ANAOVRD1_LDO_BYPASS   (1 << 7)
6631 #define   ICL_AUX_ANAOVRD1_ENABLE       (1 << 0)
6632
6633 /* Per-pipe DDI Function Control */
6634 #define _TRANS_DDI_FUNC_CTL_A           0x60400
6635 #define _TRANS_DDI_FUNC_CTL_B           0x61400
6636 #define _TRANS_DDI_FUNC_CTL_C           0x62400
6637 #define _TRANS_DDI_FUNC_CTL_D           0x63400
6638 #define _TRANS_DDI_FUNC_CTL_EDP         0x6F400
6639 #define _TRANS_DDI_FUNC_CTL_DSI0        0x6b400
6640 #define _TRANS_DDI_FUNC_CTL_DSI1        0x6bc00
6641 #define TRANS_DDI_FUNC_CTL(tran) _MMIO_TRANS2(tran, _TRANS_DDI_FUNC_CTL_A)
6642
6643 #define  TRANS_DDI_FUNC_ENABLE          (1 << 31)
6644 /* Those bits are ignored by pipe EDP since it can only connect to DDI A */
6645 #define  TRANS_DDI_PORT_SHIFT           28
6646 #define  TGL_TRANS_DDI_PORT_SHIFT       27
6647 #define  TRANS_DDI_PORT_MASK            (7 << TRANS_DDI_PORT_SHIFT)
6648 #define  TGL_TRANS_DDI_PORT_MASK        (0xf << TGL_TRANS_DDI_PORT_SHIFT)
6649 #define  TRANS_DDI_SELECT_PORT(x)       ((x) << TRANS_DDI_PORT_SHIFT)
6650 #define  TGL_TRANS_DDI_SELECT_PORT(x)   (((x) + 1) << TGL_TRANS_DDI_PORT_SHIFT)
6651 #define  TRANS_DDI_MODE_SELECT_MASK     (7 << 24)
6652 #define  TRANS_DDI_MODE_SELECT_HDMI     (0 << 24)
6653 #define  TRANS_DDI_MODE_SELECT_DVI      (1 << 24)
6654 #define  TRANS_DDI_MODE_SELECT_DP_SST   (2 << 24)
6655 #define  TRANS_DDI_MODE_SELECT_DP_MST   (3 << 24)
6656 #define  TRANS_DDI_MODE_SELECT_FDI_OR_128B132B  (4 << 24)
6657 #define  TRANS_DDI_BPC_MASK             (7 << 20)
6658 #define  TRANS_DDI_BPC_8                (0 << 20)
6659 #define  TRANS_DDI_BPC_10               (1 << 20)
6660 #define  TRANS_DDI_BPC_6                (2 << 20)
6661 #define  TRANS_DDI_BPC_12               (3 << 20)
6662 #define  TRANS_DDI_PORT_SYNC_MASTER_SELECT_MASK REG_GENMASK(19, 18)
6663 #define  TRANS_DDI_PORT_SYNC_MASTER_SELECT(x)   REG_FIELD_PREP(TRANS_DDI_PORT_SYNC_MASTER_SELECT_MASK, (x))
6664 #define  TRANS_DDI_PVSYNC               (1 << 17)
6665 #define  TRANS_DDI_PHSYNC               (1 << 16)
6666 #define  TRANS_DDI_PORT_SYNC_ENABLE     REG_BIT(15)
6667 #define  TRANS_DDI_EDP_INPUT_MASK       (7 << 12)
6668 #define  TRANS_DDI_EDP_INPUT_A_ON       (0 << 12)
6669 #define  TRANS_DDI_EDP_INPUT_A_ONOFF    (4 << 12)
6670 #define  TRANS_DDI_EDP_INPUT_B_ONOFF    (5 << 12)
6671 #define  TRANS_DDI_EDP_INPUT_C_ONOFF    (6 << 12)
6672 #define  TRANS_DDI_EDP_INPUT_D_ONOFF    (7 << 12)
6673 #define  TRANS_DDI_MST_TRANSPORT_SELECT_MASK    REG_GENMASK(11, 10)
6674 #define  TRANS_DDI_MST_TRANSPORT_SELECT(trans)  \
6675         REG_FIELD_PREP(TRANS_DDI_MST_TRANSPORT_SELECT_MASK, trans)
6676 #define  TRANS_DDI_HDCP_SIGNALLING      (1 << 9)
6677 #define  TRANS_DDI_DP_VC_PAYLOAD_ALLOC  (1 << 8)
6678 #define  TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE (1 << 7)
6679 #define  TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ (1 << 6)
6680 #define  TRANS_DDI_HDCP_SELECT          REG_BIT(5)
6681 #define  TRANS_DDI_BFI_ENABLE           (1 << 4)
6682 #define  TRANS_DDI_HIGH_TMDS_CHAR_RATE  (1 << 4)
6683 #define  TRANS_DDI_HDMI_SCRAMBLING      (1 << 0)
6684 #define  TRANS_DDI_HDMI_SCRAMBLING_MASK (TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE \
6685                                         | TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ \
6686                                         | TRANS_DDI_HDMI_SCRAMBLING)
6687
6688 #define _TRANS_DDI_FUNC_CTL2_A          0x60404
6689 #define _TRANS_DDI_FUNC_CTL2_B          0x61404
6690 #define _TRANS_DDI_FUNC_CTL2_C          0x62404
6691 #define _TRANS_DDI_FUNC_CTL2_EDP        0x6f404
6692 #define _TRANS_DDI_FUNC_CTL2_DSI0       0x6b404
6693 #define _TRANS_DDI_FUNC_CTL2_DSI1       0x6bc04
6694 #define TRANS_DDI_FUNC_CTL2(tran)       _MMIO_TRANS2(tran, _TRANS_DDI_FUNC_CTL2_A)
6695 #define  PORT_SYNC_MODE_ENABLE                  REG_BIT(4)
6696 #define  PORT_SYNC_MODE_MASTER_SELECT_MASK      REG_GENMASK(2, 0)
6697 #define  PORT_SYNC_MODE_MASTER_SELECT(x)        REG_FIELD_PREP(PORT_SYNC_MODE_MASTER_SELECT_MASK, (x))
6698
6699 #define TRANS_CMTG_CHICKEN              _MMIO(0x6fa90)
6700 #define  DISABLE_DPT_CLK_GATING         REG_BIT(1)
6701
6702 /* DisplayPort Transport Control */
6703 #define _DP_TP_CTL_A                    0x64040
6704 #define _DP_TP_CTL_B                    0x64140
6705 #define _TGL_DP_TP_CTL_A                0x60540
6706 #define DP_TP_CTL(port) _MMIO_PORT(port, _DP_TP_CTL_A, _DP_TP_CTL_B)
6707 #define TGL_DP_TP_CTL(tran) _MMIO_TRANS2((tran), _TGL_DP_TP_CTL_A)
6708 #define  DP_TP_CTL_ENABLE                       (1 << 31)
6709 #define  DP_TP_CTL_FEC_ENABLE                   (1 << 30)
6710 #define  DP_TP_CTL_MODE_SST                     (0 << 27)
6711 #define  DP_TP_CTL_MODE_MST                     (1 << 27)
6712 #define  DP_TP_CTL_FORCE_ACT                    (1 << 25)
6713 #define  DP_TP_CTL_ENHANCED_FRAME_ENABLE        (1 << 18)
6714 #define  DP_TP_CTL_FDI_AUTOTRAIN                (1 << 15)
6715 #define  DP_TP_CTL_LINK_TRAIN_MASK              (7 << 8)
6716 #define  DP_TP_CTL_LINK_TRAIN_PAT1              (0 << 8)
6717 #define  DP_TP_CTL_LINK_TRAIN_PAT2              (1 << 8)
6718 #define  DP_TP_CTL_LINK_TRAIN_PAT3              (4 << 8)
6719 #define  DP_TP_CTL_LINK_TRAIN_PAT4              (5 << 8)
6720 #define  DP_TP_CTL_LINK_TRAIN_IDLE              (2 << 8)
6721 #define  DP_TP_CTL_LINK_TRAIN_NORMAL            (3 << 8)
6722 #define  DP_TP_CTL_SCRAMBLE_DISABLE             (1 << 7)
6723
6724 /* DisplayPort Transport Status */
6725 #define _DP_TP_STATUS_A                 0x64044
6726 #define _DP_TP_STATUS_B                 0x64144
6727 #define _TGL_DP_TP_STATUS_A             0x60544
6728 #define DP_TP_STATUS(port) _MMIO_PORT(port, _DP_TP_STATUS_A, _DP_TP_STATUS_B)
6729 #define TGL_DP_TP_STATUS(tran) _MMIO_TRANS2((tran), _TGL_DP_TP_STATUS_A)
6730 #define  DP_TP_STATUS_FEC_ENABLE_LIVE           (1 << 28)
6731 #define  DP_TP_STATUS_IDLE_DONE                 (1 << 25)
6732 #define  DP_TP_STATUS_ACT_SENT                  (1 << 24)
6733 #define  DP_TP_STATUS_MODE_STATUS_MST           (1 << 23)
6734 #define  DP_TP_STATUS_AUTOTRAIN_DONE            (1 << 12)
6735 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC2       (3 << 8)
6736 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC1       (3 << 4)
6737 #define  DP_TP_STATUS_PAYLOAD_MAPPING_VC0       (3 << 0)
6738
6739 /* DDI Buffer Control */
6740 #define _DDI_BUF_CTL_A                          0x64000
6741 #define _DDI_BUF_CTL_B                          0x64100
6742 #define DDI_BUF_CTL(port) _MMIO_PORT(port, _DDI_BUF_CTL_A, _DDI_BUF_CTL_B)
6743 #define  DDI_BUF_CTL_ENABLE                     (1 << 31)
6744 #define  DDI_BUF_TRANS_SELECT(n)        ((n) << 24)
6745 #define  DDI_BUF_EMP_MASK                       (0xf << 24)
6746 #define  DDI_BUF_PHY_LINK_RATE(r)               ((r) << 20)
6747 #define  DDI_BUF_PORT_REVERSAL                  (1 << 16)
6748 #define  DDI_BUF_IS_IDLE                        (1 << 7)
6749 #define  DDI_BUF_CTL_TC_PHY_OWNERSHIP           REG_BIT(6)
6750 #define  DDI_A_4_LANES                          (1 << 4)
6751 #define  DDI_PORT_WIDTH(width)                  (((width) - 1) << 1)
6752 #define  DDI_PORT_WIDTH_MASK                    (7 << 1)
6753 #define  DDI_PORT_WIDTH_SHIFT                   1
6754 #define  DDI_INIT_DISPLAY_DETECTED              (1 << 0)
6755
6756 /* DDI Buffer Translations */
6757 #define _DDI_BUF_TRANS_A                0x64E00
6758 #define _DDI_BUF_TRANS_B                0x64E60
6759 #define DDI_BUF_TRANS_LO(port, i)       _MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8)
6760 #define  DDI_BUF_BALANCE_LEG_ENABLE     (1 << 31)
6761 #define DDI_BUF_TRANS_HI(port, i)       _MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8 + 4)
6762
6763 /* DDI DP Compliance Control */
6764 #define _DDI_DP_COMP_CTL_A                      0x605F0
6765 #define _DDI_DP_COMP_CTL_B                      0x615F0
6766 #define DDI_DP_COMP_CTL(pipe)                   _MMIO_PIPE(pipe, _DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)
6767 #define   DDI_DP_COMP_CTL_ENABLE                (1 << 31)
6768 #define   DDI_DP_COMP_CTL_D10_2                 (0 << 28)
6769 #define   DDI_DP_COMP_CTL_SCRAMBLED_0           (1 << 28)
6770 #define   DDI_DP_COMP_CTL_PRBS7                 (2 << 28)
6771 #define   DDI_DP_COMP_CTL_CUSTOM80              (3 << 28)
6772 #define   DDI_DP_COMP_CTL_HBR2                  (4 << 28)
6773 #define   DDI_DP_COMP_CTL_SCRAMBLED_1           (5 << 28)
6774 #define   DDI_DP_COMP_CTL_HBR2_RESET            (0xFC << 0)
6775
6776 /* DDI DP Compliance Pattern */
6777 #define _DDI_DP_COMP_PAT_A                      0x605F4
6778 #define _DDI_DP_COMP_PAT_B                      0x615F4
6779 #define DDI_DP_COMP_PAT(pipe, i)                _MMIO(_PIPE(pipe, _DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)
6780
6781 /* Sideband Interface (SBI) is programmed indirectly, via
6782  * SBI_ADDR, which contains the register offset; and SBI_DATA,
6783  * which contains the payload */
6784 #define SBI_ADDR                        _MMIO(0xC6000)
6785 #define SBI_DATA                        _MMIO(0xC6004)
6786 #define SBI_CTL_STAT                    _MMIO(0xC6008)
6787 #define  SBI_CTL_DEST_ICLK              (0x0 << 16)
6788 #define  SBI_CTL_DEST_MPHY              (0x1 << 16)
6789 #define  SBI_CTL_OP_IORD                (0x2 << 8)
6790 #define  SBI_CTL_OP_IOWR                (0x3 << 8)
6791 #define  SBI_CTL_OP_CRRD                (0x6 << 8)
6792 #define  SBI_CTL_OP_CRWR                (0x7 << 8)
6793 #define  SBI_RESPONSE_FAIL              (0x1 << 1)
6794 #define  SBI_RESPONSE_SUCCESS           (0x0 << 1)
6795 #define  SBI_BUSY                       (0x1 << 0)
6796 #define  SBI_READY                      (0x0 << 0)
6797
6798 /* SBI offsets */
6799 #define  SBI_SSCDIVINTPHASE                     0x0200
6800 #define  SBI_SSCDIVINTPHASE6                    0x0600
6801 #define   SBI_SSCDIVINTPHASE_DIVSEL_SHIFT       1
6802 #define   SBI_SSCDIVINTPHASE_DIVSEL_MASK        (0x7f << 1)
6803 #define   SBI_SSCDIVINTPHASE_DIVSEL(x)          ((x) << 1)
6804 #define   SBI_SSCDIVINTPHASE_INCVAL_SHIFT       8
6805 #define   SBI_SSCDIVINTPHASE_INCVAL_MASK        (0x7f << 8)
6806 #define   SBI_SSCDIVINTPHASE_INCVAL(x)          ((x) << 8)
6807 #define   SBI_SSCDIVINTPHASE_DIR(x)             ((x) << 15)
6808 #define   SBI_SSCDIVINTPHASE_PROPAGATE          (1 << 0)
6809 #define  SBI_SSCDITHPHASE                       0x0204
6810 #define  SBI_SSCCTL                             0x020c
6811 #define  SBI_SSCCTL6                            0x060C
6812 #define   SBI_SSCCTL_PATHALT                    (1 << 3)
6813 #define   SBI_SSCCTL_DISABLE                    (1 << 0)
6814 #define  SBI_SSCAUXDIV6                         0x0610
6815 #define   SBI_SSCAUXDIV_FINALDIV2SEL_SHIFT      4
6816 #define   SBI_SSCAUXDIV_FINALDIV2SEL_MASK       (1 << 4)
6817 #define   SBI_SSCAUXDIV_FINALDIV2SEL(x)         ((x) << 4)
6818 #define  SBI_DBUFF0                             0x2a00
6819 #define  SBI_GEN0                               0x1f00
6820 #define   SBI_GEN0_CFG_BUFFENABLE_DISABLE       (1 << 0)
6821
6822 /* LPT PIXCLK_GATE */
6823 #define PIXCLK_GATE                     _MMIO(0xC6020)
6824 #define  PIXCLK_GATE_UNGATE             (1 << 0)
6825 #define  PIXCLK_GATE_GATE               (0 << 0)
6826
6827 /* SPLL */
6828 #define SPLL_CTL                        _MMIO(0x46020)
6829 #define  SPLL_PLL_ENABLE                (1 << 31)
6830 #define  SPLL_REF_BCLK                  (0 << 28)
6831 #define  SPLL_REF_MUXED_SSC             (1 << 28) /* CPU SSC if fused enabled, PCH SSC otherwise */
6832 #define  SPLL_REF_NON_SSC_HSW           (2 << 28)
6833 #define  SPLL_REF_PCH_SSC_BDW           (2 << 28)
6834 #define  SPLL_REF_LCPLL                 (3 << 28)
6835 #define  SPLL_REF_MASK                  (3 << 28)
6836 #define  SPLL_FREQ_810MHz               (0 << 26)
6837 #define  SPLL_FREQ_1350MHz              (1 << 26)
6838 #define  SPLL_FREQ_2700MHz              (2 << 26)
6839 #define  SPLL_FREQ_MASK                 (3 << 26)
6840
6841 /* WRPLL */
6842 #define _WRPLL_CTL1                     0x46040
6843 #define _WRPLL_CTL2                     0x46060
6844 #define WRPLL_CTL(pll)                  _MMIO_PIPE(pll, _WRPLL_CTL1, _WRPLL_CTL2)
6845 #define  WRPLL_PLL_ENABLE               (1 << 31)
6846 #define  WRPLL_REF_BCLK                 (0 << 28)
6847 #define  WRPLL_REF_PCH_SSC              (1 << 28)
6848 #define  WRPLL_REF_MUXED_SSC_BDW        (2 << 28) /* CPU SSC if fused enabled, PCH SSC otherwise */
6849 #define  WRPLL_REF_SPECIAL_HSW          (2 << 28) /* muxed SSC (ULT), non-SSC (non-ULT) */
6850 #define  WRPLL_REF_LCPLL                (3 << 28)
6851 #define  WRPLL_REF_MASK                 (3 << 28)
6852 /* WRPLL divider programming */
6853 #define  WRPLL_DIVIDER_REFERENCE(x)     ((x) << 0)
6854 #define  WRPLL_DIVIDER_REF_MASK         (0xff)
6855 #define  WRPLL_DIVIDER_POST(x)          ((x) << 8)
6856 #define  WRPLL_DIVIDER_POST_MASK        (0x3f << 8)
6857 #define  WRPLL_DIVIDER_POST_SHIFT       8
6858 #define  WRPLL_DIVIDER_FEEDBACK(x)      ((x) << 16)
6859 #define  WRPLL_DIVIDER_FB_SHIFT         16
6860 #define  WRPLL_DIVIDER_FB_MASK          (0xff << 16)
6861
6862 /* Port clock selection */
6863 #define _PORT_CLK_SEL_A                 0x46100
6864 #define _PORT_CLK_SEL_B                 0x46104
6865 #define PORT_CLK_SEL(port) _MMIO_PORT(port, _PORT_CLK_SEL_A, _PORT_CLK_SEL_B)
6866 #define  PORT_CLK_SEL_MASK              REG_GENMASK(31, 29)
6867 #define  PORT_CLK_SEL_LCPLL_2700        REG_FIELD_PREP(PORT_CLK_SEL_MASK, 0)
6868 #define  PORT_CLK_SEL_LCPLL_1350        REG_FIELD_PREP(PORT_CLK_SEL_MASK, 1)
6869 #define  PORT_CLK_SEL_LCPLL_810         REG_FIELD_PREP(PORT_CLK_SEL_MASK, 2)
6870 #define  PORT_CLK_SEL_SPLL              REG_FIELD_PREP(PORT_CLK_SEL_MASK, 3)
6871 #define  PORT_CLK_SEL_WRPLL(pll)        REG_FIELD_PREP(PORT_CLK_SEL_MASK, 4 + (pll))
6872 #define  PORT_CLK_SEL_WRPLL1            REG_FIELD_PREP(PORT_CLK_SEL_MASK, 4)
6873 #define  PORT_CLK_SEL_WRPLL2            REG_FIELD_PREP(PORT_CLK_SEL_MASK, 5)
6874 #define  PORT_CLK_SEL_NONE              REG_FIELD_PREP(PORT_CLK_SEL_MASK, 7)
6875
6876 /* On ICL+ this is the same as PORT_CLK_SEL, but all bits change. */
6877 #define DDI_CLK_SEL(port)               PORT_CLK_SEL(port)
6878 #define  DDI_CLK_SEL_MASK               REG_GENMASK(31, 28)
6879 #define  DDI_CLK_SEL_NONE               REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0x0)
6880 #define  DDI_CLK_SEL_MG                 REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0x8)
6881 #define  DDI_CLK_SEL_TBT_162            REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xC)
6882 #define  DDI_CLK_SEL_TBT_270            REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xD)
6883 #define  DDI_CLK_SEL_TBT_540            REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xE)
6884 #define  DDI_CLK_SEL_TBT_810            REG_FIELD_PREP(DDI_CLK_SEL_MASK, 0xF)
6885
6886 /* Transcoder clock selection */
6887 #define _TRANS_CLK_SEL_A                0x46140
6888 #define _TRANS_CLK_SEL_B                0x46144
6889 #define TRANS_CLK_SEL(tran) _MMIO_TRANS(tran, _TRANS_CLK_SEL_A, _TRANS_CLK_SEL_B)
6890 /* For each transcoder, we need to select the corresponding port clock */
6891 #define  TRANS_CLK_SEL_DISABLED         (0x0 << 29)
6892 #define  TRANS_CLK_SEL_PORT(x)          (((x) + 1) << 29)
6893 #define  TGL_TRANS_CLK_SEL_DISABLED     (0x0 << 28)
6894 #define  TGL_TRANS_CLK_SEL_PORT(x)      (((x) + 1) << 28)
6895
6896
6897 #define CDCLK_FREQ                      _MMIO(0x46200)
6898
6899 #define _TRANSA_MSA_MISC                0x60410
6900 #define _TRANSB_MSA_MISC                0x61410
6901 #define _TRANSC_MSA_MISC                0x62410
6902 #define _TRANS_EDP_MSA_MISC             0x6f410
6903 #define TRANS_MSA_MISC(tran) _MMIO_TRANS2(tran, _TRANSA_MSA_MISC)
6904 /* See DP_MSA_MISC_* for the bit definitions */
6905
6906 #define _TRANS_A_SET_CONTEXT_LATENCY            0x6007C
6907 #define _TRANS_B_SET_CONTEXT_LATENCY            0x6107C
6908 #define _TRANS_C_SET_CONTEXT_LATENCY            0x6207C
6909 #define _TRANS_D_SET_CONTEXT_LATENCY            0x6307C
6910 #define TRANS_SET_CONTEXT_LATENCY(tran)         _MMIO_TRANS2(tran, _TRANS_A_SET_CONTEXT_LATENCY)
6911 #define  TRANS_SET_CONTEXT_LATENCY_MASK         REG_GENMASK(15, 0)
6912 #define  TRANS_SET_CONTEXT_LATENCY_VALUE(x)     REG_FIELD_PREP(TRANS_SET_CONTEXT_LATENCY_MASK, (x))
6913
6914 /* LCPLL Control */
6915 #define LCPLL_CTL                       _MMIO(0x130040)
6916 #define  LCPLL_PLL_DISABLE              (1 << 31)
6917 #define  LCPLL_PLL_LOCK                 (1 << 30)
6918 #define  LCPLL_REF_NON_SSC              (0 << 28)
6919 #define  LCPLL_REF_BCLK                 (2 << 28)
6920 #define  LCPLL_REF_PCH_SSC              (3 << 28)
6921 #define  LCPLL_REF_MASK                 (3 << 28)
6922 #define  LCPLL_CLK_FREQ_MASK            (3 << 26)
6923 #define  LCPLL_CLK_FREQ_450             (0 << 26)
6924 #define  LCPLL_CLK_FREQ_54O_BDW         (1 << 26)
6925 #define  LCPLL_CLK_FREQ_337_5_BDW       (2 << 26)
6926 #define  LCPLL_CLK_FREQ_675_BDW         (3 << 26)
6927 #define  LCPLL_CD_CLOCK_DISABLE         (1 << 25)
6928 #define  LCPLL_ROOT_CD_CLOCK_DISABLE    (1 << 24)
6929 #define  LCPLL_CD2X_CLOCK_DISABLE       (1 << 23)
6930 #define  LCPLL_POWER_DOWN_ALLOW         (1 << 22)
6931 #define  LCPLL_CD_SOURCE_FCLK           (1 << 21)
6932 #define  LCPLL_CD_SOURCE_FCLK_DONE      (1 << 19)
6933
6934 /*
6935  * SKL Clocks
6936  */
6937
6938 /* CDCLK_CTL */
6939 #define CDCLK_CTL                       _MMIO(0x46000)
6940 #define  CDCLK_FREQ_SEL_MASK            REG_GENMASK(27, 26)
6941 #define  CDCLK_FREQ_450_432             REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 0)
6942 #define  CDCLK_FREQ_540         REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 1)
6943 #define  CDCLK_FREQ_337_308             REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 2)
6944 #define  CDCLK_FREQ_675_617             REG_FIELD_PREP(CDCLK_FREQ_SEL_MASK, 3)
6945 #define  BXT_CDCLK_CD2X_DIV_SEL_MASK    REG_GENMASK(23, 22)
6946 #define  BXT_CDCLK_CD2X_DIV_SEL_1       REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 0)
6947 #define  BXT_CDCLK_CD2X_DIV_SEL_1_5     REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 1)
6948 #define  BXT_CDCLK_CD2X_DIV_SEL_2       REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 2)
6949 #define  BXT_CDCLK_CD2X_DIV_SEL_4       REG_FIELD_PREP(BXT_CDCLK_CD2X_DIV_SEL_MASK, 3)
6950 #define  BXT_CDCLK_CD2X_PIPE(pipe)      ((pipe) << 20)
6951 #define  CDCLK_DIVMUX_CD_OVERRIDE       (1 << 19)
6952 #define  BXT_CDCLK_CD2X_PIPE_NONE       BXT_CDCLK_CD2X_PIPE(3)
6953 #define  ICL_CDCLK_CD2X_PIPE(pipe)      (_PICK(pipe, 0, 2, 6) << 19)
6954 #define  ICL_CDCLK_CD2X_PIPE_NONE       (7 << 19)
6955 #define  TGL_CDCLK_CD2X_PIPE(pipe)      BXT_CDCLK_CD2X_PIPE(pipe)
6956 #define  TGL_CDCLK_CD2X_PIPE_NONE       ICL_CDCLK_CD2X_PIPE_NONE
6957 #define  BXT_CDCLK_SSA_PRECHARGE_ENABLE (1 << 16)
6958 #define  CDCLK_FREQ_DECIMAL_MASK        (0x7ff)
6959
6960 /* CDCLK_SQUASH_CTL */
6961 #define CDCLK_SQUASH_CTL                _MMIO(0x46008)
6962 #define  CDCLK_SQUASH_ENABLE            REG_BIT(31)
6963 #define  CDCLK_SQUASH_WINDOW_SIZE_MASK  REG_GENMASK(27, 24)
6964 #define  CDCLK_SQUASH_WINDOW_SIZE(x)    REG_FIELD_PREP(CDCLK_SQUASH_WINDOW_SIZE_MASK, (x))
6965 #define  CDCLK_SQUASH_WAVEFORM_MASK     REG_GENMASK(15, 0)
6966 #define  CDCLK_SQUASH_WAVEFORM(x)       REG_FIELD_PREP(CDCLK_SQUASH_WAVEFORM_MASK, (x))
6967
6968 /* LCPLL_CTL */
6969 #define LCPLL1_CTL              _MMIO(0x46010)
6970 #define LCPLL2_CTL              _MMIO(0x46014)
6971 #define  LCPLL_PLL_ENABLE       (1 << 31)
6972
6973 /* DPLL control1 */
6974 #define DPLL_CTRL1              _MMIO(0x6C058)
6975 #define  DPLL_CTRL1_HDMI_MODE(id)               (1 << ((id) * 6 + 5))
6976 #define  DPLL_CTRL1_SSC(id)                     (1 << ((id) * 6 + 4))
6977 #define  DPLL_CTRL1_LINK_RATE_MASK(id)          (7 << ((id) * 6 + 1))
6978 #define  DPLL_CTRL1_LINK_RATE_SHIFT(id)         ((id) * 6 + 1)
6979 #define  DPLL_CTRL1_LINK_RATE(linkrate, id)     ((linkrate) << ((id) * 6 + 1))
6980 #define  DPLL_CTRL1_OVERRIDE(id)                (1 << ((id) * 6))
6981 #define  DPLL_CTRL1_LINK_RATE_2700              0
6982 #define  DPLL_CTRL1_LINK_RATE_1350              1
6983 #define  DPLL_CTRL1_LINK_RATE_810               2
6984 #define  DPLL_CTRL1_LINK_RATE_1620              3
6985 #define  DPLL_CTRL1_LINK_RATE_1080              4
6986 #define  DPLL_CTRL1_LINK_RATE_2160              5
6987
6988 /* DPLL control2 */
6989 #define DPLL_CTRL2                              _MMIO(0x6C05C)
6990 #define  DPLL_CTRL2_DDI_CLK_OFF(port)           (1 << ((port) + 15))
6991 #define  DPLL_CTRL2_DDI_CLK_SEL_MASK(port)      (3 << ((port) * 3 + 1))
6992 #define  DPLL_CTRL2_DDI_CLK_SEL_SHIFT(port)    ((port) * 3 + 1)
6993 #define  DPLL_CTRL2_DDI_CLK_SEL(clk, port)      ((clk) << ((port) * 3 + 1))
6994 #define  DPLL_CTRL2_DDI_SEL_OVERRIDE(port)     (1 << ((port) * 3))
6995
6996 /* DPLL Status */
6997 #define DPLL_STATUS     _MMIO(0x6C060)
6998 #define  DPLL_LOCK(id) (1 << ((id) * 8))
6999
7000 /* DPLL cfg */
7001 #define _DPLL1_CFGCR1   0x6C040
7002 #define _DPLL2_CFGCR1   0x6C048
7003 #define _DPLL3_CFGCR1   0x6C050
7004 #define  DPLL_CFGCR1_FREQ_ENABLE        (1 << 31)
7005 #define  DPLL_CFGCR1_DCO_FRACTION_MASK  (0x7fff << 9)
7006 #define  DPLL_CFGCR1_DCO_FRACTION(x)    ((x) << 9)
7007 #define  DPLL_CFGCR1_DCO_INTEGER_MASK   (0x1ff)
7008
7009 #define _DPLL1_CFGCR2   0x6C044
7010 #define _DPLL2_CFGCR2   0x6C04C
7011 #define _DPLL3_CFGCR2   0x6C054
7012 #define  DPLL_CFGCR2_QDIV_RATIO_MASK    (0xff << 8)
7013 #define  DPLL_CFGCR2_QDIV_RATIO(x)      ((x) << 8)
7014 #define  DPLL_CFGCR2_QDIV_MODE(x)       ((x) << 7)
7015 #define  DPLL_CFGCR2_KDIV_MASK          (3 << 5)
7016 #define  DPLL_CFGCR2_KDIV(x)            ((x) << 5)
7017 #define  DPLL_CFGCR2_KDIV_5 (0 << 5)
7018 #define  DPLL_CFGCR2_KDIV_2 (1 << 5)
7019 #define  DPLL_CFGCR2_KDIV_3 (2 << 5)
7020 #define  DPLL_CFGCR2_KDIV_1 (3 << 5)
7021 #define  DPLL_CFGCR2_PDIV_MASK          (7 << 2)
7022 #define  DPLL_CFGCR2_PDIV(x)            ((x) << 2)
7023 #define  DPLL_CFGCR2_PDIV_1 (0 << 2)
7024 #define  DPLL_CFGCR2_PDIV_2 (1 << 2)
7025 #define  DPLL_CFGCR2_PDIV_3 (2 << 2)
7026 #define  DPLL_CFGCR2_PDIV_7 (4 << 2)
7027 #define  DPLL_CFGCR2_PDIV_7_INVALID     (5 << 2)
7028 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK  (3)
7029
7030 #define DPLL_CFGCR1(id) _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR1)
7031 #define DPLL_CFGCR2(id) _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR2, _DPLL2_CFGCR2)
7032
7033 /* ICL Clocks */
7034 #define ICL_DPCLKA_CFGCR0                       _MMIO(0x164280)
7035 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)     (1 << _PICK(phy, 10, 11, 24, 4, 5))
7036 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)     REG_BIT((phy) + 10)
7037 #define  ICL_DPCLKA_CFGCR0_TC_CLK_OFF(tc_port)  (1 << ((tc_port) < TC_PORT_4 ? \
7038                                                        (tc_port) + 12 : \
7039                                                        (tc_port) - TC_PORT_4 + 21))
7040 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)       ((phy) * 2)
7041 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy)        (3 << ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7042 #define  ICL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy)        ((pll) << ICL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7043 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)       _PICK(phy, 0, 2, 4, 27)
7044 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy) \
7045         (3 << RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7046 #define  RKL_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy) \
7047         ((pll) << RKL_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7048
7049 /*
7050  * DG1 Clocks
7051  * First registers controls the first A and B, while the second register
7052  * controls the phy C and D. The bits on these registers are the
7053  * same, but refer to different phys
7054  */
7055 #define _DG1_DPCLKA_CFGCR0                              0x164280
7056 #define _DG1_DPCLKA1_CFGCR0                             0x16C280
7057 #define _DG1_DPCLKA_PHY_IDX(phy)                        ((phy) % 2)
7058 #define _DG1_DPCLKA_PLL_IDX(pll)                        ((pll) % 2)
7059 #define DG1_DPCLKA_CFGCR0(phy)                          _MMIO_PHY((phy) / 2, \
7060                                                                   _DG1_DPCLKA_CFGCR0, \
7061                                                                   _DG1_DPCLKA1_CFGCR0)
7062 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_OFF(phy)            REG_BIT(_DG1_DPCLKA_PHY_IDX(phy) + 10)
7063 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy)      (_DG1_DPCLKA_PHY_IDX(phy) * 2)
7064 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL(pll, phy)       (_DG1_DPCLKA_PLL_IDX(pll) << DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7065 #define   DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_MASK(phy)       (0x3 << DG1_DPCLKA_CFGCR0_DDI_CLK_SEL_SHIFT(phy))
7066
7067 /* ADLS Clocks */
7068 #define _ADLS_DPCLKA_CFGCR0                     0x164280
7069 #define _ADLS_DPCLKA_CFGCR1                     0x1642BC
7070 #define ADLS_DPCLKA_CFGCR(phy)                  _MMIO_PHY((phy) / 3, \
7071                                                           _ADLS_DPCLKA_CFGCR0, \
7072                                                           _ADLS_DPCLKA_CFGCR1)
7073 #define  ADLS_DPCLKA_CFGCR_DDI_SHIFT(phy)               (((phy) % 3) * 2)
7074 /* ADLS DPCLKA_CFGCR0 DDI mask */
7075 #define  ADLS_DPCLKA_DDII_SEL_MASK                      REG_GENMASK(5, 4)
7076 #define  ADLS_DPCLKA_DDIB_SEL_MASK                      REG_GENMASK(3, 2)
7077 #define  ADLS_DPCLKA_DDIA_SEL_MASK                      REG_GENMASK(1, 0)
7078 /* ADLS DPCLKA_CFGCR1 DDI mask */
7079 #define  ADLS_DPCLKA_DDIK_SEL_MASK                      REG_GENMASK(3, 2)
7080 #define  ADLS_DPCLKA_DDIJ_SEL_MASK                      REG_GENMASK(1, 0)
7081 #define  ADLS_DPCLKA_CFGCR_DDI_CLK_SEL_MASK(phy)        _PICK((phy), \
7082                                                         ADLS_DPCLKA_DDIA_SEL_MASK, \
7083                                                         ADLS_DPCLKA_DDIB_SEL_MASK, \
7084                                                         ADLS_DPCLKA_DDII_SEL_MASK, \
7085                                                         ADLS_DPCLKA_DDIJ_SEL_MASK, \
7086                                                         ADLS_DPCLKA_DDIK_SEL_MASK)
7087
7088 /* ICL PLL */
7089 #define _DPLL0_ENABLE           0x46010
7090 #define _DPLL1_ENABLE           0x46014
7091 #define _ADLS_DPLL2_ENABLE      0x46018
7092 #define _ADLS_DPLL3_ENABLE      0x46030
7093 #define   PLL_ENABLE            REG_BIT(31)
7094 #define   PLL_LOCK              REG_BIT(30)
7095 #define   PLL_POWER_ENABLE      REG_BIT(27)
7096 #define   PLL_POWER_STATE       REG_BIT(26)
7097 #define ICL_DPLL_ENABLE(pll)    _MMIO(_PICK_EVEN_2RANGES(pll, 3,                        \
7098                                                         _DPLL0_ENABLE, _DPLL1_ENABLE,   \
7099                                                         _ADLS_DPLL3_ENABLE, _ADLS_DPLL3_ENABLE))
7100
7101 #define _DG2_PLL3_ENABLE        0x4601C
7102
7103 #define DG2_PLL_ENABLE(pll)     _MMIO(_PICK_EVEN_2RANGES(pll, 3,                        \
7104                                                         _DPLL0_ENABLE, _DPLL1_ENABLE,   \
7105                                                         _DG2_PLL3_ENABLE, _DG2_PLL3_ENABLE))
7106
7107 #define TBT_PLL_ENABLE          _MMIO(0x46020)
7108
7109 #define _MG_PLL1_ENABLE         0x46030
7110 #define _MG_PLL2_ENABLE         0x46034
7111 #define _MG_PLL3_ENABLE         0x46038
7112 #define _MG_PLL4_ENABLE         0x4603C
7113 /* Bits are the same as _DPLL0_ENABLE */
7114 #define MG_PLL_ENABLE(tc_port)  _MMIO_PORT((tc_port), _MG_PLL1_ENABLE, \
7115                                            _MG_PLL2_ENABLE)
7116
7117 /* DG1 PLL */
7118 #define DG1_DPLL_ENABLE(pll)    _MMIO(_PICK_EVEN_2RANGES(pll, 2,                        \
7119                                                         _DPLL0_ENABLE, _DPLL1_ENABLE,   \
7120                                                         _MG_PLL1_ENABLE, _MG_PLL2_ENABLE))
7121
7122 /* ADL-P Type C PLL */
7123 #define PORTTC1_PLL_ENABLE      0x46038
7124 #define PORTTC2_PLL_ENABLE      0x46040
7125
7126 #define ADLP_PORTTC_PLL_ENABLE(tc_port)         _MMIO_PORT((tc_port), \
7127                                                             PORTTC1_PLL_ENABLE, \
7128                                                             PORTTC2_PLL_ENABLE)
7129
7130 #define _ICL_DPLL0_CFGCR0               0x164000
7131 #define _ICL_DPLL1_CFGCR0               0x164080
7132 #define ICL_DPLL_CFGCR0(pll)            _MMIO_PLL(pll, _ICL_DPLL0_CFGCR0, \
7133                                                   _ICL_DPLL1_CFGCR0)
7134 #define   DPLL_CFGCR0_HDMI_MODE         (1 << 30)
7135 #define   DPLL_CFGCR0_SSC_ENABLE        (1 << 29)
7136 #define   DPLL_CFGCR0_SSC_ENABLE_ICL    (1 << 25)
7137 #define   DPLL_CFGCR0_LINK_RATE_MASK    (0xf << 25)
7138 #define   DPLL_CFGCR0_LINK_RATE_2700    (0 << 25)
7139 #define   DPLL_CFGCR0_LINK_RATE_1350    (1 << 25)
7140 #define   DPLL_CFGCR0_LINK_RATE_810     (2 << 25)
7141 #define   DPLL_CFGCR0_LINK_RATE_1620    (3 << 25)
7142 #define   DPLL_CFGCR0_LINK_RATE_1080    (4 << 25)
7143 #define   DPLL_CFGCR0_LINK_RATE_2160    (5 << 25)
7144 #define   DPLL_CFGCR0_LINK_RATE_3240    (6 << 25)
7145 #define   DPLL_CFGCR0_LINK_RATE_4050    (7 << 25)
7146 #define   DPLL_CFGCR0_DCO_FRACTION_MASK (0x7fff << 10)
7147 #define   DPLL_CFGCR0_DCO_FRACTION_SHIFT        (10)
7148 #define   DPLL_CFGCR0_DCO_FRACTION(x)   ((x) << 10)
7149 #define   DPLL_CFGCR0_DCO_INTEGER_MASK  (0x3ff)
7150
7151 #define _ICL_DPLL0_CFGCR1               0x164004
7152 #define _ICL_DPLL1_CFGCR1               0x164084
7153 #define ICL_DPLL_CFGCR1(pll)            _MMIO_PLL(pll, _ICL_DPLL0_CFGCR1, \
7154                                                   _ICL_DPLL1_CFGCR1)
7155 #define   DPLL_CFGCR1_QDIV_RATIO_MASK   (0xff << 10)
7156 #define   DPLL_CFGCR1_QDIV_RATIO_SHIFT  (10)
7157 #define   DPLL_CFGCR1_QDIV_RATIO(x)     ((x) << 10)
7158 #define   DPLL_CFGCR1_QDIV_MODE_SHIFT   (9)
7159 #define   DPLL_CFGCR1_QDIV_MODE(x)      ((x) << 9)
7160 #define   DPLL_CFGCR1_KDIV_MASK         (7 << 6)
7161 #define   DPLL_CFGCR1_KDIV_SHIFT                (6)
7162 #define   DPLL_CFGCR1_KDIV(x)           ((x) << 6)
7163 #define   DPLL_CFGCR1_KDIV_1            (1 << 6)
7164 #define   DPLL_CFGCR1_KDIV_2            (2 << 6)
7165 #define   DPLL_CFGCR1_KDIV_3            (4 << 6)
7166 #define   DPLL_CFGCR1_PDIV_MASK         (0xf << 2)
7167 #define   DPLL_CFGCR1_PDIV_SHIFT                (2)
7168 #define   DPLL_CFGCR1_PDIV(x)           ((x) << 2)
7169 #define   DPLL_CFGCR1_PDIV_2            (1 << 2)
7170 #define   DPLL_CFGCR1_PDIV_3            (2 << 2)
7171 #define   DPLL_CFGCR1_PDIV_5            (4 << 2)
7172 #define   DPLL_CFGCR1_PDIV_7            (8 << 2)
7173 #define   DPLL_CFGCR1_CENTRAL_FREQ      (3 << 0)
7174 #define   DPLL_CFGCR1_CENTRAL_FREQ_8400 (3 << 0)
7175 #define   TGL_DPLL_CFGCR1_CFSELOVRD_NORMAL_XTAL (0 << 0)
7176
7177 #define _TGL_DPLL0_CFGCR0               0x164284
7178 #define _TGL_DPLL1_CFGCR0               0x16428C
7179 #define _TGL_TBTPLL_CFGCR0              0x16429C
7180 #define TGL_DPLL_CFGCR0(pll)            _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7181                                               _TGL_DPLL0_CFGCR0, _TGL_DPLL1_CFGCR0,     \
7182                                               _TGL_TBTPLL_CFGCR0, _TGL_TBTPLL_CFGCR0))
7183 #define RKL_DPLL_CFGCR0(pll)            _MMIO_PLL(pll, _TGL_DPLL0_CFGCR0, \
7184                                                   _TGL_DPLL1_CFGCR0)
7185
7186 #define _TGL_DPLL0_DIV0                                 0x164B00
7187 #define _TGL_DPLL1_DIV0                                 0x164C00
7188 #define TGL_DPLL0_DIV0(pll)                             _MMIO_PLL(pll, _TGL_DPLL0_DIV0, _TGL_DPLL1_DIV0)
7189 #define   TGL_DPLL0_DIV0_AFC_STARTUP_MASK               REG_GENMASK(27, 25)
7190 #define   TGL_DPLL0_DIV0_AFC_STARTUP(val)               REG_FIELD_PREP(TGL_DPLL0_DIV0_AFC_STARTUP_MASK, (val))
7191
7192 #define _TGL_DPLL0_CFGCR1               0x164288
7193 #define _TGL_DPLL1_CFGCR1               0x164290
7194 #define _TGL_TBTPLL_CFGCR1              0x1642A0
7195 #define TGL_DPLL_CFGCR1(pll)            _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7196                                               _TGL_DPLL0_CFGCR1, _TGL_DPLL1_CFGCR1,     \
7197                                               _TGL_TBTPLL_CFGCR1, _TGL_TBTPLL_CFGCR1))
7198 #define RKL_DPLL_CFGCR1(pll)            _MMIO_PLL(pll, _TGL_DPLL0_CFGCR1, \
7199                                                   _TGL_DPLL1_CFGCR1)
7200
7201 #define _DG1_DPLL2_CFGCR0               0x16C284
7202 #define _DG1_DPLL3_CFGCR0               0x16C28C
7203 #define DG1_DPLL_CFGCR0(pll)            _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7204                                               _TGL_DPLL0_CFGCR0, _TGL_DPLL1_CFGCR0,     \
7205                                               _DG1_DPLL2_CFGCR0, _DG1_DPLL3_CFGCR0))
7206
7207 #define _DG1_DPLL2_CFGCR1               0x16C288
7208 #define _DG1_DPLL3_CFGCR1               0x16C290
7209 #define DG1_DPLL_CFGCR1(pll)            _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7210                                               _TGL_DPLL0_CFGCR1, _TGL_DPLL1_CFGCR1,     \
7211                                               _DG1_DPLL2_CFGCR1, _DG1_DPLL3_CFGCR1))
7212
7213 /* For ADL-S DPLL4_CFGCR0/1 are used to control DPLL2 */
7214 #define _ADLS_DPLL4_CFGCR0              0x164294
7215 #define _ADLS_DPLL3_CFGCR0              0x1642C0
7216 #define ADLS_DPLL_CFGCR0(pll)           _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7217                                               _TGL_DPLL0_CFGCR0, _TGL_DPLL1_CFGCR0,     \
7218                                               _ADLS_DPLL4_CFGCR0, _ADLS_DPLL3_CFGCR0))
7219
7220 #define _ADLS_DPLL4_CFGCR1              0x164298
7221 #define _ADLS_DPLL3_CFGCR1              0x1642C4
7222 #define ADLS_DPLL_CFGCR1(pll)           _MMIO(_PICK_EVEN_2RANGES(pll, 2,                \
7223                                               _TGL_DPLL0_CFGCR1, _TGL_DPLL1_CFGCR1,     \
7224                                               _ADLS_DPLL4_CFGCR1, _ADLS_DPLL3_CFGCR1))
7225
7226 /* BXT display engine PLL */
7227 #define BXT_DE_PLL_CTL                  _MMIO(0x6d000)
7228 #define   BXT_DE_PLL_RATIO(x)           (x)     /* {60,65,100} * 19.2MHz */
7229 #define   BXT_DE_PLL_RATIO_MASK         0xff
7230
7231 #define BXT_DE_PLL_ENABLE               _MMIO(0x46070)
7232 #define   BXT_DE_PLL_PLL_ENABLE         (1 << 31)
7233 #define   BXT_DE_PLL_LOCK               (1 << 30)
7234 #define   BXT_DE_PLL_FREQ_REQ           (1 << 23)
7235 #define   BXT_DE_PLL_FREQ_REQ_ACK       (1 << 22)
7236 #define   ICL_CDCLK_PLL_RATIO(x)        (x)
7237 #define   ICL_CDCLK_PLL_RATIO_MASK      0xff
7238
7239 /* GEN9 DC */
7240 #define DC_STATE_EN                     _MMIO(0x45504)
7241 #define  DC_STATE_DISABLE               0
7242 #define  DC_STATE_EN_DC3CO              REG_BIT(30)
7243 #define  DC_STATE_DC3CO_STATUS          REG_BIT(29)
7244 #define  DC_STATE_EN_UPTO_DC5           (1 << 0)
7245 #define  DC_STATE_EN_DC9                (1 << 3)
7246 #define  DC_STATE_EN_UPTO_DC6           (2 << 0)
7247 #define  DC_STATE_EN_UPTO_DC5_DC6_MASK   0x3
7248
7249 #define  DC_STATE_DEBUG                  _MMIO(0x45520)
7250 #define  DC_STATE_DEBUG_MASK_CORES      (1 << 0)
7251 #define  DC_STATE_DEBUG_MASK_MEMORY_UP  (1 << 1)
7252
7253 #define D_COMP_BDW                      _MMIO(0x138144)
7254
7255 /* Pipe WM_LINETIME - watermark line time */
7256 #define _WM_LINETIME_A          0x45270
7257 #define _WM_LINETIME_B          0x45274
7258 #define WM_LINETIME(pipe) _MMIO_PIPE(pipe, _WM_LINETIME_A, _WM_LINETIME_B)
7259 #define  HSW_LINETIME_MASK      REG_GENMASK(8, 0)
7260 #define  HSW_LINETIME(x)        REG_FIELD_PREP(HSW_LINETIME_MASK, (x))
7261 #define  HSW_IPS_LINETIME_MASK  REG_GENMASK(24, 16)
7262 #define  HSW_IPS_LINETIME(x)    REG_FIELD_PREP(HSW_IPS_LINETIME_MASK, (x))
7263
7264 /* SFUSE_STRAP */
7265 #define SFUSE_STRAP                     _MMIO(0xc2014)
7266 #define  SFUSE_STRAP_FUSE_LOCK          (1 << 13)
7267 #define  SFUSE_STRAP_RAW_FREQUENCY      (1 << 8)
7268 #define  SFUSE_STRAP_DISPLAY_DISABLED   (1 << 7)
7269 #define  SFUSE_STRAP_CRT_DISABLED       (1 << 6)
7270 #define  SFUSE_STRAP_DDIF_DETECTED      (1 << 3)
7271 #define  SFUSE_STRAP_DDIB_DETECTED      (1 << 2)
7272 #define  SFUSE_STRAP_DDIC_DETECTED      (1 << 1)
7273 #define  SFUSE_STRAP_DDID_DETECTED      (1 << 0)
7274
7275 #define WM_MISC                         _MMIO(0x45260)
7276 #define  WM_MISC_DATA_PARTITION_5_6     (1 << 0)
7277
7278 #define WM_DBG                          _MMIO(0x45280)
7279 #define  WM_DBG_DISALLOW_MULTIPLE_LP    (1 << 0)
7280 #define  WM_DBG_DISALLOW_MAXFIFO        (1 << 1)
7281 #define  WM_DBG_DISALLOW_SPRITE         (1 << 2)
7282
7283 /* pipe CSC */
7284 #define _PIPE_A_CSC_COEFF_RY_GY 0x49010
7285 #define _PIPE_A_CSC_COEFF_BY    0x49014
7286 #define _PIPE_A_CSC_COEFF_RU_GU 0x49018
7287 #define _PIPE_A_CSC_COEFF_BU    0x4901c
7288 #define _PIPE_A_CSC_COEFF_RV_GV 0x49020
7289 #define _PIPE_A_CSC_COEFF_BV    0x49024
7290
7291 #define _PIPE_A_CSC_MODE        0x49028
7292 #define  ICL_CSC_ENABLE                 (1 << 31) /* icl+ */
7293 #define  ICL_OUTPUT_CSC_ENABLE          (1 << 30) /* icl+ */
7294 #define  CSC_BLACK_SCREEN_OFFSET        (1 << 2) /* ilk/snb */
7295 #define  CSC_POSITION_BEFORE_GAMMA      (1 << 1) /* pre-glk */
7296 #define  CSC_MODE_YUV_TO_RGB            (1 << 0) /* ilk/snb */
7297
7298 #define _PIPE_A_CSC_PREOFF_HI   0x49030
7299 #define _PIPE_A_CSC_PREOFF_ME   0x49034
7300 #define _PIPE_A_CSC_PREOFF_LO   0x49038
7301 #define _PIPE_A_CSC_POSTOFF_HI  0x49040
7302 #define _PIPE_A_CSC_POSTOFF_ME  0x49044
7303 #define _PIPE_A_CSC_POSTOFF_LO  0x49048
7304
7305 #define _PIPE_B_CSC_COEFF_RY_GY 0x49110
7306 #define _PIPE_B_CSC_COEFF_BY    0x49114
7307 #define _PIPE_B_CSC_COEFF_RU_GU 0x49118
7308 #define _PIPE_B_CSC_COEFF_BU    0x4911c
7309 #define _PIPE_B_CSC_COEFF_RV_GV 0x49120
7310 #define _PIPE_B_CSC_COEFF_BV    0x49124
7311 #define _PIPE_B_CSC_MODE        0x49128
7312 #define _PIPE_B_CSC_PREOFF_HI   0x49130
7313 #define _PIPE_B_CSC_PREOFF_ME   0x49134
7314 #define _PIPE_B_CSC_PREOFF_LO   0x49138
7315 #define _PIPE_B_CSC_POSTOFF_HI  0x49140
7316 #define _PIPE_B_CSC_POSTOFF_ME  0x49144
7317 #define _PIPE_B_CSC_POSTOFF_LO  0x49148
7318
7319 #define PIPE_CSC_COEFF_RY_GY(pipe)      _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RY_GY, _PIPE_B_CSC_COEFF_RY_GY)
7320 #define PIPE_CSC_COEFF_BY(pipe)         _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BY, _PIPE_B_CSC_COEFF_BY)
7321 #define PIPE_CSC_COEFF_RU_GU(pipe)      _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RU_GU, _PIPE_B_CSC_COEFF_RU_GU)
7322 #define PIPE_CSC_COEFF_BU(pipe)         _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BU, _PIPE_B_CSC_COEFF_BU)
7323 #define PIPE_CSC_COEFF_RV_GV(pipe)      _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_RV_GV, _PIPE_B_CSC_COEFF_RV_GV)
7324 #define PIPE_CSC_COEFF_BV(pipe)         _MMIO_PIPE(pipe, _PIPE_A_CSC_COEFF_BV, _PIPE_B_CSC_COEFF_BV)
7325 #define PIPE_CSC_MODE(pipe)             _MMIO_PIPE(pipe, _PIPE_A_CSC_MODE, _PIPE_B_CSC_MODE)
7326 #define PIPE_CSC_PREOFF_HI(pipe)        _MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_HI, _PIPE_B_CSC_PREOFF_HI)
7327 #define PIPE_CSC_PREOFF_ME(pipe)        _MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_ME, _PIPE_B_CSC_PREOFF_ME)
7328 #define PIPE_CSC_PREOFF_LO(pipe)        _MMIO_PIPE(pipe, _PIPE_A_CSC_PREOFF_LO, _PIPE_B_CSC_PREOFF_LO)
7329 #define PIPE_CSC_POSTOFF_HI(pipe)       _MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_HI, _PIPE_B_CSC_POSTOFF_HI)
7330 #define PIPE_CSC_POSTOFF_ME(pipe)       _MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_ME, _PIPE_B_CSC_POSTOFF_ME)
7331 #define PIPE_CSC_POSTOFF_LO(pipe)       _MMIO_PIPE(pipe, _PIPE_A_CSC_POSTOFF_LO, _PIPE_B_CSC_POSTOFF_LO)
7332
7333 /* Pipe Output CSC */
7334 #define _PIPE_A_OUTPUT_CSC_COEFF_RY_GY  0x49050
7335 #define _PIPE_A_OUTPUT_CSC_COEFF_BY     0x49054
7336 #define _PIPE_A_OUTPUT_CSC_COEFF_RU_GU  0x49058
7337 #define _PIPE_A_OUTPUT_CSC_COEFF_BU     0x4905c
7338 #define _PIPE_A_OUTPUT_CSC_COEFF_RV_GV  0x49060
7339 #define _PIPE_A_OUTPUT_CSC_COEFF_BV     0x49064
7340 #define _PIPE_A_OUTPUT_CSC_PREOFF_HI    0x49068
7341 #define _PIPE_A_OUTPUT_CSC_PREOFF_ME    0x4906c
7342 #define _PIPE_A_OUTPUT_CSC_PREOFF_LO    0x49070
7343 #define _PIPE_A_OUTPUT_CSC_POSTOFF_HI   0x49074
7344 #define _PIPE_A_OUTPUT_CSC_POSTOFF_ME   0x49078
7345 #define _PIPE_A_OUTPUT_CSC_POSTOFF_LO   0x4907c
7346
7347 #define _PIPE_B_OUTPUT_CSC_COEFF_RY_GY  0x49150
7348 #define _PIPE_B_OUTPUT_CSC_COEFF_BY     0x49154
7349 #define _PIPE_B_OUTPUT_CSC_COEFF_RU_GU  0x49158
7350 #define _PIPE_B_OUTPUT_CSC_COEFF_BU     0x4915c
7351 #define _PIPE_B_OUTPUT_CSC_COEFF_RV_GV  0x49160
7352 #define _PIPE_B_OUTPUT_CSC_COEFF_BV     0x49164
7353 #define _PIPE_B_OUTPUT_CSC_PREOFF_HI    0x49168
7354 #define _PIPE_B_OUTPUT_CSC_PREOFF_ME    0x4916c
7355 #define _PIPE_B_OUTPUT_CSC_PREOFF_LO    0x49170
7356 #define _PIPE_B_OUTPUT_CSC_POSTOFF_HI   0x49174
7357 #define _PIPE_B_OUTPUT_CSC_POSTOFF_ME   0x49178
7358 #define _PIPE_B_OUTPUT_CSC_POSTOFF_LO   0x4917c
7359
7360 #define PIPE_CSC_OUTPUT_COEFF_RY_GY(pipe)       _MMIO_PIPE(pipe,\
7361                                                            _PIPE_A_OUTPUT_CSC_COEFF_RY_GY,\
7362                                                            _PIPE_B_OUTPUT_CSC_COEFF_RY_GY)
7363 #define PIPE_CSC_OUTPUT_COEFF_BY(pipe)          _MMIO_PIPE(pipe, \
7364                                                            _PIPE_A_OUTPUT_CSC_COEFF_BY, \
7365                                                            _PIPE_B_OUTPUT_CSC_COEFF_BY)
7366 #define PIPE_CSC_OUTPUT_COEFF_RU_GU(pipe)       _MMIO_PIPE(pipe, \
7367                                                            _PIPE_A_OUTPUT_CSC_COEFF_RU_GU, \
7368                                                            _PIPE_B_OUTPUT_CSC_COEFF_RU_GU)
7369 #define PIPE_CSC_OUTPUT_COEFF_BU(pipe)          _MMIO_PIPE(pipe, \
7370                                                            _PIPE_A_OUTPUT_CSC_COEFF_BU, \
7371                                                            _PIPE_B_OUTPUT_CSC_COEFF_BU)
7372 #define PIPE_CSC_OUTPUT_COEFF_RV_GV(pipe)       _MMIO_PIPE(pipe, \
7373                                                            _PIPE_A_OUTPUT_CSC_COEFF_RV_GV, \
7374                                                            _PIPE_B_OUTPUT_CSC_COEFF_RV_GV)
7375 #define PIPE_CSC_OUTPUT_COEFF_BV(pipe)          _MMIO_PIPE(pipe, \
7376                                                            _PIPE_A_OUTPUT_CSC_COEFF_BV, \
7377                                                            _PIPE_B_OUTPUT_CSC_COEFF_BV)
7378 #define PIPE_CSC_OUTPUT_PREOFF_HI(pipe)         _MMIO_PIPE(pipe, \
7379                                                            _PIPE_A_OUTPUT_CSC_PREOFF_HI, \
7380                                                            _PIPE_B_OUTPUT_CSC_PREOFF_HI)
7381 #define PIPE_CSC_OUTPUT_PREOFF_ME(pipe)         _MMIO_PIPE(pipe, \
7382                                                            _PIPE_A_OUTPUT_CSC_PREOFF_ME, \
7383                                                            _PIPE_B_OUTPUT_CSC_PREOFF_ME)
7384 #define PIPE_CSC_OUTPUT_PREOFF_LO(pipe)         _MMIO_PIPE(pipe, \
7385                                                            _PIPE_A_OUTPUT_CSC_PREOFF_LO, \
7386                                                            _PIPE_B_OUTPUT_CSC_PREOFF_LO)
7387 #define PIPE_CSC_OUTPUT_POSTOFF_HI(pipe)        _MMIO_PIPE(pipe, \
7388                                                            _PIPE_A_OUTPUT_CSC_POSTOFF_HI, \
7389                                                            _PIPE_B_OUTPUT_CSC_POSTOFF_HI)
7390 #define PIPE_CSC_OUTPUT_POSTOFF_ME(pipe)        _MMIO_PIPE(pipe, \
7391                                                            _PIPE_A_OUTPUT_CSC_POSTOFF_ME, \
7392                                                            _PIPE_B_OUTPUT_CSC_POSTOFF_ME)
7393 #define PIPE_CSC_OUTPUT_POSTOFF_LO(pipe)        _MMIO_PIPE(pipe, \
7394                                                            _PIPE_A_OUTPUT_CSC_POSTOFF_LO, \
7395                                                            _PIPE_B_OUTPUT_CSC_POSTOFF_LO)
7396
7397 /* pipe degamma/gamma LUTs on IVB+ */
7398 #define _PAL_PREC_INDEX_A       0x4A400
7399 #define _PAL_PREC_INDEX_B       0x4AC00
7400 #define _PAL_PREC_INDEX_C       0x4B400
7401 #define   PAL_PREC_SPLIT_MODE           REG_BIT(31)
7402 #define   PAL_PREC_AUTO_INCREMENT       REG_BIT(15)
7403 #define   PAL_PREC_INDEX_VALUE_MASK     REG_GENMASK(9, 0)
7404 #define   PAL_PREC_INDEX_VALUE(x)       REG_FIELD_PREP(PAL_PREC_INDEX_VALUE_MASK, (x))
7405 #define _PAL_PREC_DATA_A        0x4A404
7406 #define _PAL_PREC_DATA_B        0x4AC04
7407 #define _PAL_PREC_DATA_C        0x4B404
7408 /* see PREC_PALETTE_* for the bits */
7409 #define _PAL_PREC_GC_MAX_A      0x4A410
7410 #define _PAL_PREC_GC_MAX_B      0x4AC10
7411 #define _PAL_PREC_GC_MAX_C      0x4B410
7412 #define _PAL_PREC_EXT_GC_MAX_A  0x4A420
7413 #define _PAL_PREC_EXT_GC_MAX_B  0x4AC20
7414 #define _PAL_PREC_EXT_GC_MAX_C  0x4B420
7415 #define _PAL_PREC_EXT2_GC_MAX_A 0x4A430
7416 #define _PAL_PREC_EXT2_GC_MAX_B 0x4AC30
7417 #define _PAL_PREC_EXT2_GC_MAX_C 0x4B430
7418
7419 #define PREC_PAL_INDEX(pipe)            _MMIO_PIPE(pipe, _PAL_PREC_INDEX_A, _PAL_PREC_INDEX_B)
7420 #define PREC_PAL_DATA(pipe)             _MMIO_PIPE(pipe, _PAL_PREC_DATA_A, _PAL_PREC_DATA_B)
7421 #define PREC_PAL_GC_MAX(pipe, i)        _MMIO(_PIPE(pipe, _PAL_PREC_GC_MAX_A, _PAL_PREC_GC_MAX_B) + (i) * 4) /* u1.16 */
7422 #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 */
7423 #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 */
7424
7425 #define _PRE_CSC_GAMC_INDEX_A   0x4A484
7426 #define _PRE_CSC_GAMC_INDEX_B   0x4AC84
7427 #define _PRE_CSC_GAMC_INDEX_C   0x4B484
7428 #define   PRE_CSC_GAMC_AUTO_INCREMENT   REG_BIT(10)
7429 #define   PRE_CSC_GAMC_INDEX_VALUE_MASK REG_GENMASK(7, 0)
7430 #define   PRE_CSC_GAMC_INDEX_VALUE(x)   REG_FIELD_PREP(PRE_CSC_GAMC_INDEX_VALUE_MASK, (x))
7431 #define _PRE_CSC_GAMC_DATA_A    0x4A488
7432 #define _PRE_CSC_GAMC_DATA_B    0x4AC88
7433 #define _PRE_CSC_GAMC_DATA_C    0x4B488
7434
7435 #define PRE_CSC_GAMC_INDEX(pipe)        _MMIO_PIPE(pipe, _PRE_CSC_GAMC_INDEX_A, _PRE_CSC_GAMC_INDEX_B)
7436 #define PRE_CSC_GAMC_DATA(pipe)         _MMIO_PIPE(pipe, _PRE_CSC_GAMC_DATA_A, _PRE_CSC_GAMC_DATA_B)
7437
7438 /* ICL Multi segmented gamma */
7439 #define _PAL_PREC_MULTI_SEG_INDEX_A     0x4A408
7440 #define _PAL_PREC_MULTI_SEG_INDEX_B     0x4AC08
7441 #define   PAL_PREC_MULTI_SEG_AUTO_INCREMENT     REG_BIT(15)
7442 #define   PAL_PREC_MULTI_SEG_INDEX_VALUE_MASK   REG_GENMASK(4, 0)
7443 #define   PAL_PREC_MULTI_SEG_INDEX_VALUE(x)     REG_FIELD_PREP(PAL_PREC_MULTI_SEG_INDEX_VALUE_MASK, (x))
7444
7445 #define _PAL_PREC_MULTI_SEG_DATA_A      0x4A40C
7446 #define _PAL_PREC_MULTI_SEG_DATA_B      0x4AC0C
7447 /* see PREC_PALETTE_12P4_* for the bits */
7448
7449 #define PREC_PAL_MULTI_SEG_INDEX(pipe)  _MMIO_PIPE(pipe, \
7450                                         _PAL_PREC_MULTI_SEG_INDEX_A, \
7451                                         _PAL_PREC_MULTI_SEG_INDEX_B)
7452 #define PREC_PAL_MULTI_SEG_DATA(pipe)   _MMIO_PIPE(pipe, \
7453                                         _PAL_PREC_MULTI_SEG_DATA_A, \
7454                                         _PAL_PREC_MULTI_SEG_DATA_B)
7455
7456 #define _MMIO_PLANE_GAMC(plane, i, a, b)  _MMIO(_PIPE(plane, a, b) + (i) * 4)
7457
7458 /* Plane CSC Registers */
7459 #define _PLANE_CSC_RY_GY_1_A    0x70210
7460 #define _PLANE_CSC_RY_GY_2_A    0x70310
7461
7462 #define _PLANE_CSC_RY_GY_1_B    0x71210
7463 #define _PLANE_CSC_RY_GY_2_B    0x71310
7464
7465 #define _PLANE_CSC_RY_GY_1(pipe)        _PIPE(pipe, _PLANE_CSC_RY_GY_1_A, \
7466                                               _PLANE_CSC_RY_GY_1_B)
7467 #define _PLANE_CSC_RY_GY_2(pipe)        _PIPE(pipe, _PLANE_INPUT_CSC_RY_GY_2_A, \
7468                                               _PLANE_INPUT_CSC_RY_GY_2_B)
7469 #define PLANE_CSC_COEFF(pipe, plane, index)     _MMIO_PLANE(plane, \
7470                                                             _PLANE_CSC_RY_GY_1(pipe) +  (index) * 4, \
7471                                                             _PLANE_CSC_RY_GY_2(pipe) + (index) * 4)
7472
7473 #define _PLANE_CSC_PREOFF_HI_1_A                0x70228
7474 #define _PLANE_CSC_PREOFF_HI_2_A                0x70328
7475
7476 #define _PLANE_CSC_PREOFF_HI_1_B                0x71228
7477 #define _PLANE_CSC_PREOFF_HI_2_B                0x71328
7478
7479 #define _PLANE_CSC_PREOFF_HI_1(pipe)    _PIPE(pipe, _PLANE_CSC_PREOFF_HI_1_A, \
7480                                               _PLANE_CSC_PREOFF_HI_1_B)
7481 #define _PLANE_CSC_PREOFF_HI_2(pipe)    _PIPE(pipe, _PLANE_CSC_PREOFF_HI_2_A, \
7482                                               _PLANE_CSC_PREOFF_HI_2_B)
7483 #define PLANE_CSC_PREOFF(pipe, plane, index)    _MMIO_PLANE(plane, _PLANE_CSC_PREOFF_HI_1(pipe) + \
7484                                                             (index) * 4, _PLANE_CSC_PREOFF_HI_2(pipe) + \
7485                                                             (index) * 4)
7486
7487 #define _PLANE_CSC_POSTOFF_HI_1_A               0x70234
7488 #define _PLANE_CSC_POSTOFF_HI_2_A               0x70334
7489
7490 #define _PLANE_CSC_POSTOFF_HI_1_B               0x71234
7491 #define _PLANE_CSC_POSTOFF_HI_2_B               0x71334
7492
7493 #define _PLANE_CSC_POSTOFF_HI_1(pipe)   _PIPE(pipe, _PLANE_CSC_POSTOFF_HI_1_A, \
7494                                               _PLANE_CSC_POSTOFF_HI_1_B)
7495 #define _PLANE_CSC_POSTOFF_HI_2(pipe)   _PIPE(pipe, _PLANE_CSC_POSTOFF_HI_2_A, \
7496                                               _PLANE_CSC_POSTOFF_HI_2_B)
7497 #define PLANE_CSC_POSTOFF(pipe, plane, index)   _MMIO_PLANE(plane, _PLANE_CSC_POSTOFF_HI_1(pipe) + \
7498                                                             (index) * 4, _PLANE_CSC_POSTOFF_HI_2(pipe) + \
7499                                                             (index) * 4)
7500
7501 /* pipe CSC & degamma/gamma LUTs on CHV */
7502 #define _CGM_PIPE_A_CSC_COEFF01 (VLV_DISPLAY_BASE + 0x67900)
7503 #define _CGM_PIPE_A_CSC_COEFF23 (VLV_DISPLAY_BASE + 0x67904)
7504 #define _CGM_PIPE_A_CSC_COEFF45 (VLV_DISPLAY_BASE + 0x67908)
7505 #define _CGM_PIPE_A_CSC_COEFF67 (VLV_DISPLAY_BASE + 0x6790C)
7506 #define _CGM_PIPE_A_CSC_COEFF8  (VLV_DISPLAY_BASE + 0x67910)
7507 #define _CGM_PIPE_A_DEGAMMA     (VLV_DISPLAY_BASE + 0x66000)
7508 /* cgm degamma ldw */
7509 #define   CGM_PIPE_DEGAMMA_GREEN_LDW_MASK       REG_GENMASK(29, 16)
7510 #define   CGM_PIPE_DEGAMMA_BLUE_LDW_MASK        REG_GENMASK(13, 0)
7511 /* cgm degamma udw */
7512 #define   CGM_PIPE_DEGAMMA_RED_UDW_MASK         REG_GENMASK(13, 0)
7513 #define _CGM_PIPE_A_GAMMA       (VLV_DISPLAY_BASE + 0x67000)
7514 /* cgm gamma ldw */
7515 #define   CGM_PIPE_GAMMA_GREEN_LDW_MASK         REG_GENMASK(25, 16)
7516 #define   CGM_PIPE_GAMMA_BLUE_LDW_MASK          REG_GENMASK(9, 0)
7517 /* cgm gamma udw */
7518 #define   CGM_PIPE_GAMMA_RED_UDW_MASK           REG_GENMASK(9, 0)
7519 #define _CGM_PIPE_A_MODE        (VLV_DISPLAY_BASE + 0x67A00)
7520 #define   CGM_PIPE_MODE_GAMMA   (1 << 2)
7521 #define   CGM_PIPE_MODE_CSC     (1 << 1)
7522 #define   CGM_PIPE_MODE_DEGAMMA (1 << 0)
7523
7524 #define _CGM_PIPE_B_CSC_COEFF01 (VLV_DISPLAY_BASE + 0x69900)
7525 #define _CGM_PIPE_B_CSC_COEFF23 (VLV_DISPLAY_BASE + 0x69904)
7526 #define _CGM_PIPE_B_CSC_COEFF45 (VLV_DISPLAY_BASE + 0x69908)
7527 #define _CGM_PIPE_B_CSC_COEFF67 (VLV_DISPLAY_BASE + 0x6990C)
7528 #define _CGM_PIPE_B_CSC_COEFF8  (VLV_DISPLAY_BASE + 0x69910)
7529 #define _CGM_PIPE_B_DEGAMMA     (VLV_DISPLAY_BASE + 0x68000)
7530 #define _CGM_PIPE_B_GAMMA       (VLV_DISPLAY_BASE + 0x69000)
7531 #define _CGM_PIPE_B_MODE        (VLV_DISPLAY_BASE + 0x69A00)
7532
7533 #define CGM_PIPE_CSC_COEFF01(pipe)      _MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF01, _CGM_PIPE_B_CSC_COEFF01)
7534 #define CGM_PIPE_CSC_COEFF23(pipe)      _MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF23, _CGM_PIPE_B_CSC_COEFF23)
7535 #define CGM_PIPE_CSC_COEFF45(pipe)      _MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF45, _CGM_PIPE_B_CSC_COEFF45)
7536 #define CGM_PIPE_CSC_COEFF67(pipe)      _MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF67, _CGM_PIPE_B_CSC_COEFF67)
7537 #define CGM_PIPE_CSC_COEFF8(pipe)       _MMIO_PIPE(pipe, _CGM_PIPE_A_CSC_COEFF8, _CGM_PIPE_B_CSC_COEFF8)
7538 #define CGM_PIPE_DEGAMMA(pipe, i, w)    _MMIO(_PIPE(pipe, _CGM_PIPE_A_DEGAMMA, _CGM_PIPE_B_DEGAMMA) + (i) * 8 + (w) * 4)
7539 #define CGM_PIPE_GAMMA(pipe, i, w)      _MMIO(_PIPE(pipe, _CGM_PIPE_A_GAMMA, _CGM_PIPE_B_GAMMA) + (i) * 8 + (w) * 4)
7540 #define CGM_PIPE_MODE(pipe)             _MMIO_PIPE(pipe, _CGM_PIPE_A_MODE, _CGM_PIPE_B_MODE)
7541
7542 /* Gen4+ Timestamp and Pipe Frame time stamp registers */
7543 #define GEN4_TIMESTAMP          _MMIO(0x2358)
7544 #define ILK_TIMESTAMP_HI        _MMIO(0x70070)
7545 #define IVB_TIMESTAMP_CTR       _MMIO(0x44070)
7546
7547 #define GEN9_TIMESTAMP_OVERRIDE                         _MMIO(0x44074)
7548 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_SHIFT       0
7549 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK        0x3ff
7550 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_SHIFT   12
7551 #define  GEN9_TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK    (0xf << 12)
7552
7553 #define _PIPE_FRMTMSTMP_A               0x70048
7554 #define PIPE_FRMTMSTMP(pipe)            \
7555                         _MMIO_PIPE2(pipe, _PIPE_FRMTMSTMP_A)
7556
7557 #define GGC                             _MMIO(0x108040)
7558 #define   GMS_MASK                      REG_GENMASK(15, 8)
7559 #define   GGMS_MASK                     REG_GENMASK(7, 6)
7560
7561 #define GEN12_GSMBASE                   _MMIO(0x108100)
7562 #define GEN12_DSMBASE                   _MMIO(0x1080C0)
7563 #define   GEN12_BDSM_MASK               REG_GENMASK64(63, 20)
7564
7565 #define XEHP_CLOCK_GATE_DIS             _MMIO(0x101014)
7566 #define   SGSI_SIDECLK_DIS              REG_BIT(17)
7567 #define   SGGI_DIS                      REG_BIT(15)
7568 #define   SGR_DIS                       REG_BIT(13)
7569
7570 #define _ICL_PHY_MISC_A         0x64C00
7571 #define _ICL_PHY_MISC_B         0x64C04
7572 #define _DG2_PHY_MISC_TC1       0x64C14 /* TC1="PHY E" but offset as if "PHY F" */
7573 #define ICL_PHY_MISC(port)      _MMIO_PORT(port, _ICL_PHY_MISC_A, _ICL_PHY_MISC_B)
7574 #define DG2_PHY_MISC(port)      ((port) == PHY_E ? _MMIO(_DG2_PHY_MISC_TC1) : \
7575                                  ICL_PHY_MISC(port))
7576 #define  ICL_PHY_MISC_MUX_DDID                  (1 << 28)
7577 #define  ICL_PHY_MISC_DE_IO_COMP_PWR_DOWN       (1 << 23)
7578 #define  DG2_PHY_DP_TX_ACK_MASK                 REG_GENMASK(23, 20)
7579
7580 #define PORT_TX_DFLEXDPSP(fia)                  _MMIO_FIA((fia), 0x008A0)
7581 #define   MODULAR_FIA_MASK                      (1 << 4)
7582 #define   TC_LIVE_STATE_TBT(idx)                (1 << ((idx) * 8 + 6))
7583 #define   TC_LIVE_STATE_TC(idx)                 (1 << ((idx) * 8 + 5))
7584 #define   DP_LANE_ASSIGNMENT_SHIFT(idx)         ((idx) * 8)
7585 #define   DP_LANE_ASSIGNMENT_MASK(idx)          (0xf << ((idx) * 8))
7586 #define   DP_LANE_ASSIGNMENT(idx, x)            ((x) << ((idx) * 8))
7587
7588 #define PORT_TX_DFLEXDPPMS(fia)                 _MMIO_FIA((fia), 0x00890)
7589 #define   DP_PHY_MODE_STATUS_COMPLETED(idx)     (1 << (idx))
7590
7591 #define PORT_TX_DFLEXDPCSSS(fia)                _MMIO_FIA((fia), 0x00894)
7592 #define   DP_PHY_MODE_STATUS_NOT_SAFE(idx)      (1 << (idx))
7593
7594 #define PORT_TX_DFLEXPA1(fia)                   _MMIO_FIA((fia), 0x00880)
7595 #define   DP_PIN_ASSIGNMENT_SHIFT(idx)          ((idx) * 4)
7596 #define   DP_PIN_ASSIGNMENT_MASK(idx)           (0xf << ((idx) * 4))
7597 #define   DP_PIN_ASSIGNMENT(idx, x)             ((x) << ((idx) * 4))
7598
7599 #define _TCSS_DDI_STATUS_1                      0x161500
7600 #define _TCSS_DDI_STATUS_2                      0x161504
7601 #define TCSS_DDI_STATUS(tc)                     _MMIO(_PICK_EVEN(tc, \
7602                                                                  _TCSS_DDI_STATUS_1, \
7603                                                                  _TCSS_DDI_STATUS_2))
7604 #define  TCSS_DDI_STATUS_READY                  REG_BIT(2)
7605 #define  TCSS_DDI_STATUS_HPD_LIVE_STATUS_TBT    REG_BIT(1)
7606 #define  TCSS_DDI_STATUS_HPD_LIVE_STATUS_ALT    REG_BIT(0)
7607
7608 #define PRIMARY_SPI_TRIGGER                     _MMIO(0x102040)
7609 #define PRIMARY_SPI_ADDRESS                     _MMIO(0x102080)
7610 #define PRIMARY_SPI_REGIONID                    _MMIO(0x102084)
7611 #define SPI_STATIC_REGIONS                      _MMIO(0x102090)
7612 #define   OPTIONROM_SPI_REGIONID_MASK           REG_GENMASK(7, 0)
7613 #define OROM_OFFSET                             _MMIO(0x1020c0)
7614 #define   OROM_OFFSET_MASK                      REG_GENMASK(20, 16)
7615
7616 /* This register controls the Display State Buffer (DSB) engines. */
7617 #define _DSBSL_INSTANCE_BASE            0x70B00
7618 #define DSBSL_INSTANCE(pipe, id)        (_DSBSL_INSTANCE_BASE + \
7619                                          (pipe) * 0x1000 + (id) * 0x100)
7620 #define DSB_HEAD(pipe, id)              _MMIO(DSBSL_INSTANCE(pipe, id) + 0x0)
7621 #define DSB_TAIL(pipe, id)              _MMIO(DSBSL_INSTANCE(pipe, id) + 0x4)
7622 #define DSB_CTRL(pipe, id)              _MMIO(DSBSL_INSTANCE(pipe, id) + 0x8)
7623 #define   DSB_ENABLE                    REG_BIT(31)
7624 #define   DSB_BUF_REITERATE             REG_BIT(29)
7625 #define   DSB_WAIT_FOR_VBLANK           REG_BIT(28)
7626 #define   DSB_WAIT_FOR_LINE_IN          REG_BIT(27)
7627 #define   DSB_HALT                      REG_BIT(16)
7628 #define   DSB_NON_POSTED                REG_BIT(8)
7629 #define   DSB_STATUS_BUSY               REG_BIT(0)
7630 #define DSB_MMIOCTRL(pipe, id)          _MMIO(DSBSL_INSTANCE(pipe, id) + 0xc)
7631 #define   DSB_MMIO_DEAD_CLOCKS_ENABLE   REG_BIT(31)
7632 #define   DSB_MMIO_DEAD_CLOCKS_COUNT_MASK       REG_GENMASK(15, 8)
7633 #define   DSB_MMIO_DEAD_CLOCKS_COUNT(x) REG_FIELD_PREP(DSB_MMIO_DEAD_CLOCK_COUNT_MASK, (x))
7634 #define   DSB_MMIO_CYCLES_MASK          REG_GENMASK(7, 0)
7635 #define   DSB_MMIO_CYCLES(x)            REG_FIELD_PREP(DSB_MMIO_CYCLES_MASK, (x))
7636 #define DSB_POLLFUNC(pipe, id)          _MMIO(DSBSL_INSTANCE(pipe, id) + 0x10)
7637 #define   DSB_POLL_ENABLE               REG_BIT(31)
7638 #define   DSB_POLL_WAIT_MASK            REG_GENMASK(30, 23)
7639 #define   DSB_POLL_WAIT(x)              REG_FIELD_PREP(DSB_POLL_WAIT_MASK, (x)) /* usec */
7640 #define   DSB_POLL_COUNT_MASK           REG_GENMASK(22, 15)
7641 #define   DSB_POLL_COUNT(x)             REG_FIELD_PREP(DSB_POLL_COUNT_MASK, (x))
7642 #define DSB_DEBUG(pipe, id)             _MMIO(DSBSL_INSTANCE(pipe, id) + 0x14)
7643 #define DSB_POLLMASK(pipe, id)          _MMIO(DSBSL_INSTANCE(pipe, id) + 0x1c)
7644 #define DSB_STATUS(pipe, id)            _MMIO(DSBSL_INSTANCE(pipe, id) + 0x24)
7645 #define DSB_INTERRUPT(pipe, id)         _MMIO(DSBSL_INSTANCE(pipe, id) + 0x28)
7646 #define   DSB_ATS_FAULT_INT_EN          REG_BIT(20)
7647 #define   DSB_GTT_FAULT_INT_EN          REG_BIT(19)
7648 #define   DSB_RSPTIMEOUT_INT_EN         REG_BIT(18)
7649 #define   DSB_POLL_ERR_INT_EN           REG_BIT(17)
7650 #define   DSB_PROG_INT_EN               REG_BIT(16)
7651 #define   DSB_ATS_FAULT_INT_STATUS      REG_BIT(4)
7652 #define   DSB_GTT_FAULT_INT_STATUS      REG_BIT(3)
7653 #define   DSB_RSPTIMEOUT_INT_STATUS     REG_BIT(2)
7654 #define   DSB_POLL_ERR_INT_STATUS       REG_BIT(1)
7655 #define   DSB_PROG_INT_STATUS           REG_BIT(0)
7656 #define DSB_CURRENT_HEAD(pipe, id)      _MMIO(DSBSL_INSTANCE(pipe, id) + 0x2c)
7657 #define DSB_RM_TIMEOUT(pipe, id)        _MMIO(DSBSL_INSTANCE(pipe, id) + 0x30)
7658 #define   DSB_RM_CLAIM_TIMEOUT          REG_BIT(31)
7659 #define   DSB_RM_READY_TIMEOUT          REG_BIT(30)
7660 #define   DSB_RM_CLAIM_TIMEOUT_COUNT_MASK       REG_GENMASK(23, 16)
7661 #define   DSB_RM_CLAIM_TIMEOUT_COUNT(x) REG_FIELD_PREP(DSB_RM_CLAIM_TIMEOUT_COUNT_MASK, (x)) /* clocks */
7662 #define   DSB_RM_READY_TIMEOUT_VALUE_MASK       REG_GENMASK(15, 0)
7663 #define   DSB_RM_READY_TIMEOUT_VALUE(x) REG_FIELD_PREP(DSB_RM_READY_TIMEOUT_VALUE, (x)) /* usec */
7664 #define DSB_RMTIMEOUTREG_CAPTURE(pipe, id)      _MMIO(DSBSL_INSTANCE(pipe, id) + 0x34)
7665 #define DSB_PMCTRL(pipe, id)            _MMIO(DSBSL_INSTANCE(pipe, id) + 0x38)
7666 #define DSB_PMCTRL_2(pipe, id)          _MMIO(DSBSL_INSTANCE(pipe, id) + 0x3c)
7667 #define DSB_PF_LN_LOWER(pipe, id)       _MMIO(DSBSL_INSTANCE(pipe, id) + 0x40)
7668 #define DSB_PF_LN_UPPER(pipe, id)       _MMIO(DSBSL_INSTANCE(pipe, id) + 0x44)
7669 #define DSB_BUFRPT_CNT(pipe, id)        _MMIO(DSBSL_INSTANCE(pipe, id) + 0x48)
7670 #define DSB_CHICKEN(pipe, id)           _MMIO(DSBSL_INSTANCE(pipe, id) + 0xf0)
7671
7672 #define CLKREQ_POLICY                   _MMIO(0x101038)
7673 #define  CLKREQ_POLICY_MEM_UP_OVRD      REG_BIT(1)
7674
7675 #define CLKGATE_DIS_MISC                        _MMIO(0x46534)
7676 #define  CLKGATE_DIS_MISC_DMASC_GATING_DIS      REG_BIT(21)
7677
7678 #define _MTL_CLKGATE_DIS_TRANS_A                        0x604E8
7679 #define _MTL_CLKGATE_DIS_TRANS_B                        0x614E8
7680 #define MTL_CLKGATE_DIS_TRANS(trans)                    _MMIO_TRANS2(trans, _MTL_CLKGATE_DIS_TRANS_A)
7681 #define  MTL_CLKGATE_DIS_TRANS_DMASC_GATING_DIS         REG_BIT(7)
7682
7683 #define MTL_LATENCY_LP0_LP1             _MMIO(0x45780)
7684 #define MTL_LATENCY_LP2_LP3             _MMIO(0x45784)
7685 #define MTL_LATENCY_LP4_LP5             _MMIO(0x45788)
7686 #define  MTL_LATENCY_LEVEL_EVEN_MASK    REG_GENMASK(12, 0)
7687 #define  MTL_LATENCY_LEVEL_ODD_MASK     REG_GENMASK(28, 16)
7688
7689 #define MTL_LATENCY_SAGV                _MMIO(0x4578b)
7690 #define   MTL_LATENCY_QCLK_SAGV         REG_GENMASK(12, 0)
7691
7692 #define MTL_MEM_SS_INFO_GLOBAL                  _MMIO(0x45700)
7693 #define   MTL_N_OF_ENABLED_QGV_POINTS_MASK      REG_GENMASK(11, 8)
7694 #define   MTL_N_OF_POPULATED_CH_MASK            REG_GENMASK(7, 4)
7695 #define   MTL_DDR_TYPE_MASK                     REG_GENMASK(3, 0)
7696
7697 #define MTL_MEM_SS_INFO_QGV_POINT_LOW(point)     _MMIO(0x45710 + (point) * 2)
7698 #define   MTL_TRCD_MASK                 REG_GENMASK(31, 24)
7699 #define   MTL_TRP_MASK                  REG_GENMASK(23, 16)
7700 #define   MTL_DCLK_MASK                 REG_GENMASK(15, 0)
7701
7702 #define MTL_MEM_SS_INFO_QGV_POINT_HIGH(point)    _MMIO(0x45714 + (point) * 2)
7703 #define   MTL_TRAS_MASK                 REG_GENMASK(16, 8)
7704 #define   MTL_TRDPRE_MASK               REG_GENMASK(7, 0)
7705
7706 #define MTL_MEDIA_GSI_BASE              0x380000
7707
7708 #endif /* _I915_REG_H_ */