18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next
128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
138c2ecf20Sopenharmony_ci * Software.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
208c2ecf20Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
218c2ecf20Sopenharmony_ci * SOFTWARE.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#ifndef _GVT_REG_H
258c2ecf20Sopenharmony_ci#define _GVT_REG_H
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define INTEL_GVT_PCI_CLASS_VGA_OTHER   0x80
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define INTEL_GVT_PCI_GMCH_CONTROL	0x50
308c2ecf20Sopenharmony_ci#define   BDW_GMCH_GMS_SHIFT		8
318c2ecf20Sopenharmony_ci#define   BDW_GMCH_GMS_MASK		0xff
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define INTEL_GVT_PCI_SWSCI		0xe8
348c2ecf20Sopenharmony_ci#define   SWSCI_SCI_SELECT		(1 << 15)
358c2ecf20Sopenharmony_ci#define   SWSCI_SCI_TRIGGER		1
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define INTEL_GVT_PCI_OPREGION		0xfc
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_CLID		0x1AC
408c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SCIC		0x200
418c2ecf20Sopenharmony_ci#define   OPREGION_SCIC_FUNC_MASK	0x1E
428c2ecf20Sopenharmony_ci#define   OPREGION_SCIC_FUNC_SHIFT	1
438c2ecf20Sopenharmony_ci#define   OPREGION_SCIC_SUBFUNC_MASK	0xFF00
448c2ecf20Sopenharmony_ci#define   OPREGION_SCIC_SUBFUNC_SHIFT	8
458c2ecf20Sopenharmony_ci#define   OPREGION_SCIC_EXIT_MASK	0xE0
468c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SCIC_F_GETBIOSDATA         4
478c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SCIC_F_GETBIOSCALLBACKS    6
488c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SCIC_SF_SUPPRTEDCALLS      0
498c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SCIC_SF_REQEUSTEDCALLBACKS 1
508c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_PARM                   0x204
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_PAGES	2
538c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_SIZE		(INTEL_GVT_OPREGION_PAGES * PAGE_SIZE)
548c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_VBT_OFFSET	0x400
558c2ecf20Sopenharmony_ci#define INTEL_GVT_OPREGION_VBT_SIZE	\
568c2ecf20Sopenharmony_ci		(INTEL_GVT_OPREGION_SIZE - INTEL_GVT_OPREGION_VBT_OFFSET)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define VGT_SPRSTRIDE(pipe)	_PIPE(pipe, _SPRA_STRIDE, _PLANE_STRIDE_2_B)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#define _REG_701C0(pipe, plane) (0x701c0 + pipe * 0x1000 + (plane - 1) * 0x100)
618c2ecf20Sopenharmony_ci#define _REG_701C4(pipe, plane) (0x701c4 + pipe * 0x1000 + (plane - 1) * 0x100)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define SKL_FLIP_EVENT(pipe, plane) (PRIMARY_A_FLIP_DONE + (plane) * 3 + (pipe))
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define PLANE_CTL_ASYNC_FLIP		(1 << 9)
668c2ecf20Sopenharmony_ci#define REG50080_FLIP_TYPE_MASK	0x3
678c2ecf20Sopenharmony_ci#define REG50080_FLIP_TYPE_ASYNC	0x1
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define REG_50080(_pipe, _plane) ({ \
708c2ecf20Sopenharmony_ci	typeof(_pipe) (p) = (_pipe); \
718c2ecf20Sopenharmony_ci	typeof(_plane) (q) = (_plane); \
728c2ecf20Sopenharmony_ci	(((p) == PIPE_A) ? (((q) == PLANE_PRIMARY) ? (_MMIO(0x50080)) : \
738c2ecf20Sopenharmony_ci		(_MMIO(0x50090))) : \
748c2ecf20Sopenharmony_ci	(((p) == PIPE_B) ? (((q) == PLANE_PRIMARY) ? (_MMIO(0x50088)) : \
758c2ecf20Sopenharmony_ci		(_MMIO(0x50098))) : \
768c2ecf20Sopenharmony_ci	(((p) == PIPE_C) ? (((q) == PLANE_PRIMARY) ? (_MMIO(0x5008C)) : \
778c2ecf20Sopenharmony_ci		(_MMIO(0x5009C))) : \
788c2ecf20Sopenharmony_ci		(_MMIO(0x50080))))); })
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define REG_50080_TO_PIPE(_reg) ({ \
818c2ecf20Sopenharmony_ci	typeof(_reg) (reg) = (_reg); \
828c2ecf20Sopenharmony_ci	(((reg) == 0x50080 || (reg) == 0x50090) ? (PIPE_A) : \
838c2ecf20Sopenharmony_ci	(((reg) == 0x50088 || (reg) == 0x50098) ? (PIPE_B) : \
848c2ecf20Sopenharmony_ci	(((reg) == 0x5008C || (reg) == 0x5009C) ? (PIPE_C) : \
858c2ecf20Sopenharmony_ci	(INVALID_PIPE)))); })
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define REG_50080_TO_PLANE(_reg) ({ \
888c2ecf20Sopenharmony_ci	typeof(_reg) (reg) = (_reg); \
898c2ecf20Sopenharmony_ci	(((reg) == 0x50080 || (reg) == 0x50088 || (reg) == 0x5008C) ? \
908c2ecf20Sopenharmony_ci		(PLANE_PRIMARY) : \
918c2ecf20Sopenharmony_ci	(((reg) == 0x50090 || (reg) == 0x50098 || (reg) == 0x5009C) ? \
928c2ecf20Sopenharmony_ci		(PLANE_SPRITE0) : (I915_MAX_PLANES))); })
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define GFX_MODE_BIT_SET_IN_MASK(val, bit) \
958c2ecf20Sopenharmony_ci		((((bit) & 0xffff0000) == 0) && !!((val) & (((bit) << 16))))
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define IS_MASKED_BITS_ENABLED(_val, _b) \
988c2ecf20Sopenharmony_ci		(((_val) & _MASKED_BIT_ENABLE(_b)) == _MASKED_BIT_ENABLE(_b))
998c2ecf20Sopenharmony_ci#define IS_MASKED_BITS_DISABLED(_val, _b) \
1008c2ecf20Sopenharmony_ci		((_val) & _MASKED_BIT_DISABLE(_b))
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define FORCEWAKE_RENDER_GEN9_REG 0xa278
1038c2ecf20Sopenharmony_ci#define FORCEWAKE_ACK_RENDER_GEN9_REG 0x0D84
1048c2ecf20Sopenharmony_ci#define FORCEWAKE_BLITTER_GEN9_REG 0xa188
1058c2ecf20Sopenharmony_ci#define FORCEWAKE_ACK_BLITTER_GEN9_REG 0x130044
1068c2ecf20Sopenharmony_ci#define FORCEWAKE_MEDIA_GEN9_REG 0xa270
1078c2ecf20Sopenharmony_ci#define FORCEWAKE_ACK_MEDIA_GEN9_REG 0x0D88
1088c2ecf20Sopenharmony_ci#define FORCEWAKE_ACK_HSW_REG 0x130044
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define RB_HEAD_WRAP_CNT_MAX	((1 << 11) - 1)
1118c2ecf20Sopenharmony_ci#define RB_HEAD_WRAP_CNT_OFF	21
1128c2ecf20Sopenharmony_ci#define RB_HEAD_OFF_MASK	((1U << 21) - (1U << 2))
1138c2ecf20Sopenharmony_ci#define RB_TAIL_OFF_MASK	((1U << 21) - (1U << 3))
1148c2ecf20Sopenharmony_ci#define RB_TAIL_SIZE_MASK	((1U << 21) - (1U << 12))
1158c2ecf20Sopenharmony_ci#define _RING_CTL_BUF_SIZE(ctl) (((ctl) & RB_TAIL_SIZE_MASK) + \
1168c2ecf20Sopenharmony_ci		I915_GTT_PAGE_SIZE)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define PCH_GPIO_BASE	_MMIO(0xc5010)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define PCH_GMBUS0	_MMIO(0xc5100)
1218c2ecf20Sopenharmony_ci#define PCH_GMBUS1	_MMIO(0xc5104)
1228c2ecf20Sopenharmony_ci#define PCH_GMBUS2	_MMIO(0xc5108)
1238c2ecf20Sopenharmony_ci#define PCH_GMBUS3	_MMIO(0xc510c)
1248c2ecf20Sopenharmony_ci#define PCH_GMBUS4	_MMIO(0xc5110)
1258c2ecf20Sopenharmony_ci#define PCH_GMBUS5	_MMIO(0xc5120)
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define TRVATTL3PTRDW(i)	_MMIO(0x4de0 + (i) * 4)
1288c2ecf20Sopenharmony_ci#define TRNULLDETCT		_MMIO(0x4de8)
1298c2ecf20Sopenharmony_ci#define TRINVTILEDETCT		_MMIO(0x4dec)
1308c2ecf20Sopenharmony_ci#define TRVADR			_MMIO(0x4df0)
1318c2ecf20Sopenharmony_ci#define TRTTE			_MMIO(0x4df4)
1328c2ecf20Sopenharmony_ci#define RING_EXCC(base)		_MMIO((base) + 0x28)
1338c2ecf20Sopenharmony_ci#define RING_GFX_MODE(base)	_MMIO((base) + 0x29c)
1348c2ecf20Sopenharmony_ci#define VF_GUARDBAND		_MMIO(0x83a4)
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#endif
137