OSDN Git Service

drm/i915/chv: Use RMW to toggle swing calc init
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / gpu / drm / i915 / i915_reg.h
index 9f5b18d..89025e4 100644 (file)
@@ -29,6 +29,8 @@
 #define _TRANSCODER(tran, a, b) ((a) + (tran)*((b)-(a)))
 
 #define _PORT(port, a, b) ((a) + (port)*((b)-(a)))
+#define _PIPE3(pipe, a, b, c) (pipe < 2 ? _PIPE(pipe, a, b) : c)
+#define _PORT3(port, a, b, c) (port < 2 ? _PORT(port, a, b) : c)
 
 #define _MASKED_BIT_ENABLE(a) (((a) << 16) | (a))
 #define _MASKED_BIT_DISABLE(a) ((a) << 16)
 
 /* Graphics reset regs */
 #define I965_GDRST 0xc0 /* PCI config register */
-#define ILK_GDSR 0x2ca4 /* MCHBAR offset */
 #define  GRDOM_FULL    (0<<2)
 #define  GRDOM_RENDER  (1<<2)
 #define  GRDOM_MEDIA   (3<<2)
 #define  GRDOM_MASK    (3<<2)
 #define  GRDOM_RESET_ENABLE (1<<0)
 
+#define ILK_GDSR 0x2ca4 /* MCHBAR offset */
+#define  ILK_GRDOM_FULL                (0<<1)
+#define  ILK_GRDOM_RENDER      (1<<1)
+#define  ILK_GRDOM_MEDIA       (3<<1)
+#define  ILK_GRDOM_MASK                (3<<1)
+#define  ILK_GRDOM_RESET_ENABLE (1<<0)
+
 #define GEN6_MBCUNIT_SNPCR     0x900c /* for LLC config */
 #define   GEN6_MBC_SNPCR_SHIFT 21
 #define   GEN6_MBC_SNPCR_MASK  (3<<21)
 #define   GEN6_MBC_SNPCR_LOW   (2<<21)
 #define   GEN6_MBC_SNPCR_MIN   (3<<21) /* only 1/16th of the cache is shared */
 
+#define VLV_G3DCTL             0x9024
+#define VLV_GSCKGCTL           0x9028
+
 #define GEN6_MBCTL             0x0907c
 #define   GEN6_MBCTL_ENABLE_BOOT_FETCH (1 << 4)
 #define   GEN6_MBCTL_CTX_FETCH_NEEDED  (1 << 3)
  * Memory interface instructions used by the kernel
  */
 #define MI_INSTR(opcode, flags) (((opcode) << 23) | (flags))
+/* Many MI commands use bit 22 of the header dword for GGTT vs PPGTT */
+#define  MI_GLOBAL_GTT    (1<<22)
 
 #define MI_NOOP                        MI_INSTR(0, 0)
 #define MI_USER_INTERRUPT      MI_INSTR(0x02, 0)
 #define   MI_SEMAPHORE_SYNC_BVE            (0<<16) /* VECS wait for BCS  (VEBSYNC) */
 #define   MI_SEMAPHORE_SYNC_VVE            (1<<16) /* VECS wait for VCS  (VEVSYNC) */
 #define   MI_SEMAPHORE_SYNC_RVE            (2<<16) /* VECS wait for RCS  (VERSYNC) */
-#define   MI_SEMAPHORE_SYNC_INVALID  (3<<16)
+#define   MI_SEMAPHORE_SYNC_INVALID (3<<16)
+#define   MI_SEMAPHORE_SYNC_MASK    (3<<16)
 #define MI_SET_CONTEXT         MI_INSTR(0x18, 0)
 #define   MI_MM_SPACE_GTT              (1<<8)
 #define   MI_MM_SPACE_PHYSICAL         (0<<8)
  * - One can actually load arbitrary many arbitrary registers: Simply issue x
  *   address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
  */
-#define MI_LOAD_REGISTER_IMM(x)        MI_INSTR(0x22, 2*x-1)
-#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1)
+#define MI_LOAD_REGISTER_IMM(x)        MI_INSTR(0x22, 2*(x)-1)
+#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*(x)-1)
+#define MI_STORE_REGISTER_MEM_GEN8(x) MI_INSTR(0x24, 3*(x)-1)
 #define   MI_SRM_LRM_GLOBAL_GTT                (1<<22)
 #define MI_FLUSH_DW            MI_INSTR(0x26, 1) /* for GEN6 */
 #define   MI_FLUSH_DW_STORE_INDEX      (1<<21)
 #define   MI_INVALIDATE_TLB            (1<<18)
 #define   MI_FLUSH_DW_OP_STOREDW       (1<<14)
+#define   MI_FLUSH_DW_OP_MASK          (3<<14)
+#define   MI_FLUSH_DW_NOTIFY           (1<<8)
 #define   MI_INVALIDATE_BSD            (1<<7)
 #define   MI_FLUSH_DW_USE_GTT          (1<<2)
 #define   MI_FLUSH_DW_USE_PPGTT                (0<<2)
 #define   DISPLAY_PLANE_B           (1<<20)
 #define GFX_OP_PIPE_CONTROL(len)       ((0x3<<29)|(0x3<<27)|(0x2<<24)|(len-2))
 #define   PIPE_CONTROL_GLOBAL_GTT_IVB                  (1<<24) /* gen7+ */
+#define   PIPE_CONTROL_MMIO_WRITE                      (1<<23)
+#define   PIPE_CONTROL_STORE_DATA_INDEX                        (1<<21)
 #define   PIPE_CONTROL_CS_STALL                                (1<<20)
 #define   PIPE_CONTROL_TLB_INVALIDATE                  (1<<18)
 #define   PIPE_CONTROL_QW_WRITE                                (1<<14)
+#define   PIPE_CONTROL_POST_SYNC_OP_MASK                (3<<14)
 #define   PIPE_CONTROL_DEPTH_STALL                     (1<<13)
 #define   PIPE_CONTROL_WRITE_FLUSH                     (1<<12)
 #define   PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH       (1<<12) /* gen6+ */
 #define   PIPE_CONTROL_DEPTH_CACHE_FLUSH               (1<<0)
 #define   PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */
 
+/*
+ * Commands used only by the command parser
+ */
+#define MI_SET_PREDICATE        MI_INSTR(0x01, 0)
+#define MI_ARB_CHECK            MI_INSTR(0x05, 0)
+#define MI_RS_CONTROL           MI_INSTR(0x06, 0)
+#define MI_URB_ATOMIC_ALLOC     MI_INSTR(0x09, 0)
+#define MI_PREDICATE            MI_INSTR(0x0C, 0)
+#define MI_RS_CONTEXT           MI_INSTR(0x0F, 0)
+#define MI_TOPOLOGY_FILTER      MI_INSTR(0x0D, 0)
+#define MI_LOAD_SCAN_LINES_EXCL MI_INSTR(0x13, 0)
+#define MI_URB_CLEAR            MI_INSTR(0x19, 0)
+#define MI_UPDATE_GTT           MI_INSTR(0x23, 0)
+#define MI_CLFLUSH              MI_INSTR(0x27, 0)
+#define MI_REPORT_PERF_COUNT    MI_INSTR(0x28, 0)
+#define   MI_REPORT_PERF_COUNT_GGTT (1<<0)
+#define MI_LOAD_REGISTER_MEM    MI_INSTR(0x29, 0)
+#define MI_LOAD_REGISTER_REG    MI_INSTR(0x2A, 0)
+#define MI_RS_STORE_DATA_IMM    MI_INSTR(0x2B, 0)
+#define MI_LOAD_URB_MEM         MI_INSTR(0x2C, 0)
+#define MI_STORE_URB_MEM        MI_INSTR(0x2D, 0)
+#define MI_CONDITIONAL_BATCH_BUFFER_END MI_INSTR(0x36, 0)
+
+#define PIPELINE_SELECT                ((0x3<<29)|(0x1<<27)|(0x1<<24)|(0x4<<16))
+#define GFX_OP_3DSTATE_VF_STATISTICS   ((0x3<<29)|(0x1<<27)|(0x0<<24)|(0xB<<16))
+#define MEDIA_VFE_STATE                ((0x3<<29)|(0x2<<27)|(0x0<<24)|(0x0<<16))
+#define  MEDIA_VFE_STATE_MMIO_ACCESS_MASK (0x18)
+#define GPGPU_OBJECT                   ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x4<<16))
+#define GPGPU_WALKER                   ((0x3<<29)|(0x2<<27)|(0x1<<24)|(0x5<<16))
+#define GFX_OP_3DSTATE_DX9_CONSTANTF_VS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x39<<16))
+#define GFX_OP_3DSTATE_DX9_CONSTANTF_PS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x3A<<16))
+#define GFX_OP_3DSTATE_SO_DECL_LIST \
+       ((0x3<<29)|(0x3<<27)|(0x1<<24)|(0x17<<16))
+
+#define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_VS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x43<<16))
+#define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_GS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x44<<16))
+#define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_HS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x45<<16))
+#define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_DS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x46<<16))
+#define GFX_OP_3DSTATE_BINDING_TABLE_EDIT_PS \
+       ((0x3<<29)|(0x3<<27)|(0x0<<24)|(0x47<<16))
+
+#define MFX_WAIT  ((0x3<<29)|(0x1<<27)|(0x0<<16))
+
+#define COLOR_BLT     ((0x2<<29)|(0x40<<22))
+#define SRC_COPY_BLT  ((0x2<<29)|(0x43<<22))
+
+/*
+ * Registers used only by the command parser
+ */
+#define BCS_SWCTRL 0x22200
+
+#define HS_INVOCATION_COUNT 0x2300
+#define DS_INVOCATION_COUNT 0x2308
+#define IA_VERTICES_COUNT   0x2310
+#define IA_PRIMITIVES_COUNT 0x2318
+#define VS_INVOCATION_COUNT 0x2320
+#define GS_INVOCATION_COUNT 0x2328
+#define GS_PRIMITIVES_COUNT 0x2330
+#define CL_INVOCATION_COUNT 0x2338
+#define CL_PRIMITIVES_COUNT 0x2340
+#define PS_INVOCATION_COUNT 0x2348
+#define PS_DEPTH_COUNT      0x2350
+
+/* There are the 4 64-bit counter registers, one for each stream output */
+#define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
+
+#define GEN7_SO_PRIM_STORAGE_NEEDED(n)  (0x5240 + (n) * 8)
+
+#define GEN7_3DPRIM_END_OFFSET          0x2420
+#define GEN7_3DPRIM_START_VERTEX        0x2430
+#define GEN7_3DPRIM_VERTEX_COUNT        0x2434
+#define GEN7_3DPRIM_INSTANCE_COUNT      0x2438
+#define GEN7_3DPRIM_START_INSTANCE      0x243C
+#define GEN7_3DPRIM_BASE_VERTEX         0x2440
+
+#define OACONTROL 0x2360
+
+#define _GEN7_PIPEA_DE_LOAD_SL 0x70068
+#define _GEN7_PIPEB_DE_LOAD_SL 0x71068
+#define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
+                                        _GEN7_PIPEA_DE_LOAD_SL, \
+                                        _GEN7_PIPEB_DE_LOAD_SL)
 
 /*
  * Reset registers
 #define   IOSF_PORT_PUNIT                      0x4
 #define   IOSF_PORT_NC                         0x11
 #define   IOSF_PORT_DPIO                       0x12
+#define   IOSF_PORT_DPIO_2                     0x1a
 #define   IOSF_PORT_GPIO_NC                    0x13
 #define   IOSF_PORT_CCK                                0x14
 #define   IOSF_PORT_CCU                                0xA9
 /* See configdb bunit SB addr map */
 #define BUNIT_REG_BISOC                                0x11
 
-#define PUNIT_OPCODE_REG_READ                  6
-#define PUNIT_OPCODE_REG_WRITE                 7
-
 #define PUNIT_REG_DSPFREQ                      0x36
 #define   DSPFREQSTAT_SHIFT                    30
 #define   DSPFREQSTAT_MASK                     (0x3 << DSPFREQSTAT_SHIFT)
@@ -477,8 +583,6 @@ enum punit_power_well {
  * Note: digital port B is DDI0, digital pot C is DDI1
  */
 #define DPIO_DEVFN                     0
-#define DPIO_OPCODE_REG_WRITE          1
-#define DPIO_OPCODE_REG_READ           0
 
 #define DPIO_CTL                       (VLV_DISPLAY_BASE + 0x2110)
 #define  DPIO_MODSEL1                  (1<<3) /* if ref clk b == 27 */
@@ -555,14 +659,29 @@ enum punit_power_well {
 #define   DPIO_PCS_TX_LANE1_RESET      (1<<7)
 #define VLV_PCS_DW0(ch) _PORT(ch, _VLV_PCS_DW0_CH0, _VLV_PCS_DW0_CH1)
 
+#define _VLV_PCS01_DW0_CH0             0x200
+#define _VLV_PCS23_DW0_CH0             0x400
+#define _VLV_PCS01_DW0_CH1             0x2600
+#define _VLV_PCS23_DW0_CH1             0x2800
+#define VLV_PCS01_DW0(ch) _PORT(ch, _VLV_PCS01_DW0_CH0, _VLV_PCS01_DW0_CH1)
+#define VLV_PCS23_DW0(ch) _PORT(ch, _VLV_PCS23_DW0_CH0, _VLV_PCS23_DW0_CH1)
+
 #define _VLV_PCS_DW1_CH0               0x8204
 #define _VLV_PCS_DW1_CH1               0x8404
+#define   CHV_PCS_REQ_SOFTRESET_EN     (1<<23)
 #define   DPIO_PCS_CLK_CRI_RXEB_EIOS_EN        (1<<22)
 #define   DPIO_PCS_CLK_CRI_RXDIGFILTSG_EN (1<<21)
 #define   DPIO_PCS_CLK_DATAWIDTH_SHIFT (6)
 #define   DPIO_PCS_CLK_SOFT_RESET      (1<<5)
 #define VLV_PCS_DW1(ch) _PORT(ch, _VLV_PCS_DW1_CH0, _VLV_PCS_DW1_CH1)
 
+#define _VLV_PCS01_DW1_CH0             0x204
+#define _VLV_PCS23_DW1_CH0             0x404
+#define _VLV_PCS01_DW1_CH1             0x2604
+#define _VLV_PCS23_DW1_CH1             0x2804
+#define VLV_PCS01_DW1(ch) _PORT(ch, _VLV_PCS01_DW1_CH0, _VLV_PCS01_DW1_CH1)
+#define VLV_PCS23_DW1(ch) _PORT(ch, _VLV_PCS23_DW1_CH0, _VLV_PCS23_DW1_CH1)
+
 #define _VLV_PCS_DW8_CH0               0x8220
 #define _VLV_PCS_DW8_CH1               0x8420
 #define VLV_PCS_DW8(ch) _PORT(ch, _VLV_PCS_DW8_CH0, _VLV_PCS_DW8_CH1)
@@ -578,6 +697,19 @@ enum punit_power_well {
 #define _VLV_PCS_DW9_CH1               0x8424
 #define        VLV_PCS_DW9(ch) _PORT(ch, _VLV_PCS_DW9_CH0, _VLV_PCS_DW9_CH1)
 
+#define _CHV_PCS_DW10_CH0              0x8228
+#define _CHV_PCS_DW10_CH1              0x8428
+#define   DPIO_PCS_SWING_CALC_TX0_TX2  (1<<30)
+#define   DPIO_PCS_SWING_CALC_TX1_TX3  (1<<31)
+#define CHV_PCS_DW10(ch) _PORT(ch, _CHV_PCS_DW10_CH0, _CHV_PCS_DW10_CH1)
+
+#define _VLV_PCS01_DW10_CH0            0x0228
+#define _VLV_PCS23_DW10_CH0            0x0428
+#define _VLV_PCS01_DW10_CH1            0x2628
+#define _VLV_PCS23_DW10_CH1            0x2828
+#define VLV_PCS01_DW10(port) _PORT(port, _VLV_PCS01_DW10_CH0, _VLV_PCS01_DW10_CH1)
+#define VLV_PCS23_DW10(port) _PORT(port, _VLV_PCS23_DW10_CH0, _VLV_PCS23_DW10_CH1)
+
 #define _VLV_PCS_DW11_CH0              0x822c
 #define _VLV_PCS_DW11_CH1              0x842c
 #define VLV_PCS_DW11(ch) _PORT(ch, _VLV_PCS_DW11_CH0, _VLV_PCS_DW11_CH1)
@@ -596,14 +728,21 @@ enum punit_power_well {
 
 #define _VLV_TX_DW2_CH0                        0x8288
 #define _VLV_TX_DW2_CH1                        0x8488
+#define   DPIO_SWING_MARGIN_SHIFT      16
+#define   DPIO_SWING_MARGIN_MASK       (0xff << DPIO_SWING_MARGIN_SHIFT)
+#define   DPIO_UNIQ_TRANS_SCALE_SHIFT  8
 #define VLV_TX_DW2(ch) _PORT(ch, _VLV_TX_DW2_CH0, _VLV_TX_DW2_CH1)
 
 #define _VLV_TX_DW3_CH0                        0x828c
 #define _VLV_TX_DW3_CH1                        0x848c
+/* The following bit for CHV phy */
+#define   DPIO_TX_UNIQ_TRANS_SCALE_EN  (1<<27)
 #define VLV_TX_DW3(ch) _PORT(ch, _VLV_TX_DW3_CH0, _VLV_TX_DW3_CH1)
 
 #define _VLV_TX_DW4_CH0                        0x8290
 #define _VLV_TX_DW4_CH1                        0x8490
+#define   DPIO_SWING_DEEMPH9P5_SHIFT   24
+#define   DPIO_SWING_DEEMPH9P5_MASK    (0xff << DPIO_SWING_DEEMPH9P5_SHIFT)
 #define VLV_TX_DW4(ch) _PORT(ch, _VLV_TX_DW4_CH0, _VLV_TX_DW4_CH1)
 
 #define _VLV_TX3_DW4_CH0               0x690
@@ -623,6 +762,73 @@ enum punit_power_well {
 #define _VLV_TX_DW14_CH1               0x84b8
 #define VLV_TX_DW14(ch) _PORT(ch, _VLV_TX_DW14_CH0, _VLV_TX_DW14_CH1)
 
+/* CHV dpPhy registers */
+#define _CHV_PLL_DW0_CH0               0x8000
+#define _CHV_PLL_DW0_CH1               0x8180
+#define CHV_PLL_DW0(ch) _PIPE(ch, _CHV_PLL_DW0_CH0, _CHV_PLL_DW0_CH1)
+
+#define _CHV_PLL_DW1_CH0               0x8004
+#define _CHV_PLL_DW1_CH1               0x8184
+#define   DPIO_CHV_N_DIV_SHIFT         8
+#define   DPIO_CHV_M1_DIV_BY_2         (0 << 0)
+#define CHV_PLL_DW1(ch) _PIPE(ch, _CHV_PLL_DW1_CH0, _CHV_PLL_DW1_CH1)
+
+#define _CHV_PLL_DW2_CH0               0x8008
+#define _CHV_PLL_DW2_CH1               0x8188
+#define CHV_PLL_DW2(ch) _PIPE(ch, _CHV_PLL_DW2_CH0, _CHV_PLL_DW2_CH1)
+
+#define _CHV_PLL_DW3_CH0               0x800c
+#define _CHV_PLL_DW3_CH1               0x818c
+#define  DPIO_CHV_FRAC_DIV_EN          (1 << 16)
+#define  DPIO_CHV_FIRST_MOD            (0 << 8)
+#define  DPIO_CHV_SECOND_MOD           (1 << 8)
+#define  DPIO_CHV_FEEDFWD_GAIN_SHIFT   0
+#define CHV_PLL_DW3(ch) _PIPE(ch, _CHV_PLL_DW3_CH0, _CHV_PLL_DW3_CH1)
+
+#define _CHV_PLL_DW6_CH0               0x8018
+#define _CHV_PLL_DW6_CH1               0x8198
+#define   DPIO_CHV_GAIN_CTRL_SHIFT     16
+#define          DPIO_CHV_INT_COEFF_SHIFT      8
+#define   DPIO_CHV_PROP_COEFF_SHIFT    0
+#define CHV_PLL_DW6(ch) _PIPE(ch, _CHV_PLL_DW6_CH0, _CHV_PLL_DW6_CH1)
+
+#define _CHV_CMN_DW13_CH0              0x8134
+#define _CHV_CMN_DW0_CH1               0x8080
+#define   DPIO_CHV_S1_DIV_SHIFT                21
+#define   DPIO_CHV_P1_DIV_SHIFT                13 /* 3 bits */
+#define   DPIO_CHV_P2_DIV_SHIFT                8  /* 5 bits */
+#define   DPIO_CHV_K_DIV_SHIFT         4
+#define   DPIO_PLL_FREQLOCK            (1 << 1)
+#define   DPIO_PLL_LOCK                        (1 << 0)
+#define CHV_CMN_DW13(ch) _PIPE(ch, _CHV_CMN_DW13_CH0, _CHV_CMN_DW0_CH1)
+
+#define _CHV_CMN_DW14_CH0              0x8138
+#define _CHV_CMN_DW1_CH1               0x8084
+#define   DPIO_AFC_RECAL               (1 << 14)
+#define   DPIO_DCLKP_EN                        (1 << 13)
+#define CHV_CMN_DW14(ch) _PIPE(ch, _CHV_CMN_DW14_CH0, _CHV_CMN_DW1_CH1)
+
+#define CHV_CMN_DW30                   0x8178
+#define   DPIO_LRC_BYPASS              (1 << 3)
+
+#define _TXLANE(ch, lane, offset) ((ch ? 0x2400 : 0) + \
+                                       (lane) * 0x200 + (offset))
+
+#define CHV_TX_DW0(ch, lane) _TXLANE(ch, lane, 0x80)
+#define CHV_TX_DW1(ch, lane) _TXLANE(ch, lane, 0x84)
+#define CHV_TX_DW2(ch, lane) _TXLANE(ch, lane, 0x88)
+#define CHV_TX_DW3(ch, lane) _TXLANE(ch, lane, 0x8c)
+#define CHV_TX_DW4(ch, lane) _TXLANE(ch, lane, 0x90)
+#define CHV_TX_DW5(ch, lane) _TXLANE(ch, lane, 0x94)
+#define CHV_TX_DW6(ch, lane) _TXLANE(ch, lane, 0x98)
+#define CHV_TX_DW7(ch, lane) _TXLANE(ch, lane, 0x9c)
+#define CHV_TX_DW8(ch, lane) _TXLANE(ch, lane, 0xa0)
+#define CHV_TX_DW9(ch, lane) _TXLANE(ch, lane, 0xa4)
+#define CHV_TX_DW10(ch, lane) _TXLANE(ch, lane, 0xa8)
+#define CHV_TX_DW11(ch, lane) _TXLANE(ch, lane, 0xac)
+#define   DPIO_FRC_LATENCY_SHFIT       8
+#define CHV_TX_DW14(ch, lane) _TXLANE(ch, lane, 0xb8)
+#define   DPIO_UPAR_SHIFT              30
 /*
  * Fence registers
  */
@@ -663,6 +869,7 @@ enum punit_power_well {
 #define RENDER_RING_BASE       0x02000
 #define BSD_RING_BASE          0x04000
 #define GEN6_BSD_RING_BASE     0x12000
+#define GEN8_BSD2_RING_BASE    0x1c000
 #define VEBOX_RING_BASE                0x1a000
 #define BLT_RING_BASE          0x22000
 #define RING_TAIL(base)                ((base)+0x30)
@@ -688,9 +895,20 @@ enum punit_power_well {
 #define RING_MAX_IDLE(base)    ((base)+0x54)
 #define RING_HWS_PGA(base)     ((base)+0x80)
 #define RING_HWS_PGA_GEN6(base)        ((base)+0x2080)
-#define ARB_MODE               0x04030
+
+#define GEN7_WR_WATERMARK      0x4028
+#define GEN7_GFX_PRIO_CTRL     0x402C
+#define ARB_MODE               0x4030
 #define   ARB_MODE_SWIZZLE_SNB (1<<4)
 #define   ARB_MODE_SWIZZLE_IVB (1<<5)
+#define GEN7_GFX_PEND_TLB0     0x4034
+#define GEN7_GFX_PEND_TLB1     0x4038
+/* L3, CVS, ZTLB, RCC, CASC LRA min, max values */
+#define GEN7_LRA_LIMITS_BASE   0x403C
+#define GEN7_LRA_LIMITS_REG_NUM        13
+#define GEN7_MEDIA_MAX_REQ_COUNT       0x4070
+#define GEN7_GFX_MAX_REQ_COUNT         0x4074
+
 #define GAMTARBMODE            0x04a08
 #define   ARB_MODE_BWGTLB_DISABLE (1<<9)
 #define   ARB_MODE_SWIZZLE_BDW (1<<1)
@@ -725,6 +943,9 @@ enum punit_power_well {
 #define   RING_WAIT_I8XX       (1<<0) /* gen2, PRBx_HEAD */
 #define   RING_WAIT            (1<<11) /* gen3+, PRBx_CTL */
 #define   RING_WAIT_SEMAPHORE  (1<<10) /* gen6+ */
+
+#define GEN7_TLB_RD_ADDR       0x4700
+
 #if 0
 #define PRB0_TAIL      0x02030
 #define PRB0_HEAD      0x02034
@@ -748,6 +969,7 @@ enum punit_power_well {
 #define RING_INSTDONE(base)    ((base)+0x6c)
 #define RING_INSTPS(base)      ((base)+0x70)
 #define RING_DMA_FADD(base)    ((base)+0x78)
+#define RING_DMA_FADD_UDW(base)        ((base)+0x60) /* gen8+ */
 #define RING_INSTPM(base)      ((base)+0xc0)
 #define RING_MI_MODE(base)     ((base)+0x9c)
 #define INSTPS         0x02070 /* 965+ only */
@@ -827,6 +1049,7 @@ enum punit_power_well {
 # define MI_FLUSH_ENABLE                               (1 << 12)
 # define ASYNC_FLIP_PERF_DISABLE                       (1 << 14)
 # define MODE_IDLE                                     (1 << 9)
+# define STOP_RING                                     (1 << 8)
 
 #define GEN6_GT_MODE   0x20d0
 #define GEN7_GT_MODE   0x7008
@@ -841,14 +1064,17 @@ enum punit_power_well {
 #define GFX_MODE_GEN7  0x0229c
 #define RING_MODE_GEN7(ring)   ((ring)->mmio_base+0x29c)
 #define   GFX_RUN_LIST_ENABLE          (1<<15)
-#define   GFX_TLB_INVALIDATE_ALWAYS    (1<<13)
+#define   GFX_TLB_INVALIDATE_EXPLICIT  (1<<13)
 #define   GFX_SURFACE_FAULT_ENABLE     (1<<12)
 #define   GFX_REPLAY_MODE              (1<<11)
 #define   GFX_PSMI_GRANULARITY         (1<<10)
 #define   GFX_PPGTT_ENABLE             (1<<9)
 
 #define VLV_DISPLAY_BASE 0x180000
+#define VLV_MIPI_BASE VLV_DISPLAY_BASE
 
+#define VLV_GU_CTL0    (VLV_DISPLAY_BASE + 0x2030)
+#define VLV_GU_CTL1    (VLV_DISPLAY_BASE + 0x2034)
 #define SCPD0          0x0209c /* 915+ only */
 #define IER            0x020a0
 #define IIR            0x020a4
@@ -856,6 +1082,7 @@ enum punit_power_well {
 #define ISR            0x020ac
 #define VLV_GUNIT_CLOCK_GATE   (VLV_DISPLAY_BASE + 0x2060)
 #define   GCFG_DIS             (1<<8)
+#define VLV_GUNIT_CLOCK_GATE2  (VLV_DISPLAY_BASE + 0x2064)
 #define VLV_IIR_RW     (VLV_DISPLAY_BASE + 0x2084)
 #define VLV_IER                (VLV_DISPLAY_BASE + 0x20a0)
 #define VLV_IIR                (VLV_DISPLAY_BASE + 0x20a4)
@@ -972,6 +1199,7 @@ enum punit_power_well {
 #define   ECO_FLIP_DONE                (1<<0)
 
 #define CACHE_MODE_0_GEN7      0x7000 /* IVB+ */
+#define RC_OP_FLUSH_ENABLE (1<<0)
 #define   HIZ_RAW_STALL_OPT_DISABLE (1<<2)
 #define CACHE_MODE_1           0x7004 /* IVB+ */
 #define   PIXEL_SUBSPAN_COLLECT_OPT_DISABLE    (1<<6)
@@ -1023,24 +1251,43 @@ enum punit_power_well {
 
 /* These are all the "old" interrupts */
 #define ILK_BSD_USER_INTERRUPT                         (1<<5)
+
+#define I915_PM_INTERRUPT                              (1<<31)
+#define I915_ISP_INTERRUPT                             (1<<22)
+#define I915_LPE_PIPE_B_INTERRUPT                      (1<<21)
+#define I915_LPE_PIPE_A_INTERRUPT                      (1<<20)
+#define I915_MIPIB_INTERRUPT                           (1<<19)
+#define I915_MIPIA_INTERRUPT                           (1<<18)
 #define I915_PIPE_CONTROL_NOTIFY_INTERRUPT             (1<<18)
 #define I915_DISPLAY_PORT_INTERRUPT                    (1<<17)
+#define I915_DISPLAY_PIPE_C_HBLANK_INTERRUPT           (1<<16)
+#define I915_MASTER_ERROR_INTERRUPT                    (1<<15)
 #define I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT     (1<<15)
+#define I915_DISPLAY_PIPE_B_HBLANK_INTERRUPT           (1<<14)
 #define I915_GMCH_THERMAL_SENSOR_EVENT_INTERRUPT       (1<<14) /* p-state */
+#define I915_DISPLAY_PIPE_A_HBLANK_INTERRUPT           (1<<13)
 #define I915_HWB_OOM_INTERRUPT                         (1<<13)
+#define I915_LPE_PIPE_C_INTERRUPT                      (1<<12)
 #define I915_SYNC_STATUS_INTERRUPT                     (1<<12)
+#define I915_MISC_INTERRUPT                            (1<<11)
 #define I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT    (1<<11)
+#define I915_DISPLAY_PIPE_C_VBLANK_INTERRUPT           (1<<10)
 #define I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT    (1<<10)
+#define I915_DISPLAY_PIPE_C_EVENT_INTERRUPT            (1<<9)
 #define I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT      (1<<9)
+#define I915_DISPLAY_PIPE_C_DPBM_INTERRUPT             (1<<8)
 #define I915_DISPLAY_PLANE_C_FLIP_PENDING_INTERRUPT    (1<<8)
 #define I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT           (1<<7)
 #define I915_DISPLAY_PIPE_A_EVENT_INTERRUPT            (1<<6)
 #define I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT           (1<<5)
 #define I915_DISPLAY_PIPE_B_EVENT_INTERRUPT            (1<<4)
+#define I915_DISPLAY_PIPE_A_DPBM_INTERRUPT             (1<<3)
+#define I915_DISPLAY_PIPE_B_DPBM_INTERRUPT             (1<<2)
 #define I915_DEBUG_INTERRUPT                           (1<<2)
+#define I915_WINVALID_INTERRUPT                                (1<<1)
 #define I915_USER_INTERRUPT                            (1<<1)
 #define I915_ASLE_INTERRUPT                            (1<<0)
-#define I915_BSD_USER_INTERRUPT                                (1 << 25)
+#define I915_BSD_USER_INTERRUPT                                (1<<25)
 
 #define GEN6_BSD_RNCID                 0x12198
 
@@ -1197,6 +1444,7 @@ enum punit_power_well {
 #define   GMBUS_PORT_SSC       1
 #define   GMBUS_PORT_VGADDC    2
 #define   GMBUS_PORT_PANEL     3
+#define   GMBUS_PORT_DPD_CHV   3 /* HDMID_CHV */
 #define   GMBUS_PORT_DPC       4 /* HDMIC */
 #define   GMBUS_PORT_DPB       5 /* SDVO, HDMIB */
 #define   GMBUS_PORT_DPD       6 /* HDMID */
@@ -1238,6 +1486,7 @@ enum punit_power_well {
  */
 #define DPLL_A_OFFSET 0x6014
 #define DPLL_B_OFFSET 0x6018
+#define CHV_DPLL_C_OFFSET 0x6030
 #define DPLL(pipe) (dev_priv->info.dpll_offsets[pipe] + \
                    dev_priv->info.display_mmio_offset)
 
@@ -1272,10 +1521,23 @@ enum punit_power_well {
 #define   DPLL_LOCK_VLV                        (1<<15)
 #define   DPLL_INTEGRATED_CRI_CLK_VLV  (1<<14)
 #define   DPLL_INTEGRATED_CLOCK_VLV    (1<<13)
+#define   DPLL_SSC_REF_CLOCK_CHV       (1<<13)
 #define   DPLL_PORTC_READY_MASK                (0xf << 4)
 #define   DPLL_PORTB_READY_MASK                (0xf)
 
 #define   DPLL_FPA01_P1_POST_DIV_MASK_I830     0x001f0000
+
+/* Additional CHV pll/phy registers */
+#define DPIO_PHY_STATUS                        (VLV_DISPLAY_BASE + 0x6240)
+#define   DPLL_PORTD_READY_MASK                (0xf)
+#define DISPLAY_PHY_CONTROL (VLV_DISPLAY_BASE + 0x60100)
+#define   PHY_COM_LANE_RESET_DEASSERT(phy, val) \
+                               ((phy == DPIO_PHY0) ? (val | 1) : (val | 2))
+#define   PHY_COM_LANE_RESET_ASSERT(phy, val) \
+                               ((phy == DPIO_PHY0) ? (val & ~1) : (val & ~2))
+#define DISPLAY_PHY_STATUS (VLV_DISPLAY_BASE + 0x60104)
+#define   PHY_POWERGOOD(phy)   ((phy == DPIO_PHY0) ? (1<<31) : (1<<30))
+
 /*
  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
  * this field (only one bit may be set).
@@ -1316,6 +1578,7 @@ enum punit_power_well {
 
 #define DPLL_A_MD_OFFSET 0x601c /* 965+ only */
 #define DPLL_B_MD_OFFSET 0x6020 /* 965+ only */
+#define CHV_DPLL_C_MD_OFFSET 0x603c
 #define DPLL_MD(pipe) (dev_priv->info.dpll_md_offsets[pipe] + \
                       dev_priv->info.display_mmio_offset)
 
@@ -1512,6 +1775,7 @@ enum punit_power_well {
  */
 #define PALETTE_A_OFFSET 0xa000
 #define PALETTE_B_OFFSET 0xa800
+#define CHV_PALETTE_C_OFFSET 0xc000
 #define PALETTE(pipe) (dev_priv->info.palette_offsets[pipe] + \
                       dev_priv->info.display_mmio_offset)
 
@@ -2001,6 +2265,7 @@ enum punit_power_well {
 #define TRANSCODER_A_OFFSET 0x60000
 #define TRANSCODER_B_OFFSET 0x61000
 #define TRANSCODER_C_OFFSET 0x62000
+#define CHV_TRANSCODER_C_OFFSET 0x63000
 #define TRANSCODER_EDP_OFFSET 0x6f000
 
 #define _TRANSCODER2(pipe, reg) (dev_priv->info.trans_offsets[(pipe)] - \
@@ -2225,6 +2490,7 @@ enum punit_power_well {
 #define GEN3_SDVOC     0x61160
 #define GEN4_HDMIB     GEN3_SDVOB
 #define GEN4_HDMIC     GEN3_SDVOC
+#define CHV_HDMID      0x6116C
 #define PCH_SDVOB      0xe1140
 #define PCH_HDMIB      PCH_SDVOB
 #define PCH_HDMIC      0xe1150
@@ -2285,6 +2551,10 @@ enum punit_power_well {
 #define   SDVO_PIPE_SEL_CPT(pipe)              ((pipe) << 29)
 #define   SDVO_PIPE_SEL_MASK_CPT               (3 << 29)
 
+/* CHV SDVO/HDMI bits: */
+#define   SDVO_PIPE_SEL_CHV(pipe)              ((pipe) << 24)
+#define   SDVO_PIPE_SEL_MASK_CHV               (3 << 24)
+
 
 /* DVO port control */
 #define DVOA                   0x61120
@@ -3042,6 +3312,8 @@ enum punit_power_well {
 #define   DP_PORT_EN                   (1 << 31)
 #define   DP_PIPEB_SELECT              (1 << 30)
 #define   DP_PIPE_MASK                 (1 << 30)
+#define   DP_PIPE_SELECT_CHV(pipe)     ((pipe) << 16)
+#define   DP_PIPE_MASK_CHV             (3 << 16)
 
 /* Link training mode - select a suitable mode for each stage */
 #define   DP_LINK_TRAIN_PAT_1          (0 << 28)
@@ -3257,6 +3529,7 @@ enum punit_power_well {
 #define   PIPECONF_INTERLACED_DBL_ILK          (4 << 21) /* ilk/snb only */
 #define   PIPECONF_PFIT_PF_INTERLACED_DBL_ILK  (5 << 21) /* ilk/snb only */
 #define   PIPECONF_INTERLACE_MODE_MASK         (7 << 21)
+#define   PIPECONF_EDP_RR_MODE_SWITCH          (1 << 20)
 #define   PIPECONF_CXSR_DOWNCLOCK      (1<<16)
 #define   PIPECONF_COLOR_RANGE_SELECT  (1 << 13)
 #define   PIPECONF_BPC_MASK    (0x7 << 5)
@@ -3275,6 +3548,7 @@ enum punit_power_well {
 #define   SPRITE1_FLIP_DONE_INT_EN_VLV         (1UL<<30)
 #define   PIPE_CRC_ERROR_ENABLE                        (1UL<<29)
 #define   PIPE_CRC_DONE_ENABLE                 (1UL<<28)
+#define   PERF_COUNTER2_INTERRUPT_EN           (1UL<<27)
 #define   PIPE_GMBUS_EVENT_ENABLE              (1UL<<27)
 #define   PLANE_FLIP_DONE_INT_EN_VLV           (1UL<<26)
 #define   PIPE_HOTPLUG_INTERRUPT_ENABLE                (1UL<<26)
@@ -3286,8 +3560,10 @@ enum punit_power_well {
 #define   PIPE_ODD_FIELD_INTERRUPT_ENABLE      (1UL<<21)
 #define   PIPE_EVEN_FIELD_INTERRUPT_ENABLE     (1UL<<20)
 #define   PIPE_B_PSR_INTERRUPT_ENABLE_VLV      (1UL<<19)
+#define   PERF_COUNTER_INTERRUPT_EN            (1UL<<19)
 #define   PIPE_HOTPLUG_TV_INTERRUPT_ENABLE     (1UL<<18) /* pre-965 */
 #define   PIPE_START_VBLANK_INTERRUPT_ENABLE   (1UL<<18) /* 965 or later */
+#define   PIPE_FRAMESTART_INTERRUPT_ENABLE     (1UL<<17)
 #define   PIPE_VBLANK_INTERRUPT_ENABLE         (1UL<<17)
 #define   PIPEA_HBLANK_INT_EN_VLV              (1UL<<16)
 #define   PIPE_OVERLAY_UPDATED_ENABLE          (1UL<<16)
@@ -3295,6 +3571,7 @@ enum punit_power_well {
 #define   SPRITE0_FLIP_DONE_INT_STATUS_VLV     (1UL<<14)
 #define   PIPE_CRC_ERROR_INTERRUPT_STATUS      (1UL<<13)
 #define   PIPE_CRC_DONE_INTERRUPT_STATUS       (1UL<<12)
+#define   PERF_COUNTER2_INTERRUPT_STATUS       (1UL<<11)
 #define   PIPE_GMBUS_INTERRUPT_STATUS          (1UL<<11)
 #define   PLANE_FLIP_DONE_INT_STATUS_VLV       (1UL<<10)
 #define   PIPE_HOTPLUG_INTERRUPT_STATUS                (1UL<<10)
@@ -3303,20 +3580,25 @@ enum punit_power_well {
 #define   PIPE_DPST_EVENT_STATUS               (1UL<<7)
 #define   PIPE_LEGACY_BLC_EVENT_STATUS         (1UL<<6)
 #define   PIPE_A_PSR_STATUS_VLV                        (1UL<<6)
+#define   PIPE_LEGACY_BLC_EVENT_STATUS         (1UL<<6)
 #define   PIPE_ODD_FIELD_INTERRUPT_STATUS      (1UL<<5)
 #define   PIPE_EVEN_FIELD_INTERRUPT_STATUS     (1UL<<4)
 #define   PIPE_B_PSR_STATUS_VLV                        (1UL<<3)
+#define   PERF_COUNTER_INTERRUPT_STATUS                (1UL<<3)
 #define   PIPE_HOTPLUG_TV_INTERRUPT_STATUS     (1UL<<2) /* pre-965 */
 #define   PIPE_START_VBLANK_INTERRUPT_STATUS   (1UL<<2) /* 965 or later */
+#define   PIPE_FRAMESTART_INTERRUPT_STATUS     (1UL<<1)
 #define   PIPE_VBLANK_INTERRUPT_STATUS         (1UL<<1)
+#define   PIPE_HBLANK_INT_STATUS               (1UL<<0)
 #define   PIPE_OVERLAY_UPDATED_STATUS          (1UL<<0)
 
 #define PIPESTAT_INT_ENABLE_MASK               0x7fff0000
 #define PIPESTAT_INT_STATUS_MASK               0x0000ffff
 
-#define PIPE_A_OFFSET  0x70000
-#define PIPE_B_OFFSET  0x71000
-#define PIPE_C_OFFSET  0x72000
+#define PIPE_A_OFFSET          0x70000
+#define PIPE_B_OFFSET          0x71000
+#define PIPE_C_OFFSET          0x72000
+#define CHV_PIPE_C_OFFSET      0x74000
 /*
  * There's actually no pipe EDP. Some pipe registers have
  * simply shifted from the pipe to the transcoder, while
@@ -3354,14 +3636,25 @@ enum punit_power_well {
 #define   SPRITED_FLIP_DONE_INT_EN             (1<<26)
 #define   SPRITEC_FLIP_DONE_INT_EN             (1<<25)
 #define   PLANEB_FLIP_DONE_INT_EN              (1<<24)
+#define   PIPE_PSR_INT_EN                      (1<<22)
 #define   PIPEA_LINE_COMPARE_INT_EN            (1<<21)
 #define   PIPEA_HLINE_INT_EN                   (1<<20)
 #define   PIPEA_VBLANK_INT_EN                  (1<<19)
 #define   SPRITEB_FLIP_DONE_INT_EN             (1<<18)
 #define   SPRITEA_FLIP_DONE_INT_EN             (1<<17)
 #define   PLANEA_FLIPDONE_INT_EN               (1<<16)
-
-#define DPINVGTT                               (VLV_DISPLAY_BASE + 0x7002c) /* VLV only */
+#define   PIPEC_LINE_COMPARE_INT_EN            (1<<13)
+#define   PIPEC_HLINE_INT_EN                   (1<<12)
+#define   PIPEC_VBLANK_INT_EN                  (1<<11)
+#define   SPRITEF_FLIPDONE_INT_EN              (1<<10)
+#define   SPRITEE_FLIPDONE_INT_EN              (1<<9)
+#define   PLANEC_FLIPDONE_INT_EN               (1<<8)
+
+#define DPINVGTT                               (VLV_DISPLAY_BASE + 0x7002c) /* VLV/CHV only */
+#define   SPRITEF_INVALID_GTT_INT_EN           (1<<27)
+#define   SPRITEE_INVALID_GTT_INT_EN           (1<<26)
+#define   PLANEC_INVALID_GTT_INT_EN            (1<<25)
+#define   CURSORC_INVALID_GTT_INT_EN           (1<<24)
 #define   CURSORB_INVALID_GTT_INT_EN           (1<<23)
 #define   CURSORA_INVALID_GTT_INT_EN           (1<<22)
 #define   SPRITED_INVALID_GTT_INT_EN           (1<<21)
@@ -3371,6 +3664,11 @@ enum punit_power_well {
 #define   SPRITEA_INVALID_GTT_INT_EN           (1<<17)
 #define   PLANEA_INVALID_GTT_INT_EN            (1<<16)
 #define   DPINVGTT_EN_MASK                     0xff0000
+#define   DPINVGTT_EN_MASK_CHV                 0xfff0000
+#define   SPRITEF_INVALID_GTT_STATUS           (1<<11)
+#define   SPRITEE_INVALID_GTT_STATUS           (1<<10)
+#define   PLANEC_INVALID_GTT_STATUS            (1<<9)
+#define   CURSORC_INVALID_GTT_STATUS           (1<<8)
 #define   CURSORB_INVALID_GTT_STATUS           (1<<7)
 #define   CURSORA_INVALID_GTT_STATUS           (1<<6)
 #define   SPRITED_INVALID_GTT_STATUS           (1<<5)
@@ -3380,6 +3678,7 @@ enum punit_power_well {
 #define   SPRITEA_INVALID_GTT_STATUS           (1<<1)
 #define   PLANEA_INVALID_GTT_STATUS            (1<<0)
 #define   DPINVGTT_STATUS_MASK                 0xff
+#define   DPINVGTT_STATUS_MASK_CHV             0xfff
 
 #define DSPARB                 0x70030
 #define   DSPARB_CSTART_MASK   (0x7f << 7)
@@ -3419,14 +3718,43 @@ enum punit_power_well {
 #define DDL_CURSORA_PRECISION_32       (1<<31)
 #define DDL_CURSORA_PRECISION_16       (0<<31)
 #define DDL_CURSORA_SHIFT              24
+#define DDL_SPRITEB_PRECISION_32       (1<<23)
+#define DDL_SPRITEB_PRECISION_16       (0<<23)
+#define DDL_SPRITEB_SHIFT              16
+#define DDL_SPRITEA_PRECISION_32       (1<<15)
+#define DDL_SPRITEA_PRECISION_16       (0<<15)
+#define DDL_SPRITEA_SHIFT              8
 #define DDL_PLANEA_PRECISION_32                (1<<7)
 #define DDL_PLANEA_PRECISION_16                (0<<7)
+#define DDL_PLANEA_SHIFT               0
+
 #define VLV_DDL2                       (VLV_DISPLAY_BASE + 0x70054)
 #define DDL_CURSORB_PRECISION_32       (1<<31)
 #define DDL_CURSORB_PRECISION_16       (0<<31)
 #define DDL_CURSORB_SHIFT              24
+#define DDL_SPRITED_PRECISION_32       (1<<23)
+#define DDL_SPRITED_PRECISION_16       (0<<23)
+#define DDL_SPRITED_SHIFT              16
+#define DDL_SPRITEC_PRECISION_32       (1<<15)
+#define DDL_SPRITEC_PRECISION_16       (0<<15)
+#define DDL_SPRITEC_SHIFT              8
 #define DDL_PLANEB_PRECISION_32                (1<<7)
 #define DDL_PLANEB_PRECISION_16                (0<<7)
+#define DDL_PLANEB_SHIFT               0
+
+#define VLV_DDL3                       (VLV_DISPLAY_BASE + 0x70058)
+#define DDL_CURSORC_PRECISION_32       (1<<31)
+#define DDL_CURSORC_PRECISION_16       (0<<31)
+#define DDL_CURSORC_SHIFT              24
+#define DDL_SPRITEF_PRECISION_32       (1<<23)
+#define DDL_SPRITEF_PRECISION_16       (0<<23)
+#define DDL_SPRITEF_SHIFT              16
+#define DDL_SPRITEE_PRECISION_32       (1<<15)
+#define DDL_SPRITEE_PRECISION_16       (0<<15)
+#define DDL_SPRITEE_SHIFT              8
+#define DDL_PLANEC_PRECISION_32                (1<<7)
+#define DDL_PLANEC_PRECISION_16                (0<<7)
+#define DDL_PLANEC_SHIFT               0
 
 /* FIFO watermark sizes etc */
 #define G4X_FIFO_LINE_SIZE     64
@@ -3534,12 +3862,12 @@ enum punit_power_well {
 #define   PIPE_PIXEL_MASK         0x00ffffff
 #define   PIPE_PIXEL_SHIFT        0
 /* GM45+ just has to be different */
-#define _PIPEA_FRMCOUNT_GM45   (dev_priv->info.display_mmio_offset + 0x70040)
-#define _PIPEA_FLIPCOUNT_GM45  (dev_priv->info.display_mmio_offset + 0x70044)
-#define PIPE_FRMCOUNT_GM45(pipe) _PIPE(pipe, _PIPEA_FRMCOUNT_GM45, _PIPEB_FRMCOUNT_GM45)
+#define _PIPEA_FRMCOUNT_GM45   0x70040
+#define _PIPEA_FLIPCOUNT_GM45  0x70044
+#define PIPE_FRMCOUNT_GM45(pipe) _PIPE2(pipe, _PIPEA_FRMCOUNT_GM45)
 
 /* Cursor A & B regs */
-#define _CURACNTR              (dev_priv->info.display_mmio_offset + 0x70080)
+#define _CURACNTR              0x70080
 /* Old style CUR*CNTR flags (desktop 8xx) */
 #define   CURSOR_ENABLE                0x80000000
 #define   CURSOR_GAMMA_ENABLE  0x40000000
@@ -3566,28 +3894,34 @@ enum punit_power_well {
 #define   MCURSOR_PIPE_B       (1 << 28)
 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
 #define   CURSOR_TRICKLE_FEED_DISABLE  (1 << 14)
-#define _CURABASE              (dev_priv->info.display_mmio_offset + 0x70084)
-#define _CURAPOS               (dev_priv->info.display_mmio_offset + 0x70088)
+#define _CURABASE              0x70084
+#define _CURAPOS               0x70088
 #define   CURSOR_POS_MASK       0x007FF
 #define   CURSOR_POS_SIGN       0x8000
 #define   CURSOR_X_SHIFT        0
 #define   CURSOR_Y_SHIFT        16
 #define CURSIZE                        0x700a0
-#define _CURBCNTR              (dev_priv->info.display_mmio_offset + 0x700c0)
-#define _CURBBASE              (dev_priv->info.display_mmio_offset + 0x700c4)
-#define _CURBPOS               (dev_priv->info.display_mmio_offset + 0x700c8)
+#define _CURBCNTR              0x700c0
+#define _CURBBASE              0x700c4
+#define _CURBPOS               0x700c8
 
 #define _CURBCNTR_IVB          0x71080
 #define _CURBBASE_IVB          0x71084
 #define _CURBPOS_IVB           0x71088
 
-#define CURCNTR(pipe) _PIPE(pipe, _CURACNTR, _CURBCNTR)
-#define CURBASE(pipe) _PIPE(pipe, _CURABASE, _CURBBASE)
-#define CURPOS(pipe) _PIPE(pipe, _CURAPOS, _CURBPOS)
+#define _CURSOR2(pipe, reg) (dev_priv->info.cursor_offsets[(pipe)] - \
+       dev_priv->info.cursor_offsets[PIPE_A] + (reg) + \
+       dev_priv->info.display_mmio_offset)
+
+#define CURCNTR(pipe) _CURSOR2(pipe, _CURACNTR)
+#define CURBASE(pipe) _CURSOR2(pipe, _CURABASE)
+#define CURPOS(pipe) _CURSOR2(pipe, _CURAPOS)
 
-#define CURCNTR_IVB(pipe) _PIPE(pipe, _CURACNTR, _CURBCNTR_IVB)
-#define CURBASE_IVB(pipe) _PIPE(pipe, _CURABASE, _CURBBASE_IVB)
-#define CURPOS_IVB(pipe) _PIPE(pipe, _CURAPOS, _CURBPOS_IVB)
+#define CURSOR_A_OFFSET 0x70080
+#define CURSOR_B_OFFSET 0x700c0
+#define CHV_CURSOR_C_OFFSET 0x700e0
+#define IVB_CURSOR_B_OFFSET 0x71080
+#define IVB_CURSOR_C_OFFSET 0x72080
 
 /* Display A control */
 #define _DSPACNTR                              0x70180
@@ -4092,6 +4426,7 @@ enum punit_power_well {
 #define  GEN8_DE_PIPE_A_IRQ            (1<<16)
 #define  GEN8_DE_PIPE_IRQ(pipe)                (1<<(16+pipe))
 #define  GEN8_GT_VECS_IRQ              (1<<6)
+#define  GEN8_GT_PM_IRQ                        (1<<4)
 #define  GEN8_GT_VCS2_IRQ              (1<<3)
 #define  GEN8_GT_VCS1_IRQ              (1<<2)
 #define  GEN8_GT_BCS_IRQ               (1<<1)
@@ -4119,7 +4454,7 @@ enum punit_power_well {
 #define  GEN8_PIPE_SPRITE_FAULT                (1 << 9)
 #define  GEN8_PIPE_PRIMARY_FAULT       (1 << 8)
 #define  GEN8_PIPE_SPRITE_FLIP_DONE    (1 << 5)
-#define  GEN8_PIPE_FLIP_DONE           (1 << 4)
+#define  GEN8_PIPE_PRIMARY_FLIP_DONE   (1 << 4)
 #define  GEN8_PIPE_SCAN_LINE_EVENT     (1 << 2)
 #define  GEN8_PIPE_VSYNC               (1 << 1)
 #define  GEN8_PIPE_VBLANK              (1 << 0)
@@ -4831,6 +5166,8 @@ enum punit_power_well {
 #define  PORT_TRANS_SEL_CPT(pipe)      ((pipe) << 29)
 #define  PORT_TO_PIPE(val)     (((val) & (1<<30)) >> 30)
 #define  PORT_TO_PIPE_CPT(val) (((val) & PORT_TRANS_SEL_MASK) >> 29)
+#define  SDVO_PORT_TO_PIPE_CHV(val)    (((val) & (3<<24)) >> 24)
+#define  DP_PORT_TO_PIPE_CHV(val)      (((val) & (3<<16)) >> 16)
 
 #define TRANS_DP_CTL_A         0xe0300
 #define TRANS_DP_CTL_B         0xe1300
@@ -4887,6 +5224,8 @@ enum punit_power_well {
 
 #define  EDP_LINK_TRAIN_VOL_EMP_MASK_IVB       (0x3f<<22)
 
+#define  VLV_PMWGICZ                           0x1300a4
+
 #define  FORCEWAKE                             0xA18C
 #define  FORCEWAKE_VLV                         0x1300b0
 #define  FORCEWAKE_ACK_VLV                     0x1300b4
@@ -4895,15 +5234,22 @@ enum punit_power_well {
 #define  FORCEWAKE_ACK_HSW                     0x130044
 #define  FORCEWAKE_ACK                         0x130090
 #define  VLV_GTLC_WAKE_CTRL                    0x130090
+#define   VLV_GTLC_RENDER_CTX_EXISTS           (1 << 25)
+#define   VLV_GTLC_MEDIA_CTX_EXISTS            (1 << 24)
+#define   VLV_GTLC_ALLOWWAKEREQ                        (1 << 0)
+
 #define  VLV_GTLC_PW_STATUS                    0x130094
-#define VLV_GTLC_PW_RENDER_STATUS_MASK         0x80
-#define VLV_GTLC_PW_MEDIA_STATUS_MASK          0x20
+#define   VLV_GTLC_ALLOWWAKEACK                        (1 << 0)
+#define   VLV_GTLC_ALLOWWAKEERR                        (1 << 1)
+#define   VLV_GTLC_PW_MEDIA_STATUS_MASK                (1 << 5)
+#define   VLV_GTLC_PW_RENDER_STATUS_MASK       (1 << 7)
 #define  FORCEWAKE_MT                          0xa188 /* multi-threaded */
 #define   FORCEWAKE_KERNEL                     0x1
 #define   FORCEWAKE_USER                       0x2
 #define  FORCEWAKE_MT_ACK                      0x130040
 #define  ECOBUS                                        0xa180
 #define    FORCEWAKE_MT_ENABLE                 (1<<5)
+#define  VLV_SPAREG2H                          0xA194
 
 #define  GTFIFODBG                             0x120000
 #define    GT_FIFO_SBDROPERR                   (1<<6)
@@ -4933,12 +5279,19 @@ enum punit_power_well {
 # define GEN6_RCPBUNIT_CLOCK_GATE_DISABLE              (1 << 12)
 # define GEN6_RCCUNIT_CLOCK_GATE_DISABLE               (1 << 11)
 
+#define GEN6_UCGCTL3                           0x9408
+
 #define GEN7_UCGCTL4                           0x940c
 #define  GEN7_L3BANK2X_CLOCK_GATE_DISABLE      (1<<25)
 
+#define GEN6_RCGCTL1                           0x9410
+#define GEN6_RCGCTL2                           0x9414
+#define GEN6_RSTCTL                            0x9420
+
 #define GEN8_UCGCTL6                           0x9430
 #define   GEN8_SDEUNIT_CLOCK_GATE_DISABLE      (1<<14)
 
+#define GEN6_GFXPAUSE                          0xA000
 #define GEN6_RPNSWREQ                          0xA008
 #define   GEN6_TURBO_DISABLE                   (1<<31)
 #define   GEN6_FREQUENCY(x)                    ((x)<<25)
@@ -4991,6 +5344,9 @@ enum punit_power_well {
 #define GEN6_RP_UP_EI                          0xA068
 #define GEN6_RP_DOWN_EI                                0xA06C
 #define GEN6_RP_IDLE_HYSTERSIS                 0xA070
+#define GEN6_RPDEUHWTC                         0xA080
+#define GEN6_RPDEUC                            0xA084
+#define GEN6_RPDEUCSW                          0xA088
 #define GEN6_RC_STATE                          0xA094
 #define GEN6_RC1_WAKE_RATE_LIMIT               0xA098
 #define GEN6_RC6_WAKE_RATE_LIMIT               0xA09C
@@ -4998,11 +5354,15 @@ enum punit_power_well {
 #define GEN6_RC_EVALUATION_INTERVAL            0xA0A8
 #define GEN6_RC_IDLE_HYSTERSIS                 0xA0AC
 #define GEN6_RC_SLEEP                          0xA0B0
+#define GEN6_RCUBMABDTMR                       0xA0B0
 #define GEN6_RC1e_THRESHOLD                    0xA0B4
 #define GEN6_RC6_THRESHOLD                     0xA0B8
 #define GEN6_RC6p_THRESHOLD                    0xA0BC
+#define VLV_RCEDATA                            0xA0BC
 #define GEN6_RC6pp_THRESHOLD                   0xA0C0
 #define GEN6_PMINTRMSK                         0xA168
+#define GEN8_PMINTR_REDIRECT_TO_NON_DISP       (1<<31)
+#define VLV_PWRDWNUPCTL                                0xA294
 
 #define GEN6_PMISR                             0x44020
 #define GEN6_PMIMR                             0x44024 /* rps_lock */
@@ -5019,6 +5379,9 @@ enum punit_power_well {
                                                 GEN6_PM_RP_DOWN_THRESHOLD | \
                                                 GEN6_PM_RP_DOWN_TIMEOUT)
 
+#define GEN7_GT_SCRATCH_BASE                   0x4F100
+#define GEN7_GT_SCRATCH_REG_NUM                        8
+
 #define VLV_GTLC_SURVIVABILITY_REG              0x130098
 #define VLV_GFX_CLK_STATUS_BIT                 (1<<3)
 #define VLV_GFX_CLK_FORCE_ON_BIT               (1<<2)
@@ -5029,6 +5392,9 @@ enum punit_power_well {
 #define   VLV_MEDIA_RC6_COUNT_EN               (1<<1)
 #define   VLV_RENDER_RC6_COUNT_EN              (1<<0)
 #define GEN6_GT_GFX_RC6                                0x138108
+#define VLV_GT_RENDER_RC6                      0x138108
+#define VLV_GT_MEDIA_RC6                       0x13810C
+
 #define GEN6_GT_GFX_RC6p                       0x13810C
 #define GEN6_GT_GFX_RC6pp                      0x138110