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 * Authors:
248c2ecf20Sopenharmony_ci *    Kevin Tian <kevin.tian@intel.com>
258c2ecf20Sopenharmony_ci *    Eddie Dong <eddie.dong@intel.com>
268c2ecf20Sopenharmony_ci *    Zhiyuan Lv <zhiyuan.lv@intel.com>
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * Contributors:
298c2ecf20Sopenharmony_ci *    Min He <min.he@intel.com>
308c2ecf20Sopenharmony_ci *    Tina Zhang <tina.zhang@intel.com>
318c2ecf20Sopenharmony_ci *    Pei Zhang <pei.zhang@intel.com>
328c2ecf20Sopenharmony_ci *    Niu Bing <bing.niu@intel.com>
338c2ecf20Sopenharmony_ci *    Ping Gao <ping.a.gao@intel.com>
348c2ecf20Sopenharmony_ci *    Zhi Wang <zhi.a.wang@intel.com>
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#include "i915_drv.h"
408c2ecf20Sopenharmony_ci#include "gvt.h"
418c2ecf20Sopenharmony_ci#include "i915_pvinfo.h"
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* XXX FIXME i915 has changed PP_XXX definition */
448c2ecf20Sopenharmony_ci#define PCH_PP_STATUS  _MMIO(0xc7200)
458c2ecf20Sopenharmony_ci#define PCH_PP_CONTROL _MMIO(0xc7204)
468c2ecf20Sopenharmony_ci#define PCH_PP_ON_DELAYS _MMIO(0xc7208)
478c2ecf20Sopenharmony_ci#define PCH_PP_OFF_DELAYS _MMIO(0xc720c)
488c2ecf20Sopenharmony_ci#define PCH_PP_DIVISOR _MMIO(0xc7210)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciunsigned long intel_gvt_get_device_type(struct intel_gvt *gvt)
518c2ecf20Sopenharmony_ci{
528c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = gvt->gt->i915;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	if (IS_BROADWELL(i915))
558c2ecf20Sopenharmony_ci		return D_BDW;
568c2ecf20Sopenharmony_ci	else if (IS_SKYLAKE(i915))
578c2ecf20Sopenharmony_ci		return D_SKL;
588c2ecf20Sopenharmony_ci	else if (IS_KABYLAKE(i915))
598c2ecf20Sopenharmony_ci		return D_KBL;
608c2ecf20Sopenharmony_ci	else if (IS_BROXTON(i915))
618c2ecf20Sopenharmony_ci		return D_BXT;
628c2ecf20Sopenharmony_ci	else if (IS_COFFEELAKE(i915) || IS_COMETLAKE(i915))
638c2ecf20Sopenharmony_ci		return D_CFL;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	return 0;
668c2ecf20Sopenharmony_ci}
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cibool intel_gvt_match_device(struct intel_gvt *gvt,
698c2ecf20Sopenharmony_ci		unsigned long device)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	return intel_gvt_get_device_type(gvt) & device;
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic void read_vreg(struct intel_vgpu *vgpu, unsigned int offset,
758c2ecf20Sopenharmony_ci	void *p_data, unsigned int bytes)
768c2ecf20Sopenharmony_ci{
778c2ecf20Sopenharmony_ci	memcpy(p_data, &vgpu_vreg(vgpu, offset), bytes);
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic void write_vreg(struct intel_vgpu *vgpu, unsigned int offset,
818c2ecf20Sopenharmony_ci	void *p_data, unsigned int bytes)
828c2ecf20Sopenharmony_ci{
838c2ecf20Sopenharmony_ci	memcpy(&vgpu_vreg(vgpu, offset), p_data, bytes);
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic struct intel_gvt_mmio_info *find_mmio_info(struct intel_gvt *gvt,
878c2ecf20Sopenharmony_ci						  unsigned int offset)
888c2ecf20Sopenharmony_ci{
898c2ecf20Sopenharmony_ci	struct intel_gvt_mmio_info *e;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	hash_for_each_possible(gvt->mmio.mmio_info_table, e, node, offset) {
928c2ecf20Sopenharmony_ci		if (e->offset == offset)
938c2ecf20Sopenharmony_ci			return e;
948c2ecf20Sopenharmony_ci	}
958c2ecf20Sopenharmony_ci	return NULL;
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic int new_mmio_info(struct intel_gvt *gvt,
998c2ecf20Sopenharmony_ci		u32 offset, u8 flags, u32 size,
1008c2ecf20Sopenharmony_ci		u32 addr_mask, u32 ro_mask, u32 device,
1018c2ecf20Sopenharmony_ci		gvt_mmio_func read, gvt_mmio_func write)
1028c2ecf20Sopenharmony_ci{
1038c2ecf20Sopenharmony_ci	struct intel_gvt_mmio_info *info, *p;
1048c2ecf20Sopenharmony_ci	u32 start, end, i;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci	if (!intel_gvt_match_device(gvt, device))
1078c2ecf20Sopenharmony_ci		return 0;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	if (WARN_ON(!IS_ALIGNED(offset, 4)))
1108c2ecf20Sopenharmony_ci		return -EINVAL;
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	start = offset;
1138c2ecf20Sopenharmony_ci	end = offset + size;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	for (i = start; i < end; i += 4) {
1168c2ecf20Sopenharmony_ci		info = kzalloc(sizeof(*info), GFP_KERNEL);
1178c2ecf20Sopenharmony_ci		if (!info)
1188c2ecf20Sopenharmony_ci			return -ENOMEM;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci		info->offset = i;
1218c2ecf20Sopenharmony_ci		p = find_mmio_info(gvt, info->offset);
1228c2ecf20Sopenharmony_ci		if (p) {
1238c2ecf20Sopenharmony_ci			WARN(1, "dup mmio definition offset %x\n",
1248c2ecf20Sopenharmony_ci				info->offset);
1258c2ecf20Sopenharmony_ci			kfree(info);
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci			/* We return -EEXIST here to make GVT-g load fail.
1288c2ecf20Sopenharmony_ci			 * So duplicated MMIO can be found as soon as
1298c2ecf20Sopenharmony_ci			 * possible.
1308c2ecf20Sopenharmony_ci			 */
1318c2ecf20Sopenharmony_ci			return -EEXIST;
1328c2ecf20Sopenharmony_ci		}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci		info->ro_mask = ro_mask;
1358c2ecf20Sopenharmony_ci		info->device = device;
1368c2ecf20Sopenharmony_ci		info->read = read ? read : intel_vgpu_default_mmio_read;
1378c2ecf20Sopenharmony_ci		info->write = write ? write : intel_vgpu_default_mmio_write;
1388c2ecf20Sopenharmony_ci		gvt->mmio.mmio_attribute[info->offset / 4] = flags;
1398c2ecf20Sopenharmony_ci		INIT_HLIST_NODE(&info->node);
1408c2ecf20Sopenharmony_ci		hash_add(gvt->mmio.mmio_info_table, &info->node, info->offset);
1418c2ecf20Sopenharmony_ci		gvt->mmio.num_tracked_mmio++;
1428c2ecf20Sopenharmony_ci	}
1438c2ecf20Sopenharmony_ci	return 0;
1448c2ecf20Sopenharmony_ci}
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci/**
1478c2ecf20Sopenharmony_ci * intel_gvt_render_mmio_to_engine - convert a mmio offset into the engine
1488c2ecf20Sopenharmony_ci * @gvt: a GVT device
1498c2ecf20Sopenharmony_ci * @offset: register offset
1508c2ecf20Sopenharmony_ci *
1518c2ecf20Sopenharmony_ci * Returns:
1528c2ecf20Sopenharmony_ci * The engine containing the offset within its mmio page.
1538c2ecf20Sopenharmony_ci */
1548c2ecf20Sopenharmony_ciconst struct intel_engine_cs *
1558c2ecf20Sopenharmony_ciintel_gvt_render_mmio_to_engine(struct intel_gvt *gvt, unsigned int offset)
1568c2ecf20Sopenharmony_ci{
1578c2ecf20Sopenharmony_ci	struct intel_engine_cs *engine;
1588c2ecf20Sopenharmony_ci	enum intel_engine_id id;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	offset &= ~GENMASK(11, 0);
1618c2ecf20Sopenharmony_ci	for_each_engine(engine, gvt->gt, id)
1628c2ecf20Sopenharmony_ci		if (engine->mmio_base == offset)
1638c2ecf20Sopenharmony_ci			return engine;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	return NULL;
1668c2ecf20Sopenharmony_ci}
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#define offset_to_fence_num(offset) \
1698c2ecf20Sopenharmony_ci	((offset - i915_mmio_reg_offset(FENCE_REG_GEN6_LO(0))) >> 3)
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define fence_num_to_offset(num) \
1728c2ecf20Sopenharmony_ci	(num * 8 + i915_mmio_reg_offset(FENCE_REG_GEN6_LO(0)))
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_civoid enter_failsafe_mode(struct intel_vgpu *vgpu, int reason)
1768c2ecf20Sopenharmony_ci{
1778c2ecf20Sopenharmony_ci	switch (reason) {
1788c2ecf20Sopenharmony_ci	case GVT_FAILSAFE_UNSUPPORTED_GUEST:
1798c2ecf20Sopenharmony_ci		pr_err("Detected your guest driver doesn't support GVT-g.\n");
1808c2ecf20Sopenharmony_ci		break;
1818c2ecf20Sopenharmony_ci	case GVT_FAILSAFE_INSUFFICIENT_RESOURCE:
1828c2ecf20Sopenharmony_ci		pr_err("Graphics resource is not enough for the guest\n");
1838c2ecf20Sopenharmony_ci		break;
1848c2ecf20Sopenharmony_ci	case GVT_FAILSAFE_GUEST_ERR:
1858c2ecf20Sopenharmony_ci		pr_err("GVT Internal error  for the guest\n");
1868c2ecf20Sopenharmony_ci		break;
1878c2ecf20Sopenharmony_ci	default:
1888c2ecf20Sopenharmony_ci		break;
1898c2ecf20Sopenharmony_ci	}
1908c2ecf20Sopenharmony_ci	pr_err("Now vgpu %d will enter failsafe mode.\n", vgpu->id);
1918c2ecf20Sopenharmony_ci	vgpu->failsafe = true;
1928c2ecf20Sopenharmony_ci}
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistatic int sanitize_fence_mmio_access(struct intel_vgpu *vgpu,
1958c2ecf20Sopenharmony_ci		unsigned int fence_num, void *p_data, unsigned int bytes)
1968c2ecf20Sopenharmony_ci{
1978c2ecf20Sopenharmony_ci	unsigned int max_fence = vgpu_fence_sz(vgpu);
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	if (fence_num >= max_fence) {
2008c2ecf20Sopenharmony_ci		gvt_vgpu_err("access oob fence reg %d/%d\n",
2018c2ecf20Sopenharmony_ci			     fence_num, max_fence);
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci		/* When guest access oob fence regs without access
2048c2ecf20Sopenharmony_ci		 * pv_info first, we treat guest not supporting GVT,
2058c2ecf20Sopenharmony_ci		 * and we will let vgpu enter failsafe mode.
2068c2ecf20Sopenharmony_ci		 */
2078c2ecf20Sopenharmony_ci		if (!vgpu->pv_notified)
2088c2ecf20Sopenharmony_ci			enter_failsafe_mode(vgpu,
2098c2ecf20Sopenharmony_ci					GVT_FAILSAFE_UNSUPPORTED_GUEST);
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci		memset(p_data, 0, bytes);
2128c2ecf20Sopenharmony_ci		return -EINVAL;
2138c2ecf20Sopenharmony_ci	}
2148c2ecf20Sopenharmony_ci	return 0;
2158c2ecf20Sopenharmony_ci}
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_cistatic int gamw_echo_dev_rw_ia_write(struct intel_vgpu *vgpu,
2188c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	u32 ips = (*(u32 *)p_data) & GAMW_ECO_ENABLE_64K_IPS_FIELD;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	if (INTEL_GEN(vgpu->gvt->gt->i915) <= 10) {
2238c2ecf20Sopenharmony_ci		if (ips == GAMW_ECO_ENABLE_64K_IPS_FIELD)
2248c2ecf20Sopenharmony_ci			gvt_dbg_core("vgpu%d: ips enabled\n", vgpu->id);
2258c2ecf20Sopenharmony_ci		else if (!ips)
2268c2ecf20Sopenharmony_ci			gvt_dbg_core("vgpu%d: ips disabled\n", vgpu->id);
2278c2ecf20Sopenharmony_ci		else {
2288c2ecf20Sopenharmony_ci			/* All engines must be enabled together for vGPU,
2298c2ecf20Sopenharmony_ci			 * since we don't know which engine the ppgtt will
2308c2ecf20Sopenharmony_ci			 * bind to when shadowing.
2318c2ecf20Sopenharmony_ci			 */
2328c2ecf20Sopenharmony_ci			gvt_vgpu_err("Unsupported IPS setting %x, cannot enable 64K gtt.\n",
2338c2ecf20Sopenharmony_ci				     ips);
2348c2ecf20Sopenharmony_ci			return -EINVAL;
2358c2ecf20Sopenharmony_ci		}
2368c2ecf20Sopenharmony_ci	}
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
2398c2ecf20Sopenharmony_ci	return 0;
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cistatic int fence_mmio_read(struct intel_vgpu *vgpu, unsigned int off,
2438c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
2448c2ecf20Sopenharmony_ci{
2458c2ecf20Sopenharmony_ci	int ret;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	ret = sanitize_fence_mmio_access(vgpu, offset_to_fence_num(off),
2488c2ecf20Sopenharmony_ci			p_data, bytes);
2498c2ecf20Sopenharmony_ci	if (ret)
2508c2ecf20Sopenharmony_ci		return ret;
2518c2ecf20Sopenharmony_ci	read_vreg(vgpu, off, p_data, bytes);
2528c2ecf20Sopenharmony_ci	return 0;
2538c2ecf20Sopenharmony_ci}
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistatic int fence_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
2568c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
2578c2ecf20Sopenharmony_ci{
2588c2ecf20Sopenharmony_ci	struct intel_gvt *gvt = vgpu->gvt;
2598c2ecf20Sopenharmony_ci	unsigned int fence_num = offset_to_fence_num(off);
2608c2ecf20Sopenharmony_ci	int ret;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	ret = sanitize_fence_mmio_access(vgpu, fence_num, p_data, bytes);
2638c2ecf20Sopenharmony_ci	if (ret)
2648c2ecf20Sopenharmony_ci		return ret;
2658c2ecf20Sopenharmony_ci	write_vreg(vgpu, off, p_data, bytes);
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	mmio_hw_access_pre(gvt->gt);
2688c2ecf20Sopenharmony_ci	intel_vgpu_write_fence(vgpu, fence_num,
2698c2ecf20Sopenharmony_ci			vgpu_vreg64(vgpu, fence_num_to_offset(fence_num)));
2708c2ecf20Sopenharmony_ci	mmio_hw_access_post(gvt->gt);
2718c2ecf20Sopenharmony_ci	return 0;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci#define CALC_MODE_MASK_REG(old, new) \
2758c2ecf20Sopenharmony_ci	(((new) & GENMASK(31, 16)) \
2768c2ecf20Sopenharmony_ci	 | ((((old) & GENMASK(15, 0)) & ~((new) >> 16)) \
2778c2ecf20Sopenharmony_ci	 | ((new) & ((new) >> 16))))
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistatic int mul_force_wake_write(struct intel_vgpu *vgpu,
2808c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
2818c2ecf20Sopenharmony_ci{
2828c2ecf20Sopenharmony_ci	u32 old, new;
2838c2ecf20Sopenharmony_ci	u32 ack_reg_offset;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	old = vgpu_vreg(vgpu, offset);
2868c2ecf20Sopenharmony_ci	new = CALC_MODE_MASK_REG(old, *(u32 *)p_data);
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	if (INTEL_GEN(vgpu->gvt->gt->i915)  >=  9) {
2898c2ecf20Sopenharmony_ci		switch (offset) {
2908c2ecf20Sopenharmony_ci		case FORCEWAKE_RENDER_GEN9_REG:
2918c2ecf20Sopenharmony_ci			ack_reg_offset = FORCEWAKE_ACK_RENDER_GEN9_REG;
2928c2ecf20Sopenharmony_ci			break;
2938c2ecf20Sopenharmony_ci		case FORCEWAKE_BLITTER_GEN9_REG:
2948c2ecf20Sopenharmony_ci			ack_reg_offset = FORCEWAKE_ACK_BLITTER_GEN9_REG;
2958c2ecf20Sopenharmony_ci			break;
2968c2ecf20Sopenharmony_ci		case FORCEWAKE_MEDIA_GEN9_REG:
2978c2ecf20Sopenharmony_ci			ack_reg_offset = FORCEWAKE_ACK_MEDIA_GEN9_REG;
2988c2ecf20Sopenharmony_ci			break;
2998c2ecf20Sopenharmony_ci		default:
3008c2ecf20Sopenharmony_ci			/*should not hit here*/
3018c2ecf20Sopenharmony_ci			gvt_vgpu_err("invalid forcewake offset 0x%x\n", offset);
3028c2ecf20Sopenharmony_ci			return -EINVAL;
3038c2ecf20Sopenharmony_ci		}
3048c2ecf20Sopenharmony_ci	} else {
3058c2ecf20Sopenharmony_ci		ack_reg_offset = FORCEWAKE_ACK_HSW_REG;
3068c2ecf20Sopenharmony_ci	}
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = new;
3098c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, ack_reg_offset) = (new & GENMASK(15, 0));
3108c2ecf20Sopenharmony_ci	return 0;
3118c2ecf20Sopenharmony_ci}
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistatic int gdrst_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
3148c2ecf20Sopenharmony_ci			    void *p_data, unsigned int bytes)
3158c2ecf20Sopenharmony_ci{
3168c2ecf20Sopenharmony_ci	intel_engine_mask_t engine_mask = 0;
3178c2ecf20Sopenharmony_ci	u32 data;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
3208c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	if (data & GEN6_GRDOM_FULL) {
3238c2ecf20Sopenharmony_ci		gvt_dbg_mmio("vgpu%d: request full GPU reset\n", vgpu->id);
3248c2ecf20Sopenharmony_ci		engine_mask = ALL_ENGINES;
3258c2ecf20Sopenharmony_ci	} else {
3268c2ecf20Sopenharmony_ci		if (data & GEN6_GRDOM_RENDER) {
3278c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request RCS reset\n", vgpu->id);
3288c2ecf20Sopenharmony_ci			engine_mask |= BIT(RCS0);
3298c2ecf20Sopenharmony_ci		}
3308c2ecf20Sopenharmony_ci		if (data & GEN6_GRDOM_MEDIA) {
3318c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request VCS reset\n", vgpu->id);
3328c2ecf20Sopenharmony_ci			engine_mask |= BIT(VCS0);
3338c2ecf20Sopenharmony_ci		}
3348c2ecf20Sopenharmony_ci		if (data & GEN6_GRDOM_BLT) {
3358c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request BCS Reset\n", vgpu->id);
3368c2ecf20Sopenharmony_ci			engine_mask |= BIT(BCS0);
3378c2ecf20Sopenharmony_ci		}
3388c2ecf20Sopenharmony_ci		if (data & GEN6_GRDOM_VECS) {
3398c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request VECS Reset\n", vgpu->id);
3408c2ecf20Sopenharmony_ci			engine_mask |= BIT(VECS0);
3418c2ecf20Sopenharmony_ci		}
3428c2ecf20Sopenharmony_ci		if (data & GEN8_GRDOM_MEDIA2) {
3438c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request VCS2 Reset\n", vgpu->id);
3448c2ecf20Sopenharmony_ci			engine_mask |= BIT(VCS1);
3458c2ecf20Sopenharmony_ci		}
3468c2ecf20Sopenharmony_ci		if (data & GEN9_GRDOM_GUC) {
3478c2ecf20Sopenharmony_ci			gvt_dbg_mmio("vgpu%d: request GUC Reset\n", vgpu->id);
3488c2ecf20Sopenharmony_ci			vgpu_vreg_t(vgpu, GUC_STATUS) |= GS_MIA_IN_RESET;
3498c2ecf20Sopenharmony_ci		}
3508c2ecf20Sopenharmony_ci		engine_mask &= vgpu->gvt->gt->info.engine_mask;
3518c2ecf20Sopenharmony_ci	}
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	/* vgpu_lock already hold by emulate mmio r/w */
3548c2ecf20Sopenharmony_ci	intel_gvt_reset_vgpu_locked(vgpu, false, engine_mask);
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci	/* sw will wait for the device to ack the reset request */
3578c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = 0;
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci	return 0;
3608c2ecf20Sopenharmony_ci}
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic int gmbus_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
3638c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
3648c2ecf20Sopenharmony_ci{
3658c2ecf20Sopenharmony_ci	return intel_gvt_i2c_handle_gmbus_read(vgpu, offset, p_data, bytes);
3668c2ecf20Sopenharmony_ci}
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_cistatic int gmbus_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
3698c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
3708c2ecf20Sopenharmony_ci{
3718c2ecf20Sopenharmony_ci	return intel_gvt_i2c_handle_gmbus_write(vgpu, offset, p_data, bytes);
3728c2ecf20Sopenharmony_ci}
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_cistatic int pch_pp_control_mmio_write(struct intel_vgpu *vgpu,
3758c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
3768c2ecf20Sopenharmony_ci{
3778c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & PANEL_POWER_ON) {
3808c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PCH_PP_STATUS) |= PP_ON;
3818c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PCH_PP_STATUS) |= PP_SEQUENCE_STATE_ON_IDLE;
3828c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PCH_PP_STATUS) &= ~PP_SEQUENCE_POWER_DOWN;
3838c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PCH_PP_STATUS) &= ~PP_CYCLE_DELAY_ACTIVE;
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci	} else
3868c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PCH_PP_STATUS) &=
3878c2ecf20Sopenharmony_ci			~(PP_ON | PP_SEQUENCE_POWER_DOWN
3888c2ecf20Sopenharmony_ci					| PP_CYCLE_DELAY_ACTIVE);
3898c2ecf20Sopenharmony_ci	return 0;
3908c2ecf20Sopenharmony_ci}
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic int transconf_mmio_write(struct intel_vgpu *vgpu,
3938c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
3948c2ecf20Sopenharmony_ci{
3958c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & TRANS_ENABLE)
3988c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= TRANS_STATE_ENABLE;
3998c2ecf20Sopenharmony_ci	else
4008c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~TRANS_STATE_ENABLE;
4018c2ecf20Sopenharmony_ci	return 0;
4028c2ecf20Sopenharmony_ci}
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_cistatic int lcpll_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
4058c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
4068c2ecf20Sopenharmony_ci{
4078c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & LCPLL_PLL_DISABLE)
4108c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~LCPLL_PLL_LOCK;
4118c2ecf20Sopenharmony_ci	else
4128c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= LCPLL_PLL_LOCK;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & LCPLL_CD_SOURCE_FCLK)
4158c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= LCPLL_CD_SOURCE_FCLK_DONE;
4168c2ecf20Sopenharmony_ci	else
4178c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~LCPLL_CD_SOURCE_FCLK_DONE;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	return 0;
4208c2ecf20Sopenharmony_ci}
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_cistatic int dpy_reg_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
4238c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
4248c2ecf20Sopenharmony_ci{
4258c2ecf20Sopenharmony_ci	switch (offset) {
4268c2ecf20Sopenharmony_ci	case 0xe651c:
4278c2ecf20Sopenharmony_ci	case 0xe661c:
4288c2ecf20Sopenharmony_ci	case 0xe671c:
4298c2ecf20Sopenharmony_ci	case 0xe681c:
4308c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) = 1 << 17;
4318c2ecf20Sopenharmony_ci		break;
4328c2ecf20Sopenharmony_ci	case 0xe6c04:
4338c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) = 0x3;
4348c2ecf20Sopenharmony_ci		break;
4358c2ecf20Sopenharmony_ci	case 0xe6e1c:
4368c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) = 0x2f << 16;
4378c2ecf20Sopenharmony_ci		break;
4388c2ecf20Sopenharmony_ci	default:
4398c2ecf20Sopenharmony_ci		return -EINVAL;
4408c2ecf20Sopenharmony_ci	}
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	read_vreg(vgpu, offset, p_data, bytes);
4438c2ecf20Sopenharmony_ci	return 0;
4448c2ecf20Sopenharmony_ci}
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_cistatic int pipeconf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
4478c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
4488c2ecf20Sopenharmony_ci{
4498c2ecf20Sopenharmony_ci	u32 data;
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
4528c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	if (data & PIPECONF_ENABLE)
4558c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= I965_PIPECONF_ACTIVE;
4568c2ecf20Sopenharmony_ci	else
4578c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~I965_PIPECONF_ACTIVE;
4588c2ecf20Sopenharmony_ci	/* vgpu_lock already hold by emulate mmio r/w */
4598c2ecf20Sopenharmony_ci	mutex_unlock(&vgpu->vgpu_lock);
4608c2ecf20Sopenharmony_ci	intel_gvt_check_vblank_emulation(vgpu->gvt);
4618c2ecf20Sopenharmony_ci	mutex_lock(&vgpu->vgpu_lock);
4628c2ecf20Sopenharmony_ci	return 0;
4638c2ecf20Sopenharmony_ci}
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci/* sorted in ascending order */
4668c2ecf20Sopenharmony_cistatic i915_reg_t force_nonpriv_white_list[] = {
4678c2ecf20Sopenharmony_ci	_MMIO(0xd80),
4688c2ecf20Sopenharmony_ci	GEN9_CS_DEBUG_MODE1, //_MMIO(0x20ec)
4698c2ecf20Sopenharmony_ci	GEN9_CTX_PREEMPT_REG,//_MMIO(0x2248)
4708c2ecf20Sopenharmony_ci	CL_PRIMITIVES_COUNT, //_MMIO(0x2340)
4718c2ecf20Sopenharmony_ci	PS_INVOCATION_COUNT, //_MMIO(0x2348)
4728c2ecf20Sopenharmony_ci	PS_DEPTH_COUNT, //_MMIO(0x2350)
4738c2ecf20Sopenharmony_ci	GEN8_CS_CHICKEN1,//_MMIO(0x2580)
4748c2ecf20Sopenharmony_ci	_MMIO(0x2690),
4758c2ecf20Sopenharmony_ci	_MMIO(0x2694),
4768c2ecf20Sopenharmony_ci	_MMIO(0x2698),
4778c2ecf20Sopenharmony_ci	_MMIO(0x2754),
4788c2ecf20Sopenharmony_ci	_MMIO(0x28a0),
4798c2ecf20Sopenharmony_ci	_MMIO(0x4de0),
4808c2ecf20Sopenharmony_ci	_MMIO(0x4de4),
4818c2ecf20Sopenharmony_ci	_MMIO(0x4dfc),
4828c2ecf20Sopenharmony_ci	GEN7_COMMON_SLICE_CHICKEN1,//_MMIO(0x7010)
4838c2ecf20Sopenharmony_ci	_MMIO(0x7014),
4848c2ecf20Sopenharmony_ci	HDC_CHICKEN0,//_MMIO(0x7300)
4858c2ecf20Sopenharmony_ci	GEN8_HDC_CHICKEN1,//_MMIO(0x7304)
4868c2ecf20Sopenharmony_ci	_MMIO(0x7700),
4878c2ecf20Sopenharmony_ci	_MMIO(0x7704),
4888c2ecf20Sopenharmony_ci	_MMIO(0x7708),
4898c2ecf20Sopenharmony_ci	_MMIO(0x770c),
4908c2ecf20Sopenharmony_ci	_MMIO(0x83a8),
4918c2ecf20Sopenharmony_ci	_MMIO(0xb110),
4928c2ecf20Sopenharmony_ci	GEN8_L3SQCREG4,//_MMIO(0xb118)
4938c2ecf20Sopenharmony_ci	_MMIO(0xe100),
4948c2ecf20Sopenharmony_ci	_MMIO(0xe18c),
4958c2ecf20Sopenharmony_ci	_MMIO(0xe48c),
4968c2ecf20Sopenharmony_ci	_MMIO(0xe5f4),
4978c2ecf20Sopenharmony_ci	_MMIO(0x64844),
4988c2ecf20Sopenharmony_ci};
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci/* a simple bsearch */
5018c2ecf20Sopenharmony_cistatic inline bool in_whitelist(u32 reg)
5028c2ecf20Sopenharmony_ci{
5038c2ecf20Sopenharmony_ci	int left = 0, right = ARRAY_SIZE(force_nonpriv_white_list);
5048c2ecf20Sopenharmony_ci	i915_reg_t *array = force_nonpriv_white_list;
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci	while (left < right) {
5078c2ecf20Sopenharmony_ci		int mid = (left + right)/2;
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci		if (reg > array[mid].reg)
5108c2ecf20Sopenharmony_ci			left = mid + 1;
5118c2ecf20Sopenharmony_ci		else if (reg < array[mid].reg)
5128c2ecf20Sopenharmony_ci			right = mid;
5138c2ecf20Sopenharmony_ci		else
5148c2ecf20Sopenharmony_ci			return true;
5158c2ecf20Sopenharmony_ci	}
5168c2ecf20Sopenharmony_ci	return false;
5178c2ecf20Sopenharmony_ci}
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistatic int force_nonpriv_write(struct intel_vgpu *vgpu,
5208c2ecf20Sopenharmony_ci	unsigned int offset, void *p_data, unsigned int bytes)
5218c2ecf20Sopenharmony_ci{
5228c2ecf20Sopenharmony_ci	u32 reg_nonpriv = (*(u32 *)p_data) & REG_GENMASK(25, 2);
5238c2ecf20Sopenharmony_ci	const struct intel_engine_cs *engine =
5248c2ecf20Sopenharmony_ci		intel_gvt_render_mmio_to_engine(vgpu->gvt, offset);
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci	if (bytes != 4 || !IS_ALIGNED(offset, bytes) || !engine) {
5278c2ecf20Sopenharmony_ci		gvt_err("vgpu(%d) Invalid FORCE_NONPRIV offset %x(%dB)\n",
5288c2ecf20Sopenharmony_ci			vgpu->id, offset, bytes);
5298c2ecf20Sopenharmony_ci		return -EINVAL;
5308c2ecf20Sopenharmony_ci	}
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci	if (!in_whitelist(reg_nonpriv) &&
5338c2ecf20Sopenharmony_ci	    reg_nonpriv != i915_mmio_reg_offset(RING_NOPID(engine->mmio_base))) {
5348c2ecf20Sopenharmony_ci		gvt_err("vgpu(%d) Invalid FORCE_NONPRIV write %x at offset %x\n",
5358c2ecf20Sopenharmony_ci			vgpu->id, reg_nonpriv, offset);
5368c2ecf20Sopenharmony_ci	} else
5378c2ecf20Sopenharmony_ci		intel_vgpu_default_mmio_write(vgpu, offset, p_data, bytes);
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	return 0;
5408c2ecf20Sopenharmony_ci}
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_cistatic int ddi_buf_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
5438c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
5448c2ecf20Sopenharmony_ci{
5458c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & DDI_BUF_CTL_ENABLE) {
5488c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~DDI_BUF_IS_IDLE;
5498c2ecf20Sopenharmony_ci	} else {
5508c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= DDI_BUF_IS_IDLE;
5518c2ecf20Sopenharmony_ci		if (offset == i915_mmio_reg_offset(DDI_BUF_CTL(PORT_E)))
5528c2ecf20Sopenharmony_ci			vgpu_vreg_t(vgpu, DP_TP_STATUS(PORT_E))
5538c2ecf20Sopenharmony_ci				&= ~DP_TP_STATUS_AUTOTRAIN_DONE;
5548c2ecf20Sopenharmony_ci	}
5558c2ecf20Sopenharmony_ci	return 0;
5568c2ecf20Sopenharmony_ci}
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_cistatic int fdi_rx_iir_mmio_write(struct intel_vgpu *vgpu,
5598c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
5608c2ecf20Sopenharmony_ci{
5618c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) &= ~*(u32 *)p_data;
5628c2ecf20Sopenharmony_ci	return 0;
5638c2ecf20Sopenharmony_ci}
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci#define FDI_LINK_TRAIN_PATTERN1         0
5668c2ecf20Sopenharmony_ci#define FDI_LINK_TRAIN_PATTERN2         1
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_cistatic int fdi_auto_training_started(struct intel_vgpu *vgpu)
5698c2ecf20Sopenharmony_ci{
5708c2ecf20Sopenharmony_ci	u32 ddi_buf_ctl = vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_E));
5718c2ecf20Sopenharmony_ci	u32 rx_ctl = vgpu_vreg(vgpu, _FDI_RXA_CTL);
5728c2ecf20Sopenharmony_ci	u32 tx_ctl = vgpu_vreg_t(vgpu, DP_TP_CTL(PORT_E));
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci	if ((ddi_buf_ctl & DDI_BUF_CTL_ENABLE) &&
5758c2ecf20Sopenharmony_ci			(rx_ctl & FDI_RX_ENABLE) &&
5768c2ecf20Sopenharmony_ci			(rx_ctl & FDI_AUTO_TRAINING) &&
5778c2ecf20Sopenharmony_ci			(tx_ctl & DP_TP_CTL_ENABLE) &&
5788c2ecf20Sopenharmony_ci			(tx_ctl & DP_TP_CTL_FDI_AUTOTRAIN))
5798c2ecf20Sopenharmony_ci		return 1;
5808c2ecf20Sopenharmony_ci	else
5818c2ecf20Sopenharmony_ci		return 0;
5828c2ecf20Sopenharmony_ci}
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_cistatic int check_fdi_rx_train_status(struct intel_vgpu *vgpu,
5858c2ecf20Sopenharmony_ci		enum pipe pipe, unsigned int train_pattern)
5868c2ecf20Sopenharmony_ci{
5878c2ecf20Sopenharmony_ci	i915_reg_t fdi_rx_imr, fdi_tx_ctl, fdi_rx_ctl;
5888c2ecf20Sopenharmony_ci	unsigned int fdi_rx_check_bits, fdi_tx_check_bits;
5898c2ecf20Sopenharmony_ci	unsigned int fdi_rx_train_bits, fdi_tx_train_bits;
5908c2ecf20Sopenharmony_ci	unsigned int fdi_iir_check_bits;
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci	fdi_rx_imr = FDI_RX_IMR(pipe);
5938c2ecf20Sopenharmony_ci	fdi_tx_ctl = FDI_TX_CTL(pipe);
5948c2ecf20Sopenharmony_ci	fdi_rx_ctl = FDI_RX_CTL(pipe);
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci	if (train_pattern == FDI_LINK_TRAIN_PATTERN1) {
5978c2ecf20Sopenharmony_ci		fdi_rx_train_bits = FDI_LINK_TRAIN_PATTERN_1_CPT;
5988c2ecf20Sopenharmony_ci		fdi_tx_train_bits = FDI_LINK_TRAIN_PATTERN_1;
5998c2ecf20Sopenharmony_ci		fdi_iir_check_bits = FDI_RX_BIT_LOCK;
6008c2ecf20Sopenharmony_ci	} else if (train_pattern == FDI_LINK_TRAIN_PATTERN2) {
6018c2ecf20Sopenharmony_ci		fdi_rx_train_bits = FDI_LINK_TRAIN_PATTERN_2_CPT;
6028c2ecf20Sopenharmony_ci		fdi_tx_train_bits = FDI_LINK_TRAIN_PATTERN_2;
6038c2ecf20Sopenharmony_ci		fdi_iir_check_bits = FDI_RX_SYMBOL_LOCK;
6048c2ecf20Sopenharmony_ci	} else {
6058c2ecf20Sopenharmony_ci		gvt_vgpu_err("Invalid train pattern %d\n", train_pattern);
6068c2ecf20Sopenharmony_ci		return -EINVAL;
6078c2ecf20Sopenharmony_ci	}
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci	fdi_rx_check_bits = FDI_RX_ENABLE | fdi_rx_train_bits;
6108c2ecf20Sopenharmony_ci	fdi_tx_check_bits = FDI_TX_ENABLE | fdi_tx_train_bits;
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ci	/* If imr bit has been masked */
6138c2ecf20Sopenharmony_ci	if (vgpu_vreg_t(vgpu, fdi_rx_imr) & fdi_iir_check_bits)
6148c2ecf20Sopenharmony_ci		return 0;
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci	if (((vgpu_vreg_t(vgpu, fdi_tx_ctl) & fdi_tx_check_bits)
6178c2ecf20Sopenharmony_ci			== fdi_tx_check_bits)
6188c2ecf20Sopenharmony_ci		&& ((vgpu_vreg_t(vgpu, fdi_rx_ctl) & fdi_rx_check_bits)
6198c2ecf20Sopenharmony_ci			== fdi_rx_check_bits))
6208c2ecf20Sopenharmony_ci		return 1;
6218c2ecf20Sopenharmony_ci	else
6228c2ecf20Sopenharmony_ci		return 0;
6238c2ecf20Sopenharmony_ci}
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci#define INVALID_INDEX (~0U)
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_cistatic unsigned int calc_index(unsigned int offset, unsigned int start,
6288c2ecf20Sopenharmony_ci	unsigned int next, unsigned int end, i915_reg_t i915_end)
6298c2ecf20Sopenharmony_ci{
6308c2ecf20Sopenharmony_ci	unsigned int range = next - start;
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	if (!end)
6338c2ecf20Sopenharmony_ci		end = i915_mmio_reg_offset(i915_end);
6348c2ecf20Sopenharmony_ci	if (offset < start || offset > end)
6358c2ecf20Sopenharmony_ci		return INVALID_INDEX;
6368c2ecf20Sopenharmony_ci	offset -= start;
6378c2ecf20Sopenharmony_ci	return offset / range;
6388c2ecf20Sopenharmony_ci}
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci#define FDI_RX_CTL_TO_PIPE(offset) \
6418c2ecf20Sopenharmony_ci	calc_index(offset, _FDI_RXA_CTL, _FDI_RXB_CTL, 0, FDI_RX_CTL(PIPE_C))
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci#define FDI_TX_CTL_TO_PIPE(offset) \
6448c2ecf20Sopenharmony_ci	calc_index(offset, _FDI_TXA_CTL, _FDI_TXB_CTL, 0, FDI_TX_CTL(PIPE_C))
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_ci#define FDI_RX_IMR_TO_PIPE(offset) \
6478c2ecf20Sopenharmony_ci	calc_index(offset, _FDI_RXA_IMR, _FDI_RXB_IMR, 0, FDI_RX_IMR(PIPE_C))
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_cistatic int update_fdi_rx_iir_status(struct intel_vgpu *vgpu,
6508c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
6518c2ecf20Sopenharmony_ci{
6528c2ecf20Sopenharmony_ci	i915_reg_t fdi_rx_iir;
6538c2ecf20Sopenharmony_ci	unsigned int index;
6548c2ecf20Sopenharmony_ci	int ret;
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci	if (FDI_RX_CTL_TO_PIPE(offset) != INVALID_INDEX)
6578c2ecf20Sopenharmony_ci		index = FDI_RX_CTL_TO_PIPE(offset);
6588c2ecf20Sopenharmony_ci	else if (FDI_TX_CTL_TO_PIPE(offset) != INVALID_INDEX)
6598c2ecf20Sopenharmony_ci		index = FDI_TX_CTL_TO_PIPE(offset);
6608c2ecf20Sopenharmony_ci	else if (FDI_RX_IMR_TO_PIPE(offset) != INVALID_INDEX)
6618c2ecf20Sopenharmony_ci		index = FDI_RX_IMR_TO_PIPE(offset);
6628c2ecf20Sopenharmony_ci	else {
6638c2ecf20Sopenharmony_ci		gvt_vgpu_err("Unsupported registers %x\n", offset);
6648c2ecf20Sopenharmony_ci		return -EINVAL;
6658c2ecf20Sopenharmony_ci	}
6668c2ecf20Sopenharmony_ci
6678c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	fdi_rx_iir = FDI_RX_IIR(index);
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci	ret = check_fdi_rx_train_status(vgpu, index, FDI_LINK_TRAIN_PATTERN1);
6728c2ecf20Sopenharmony_ci	if (ret < 0)
6738c2ecf20Sopenharmony_ci		return ret;
6748c2ecf20Sopenharmony_ci	if (ret)
6758c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, fdi_rx_iir) |= FDI_RX_BIT_LOCK;
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	ret = check_fdi_rx_train_status(vgpu, index, FDI_LINK_TRAIN_PATTERN2);
6788c2ecf20Sopenharmony_ci	if (ret < 0)
6798c2ecf20Sopenharmony_ci		return ret;
6808c2ecf20Sopenharmony_ci	if (ret)
6818c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, fdi_rx_iir) |= FDI_RX_SYMBOL_LOCK;
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	if (offset == _FDI_RXA_CTL)
6848c2ecf20Sopenharmony_ci		if (fdi_auto_training_started(vgpu))
6858c2ecf20Sopenharmony_ci			vgpu_vreg_t(vgpu, DP_TP_STATUS(PORT_E)) |=
6868c2ecf20Sopenharmony_ci				DP_TP_STATUS_AUTOTRAIN_DONE;
6878c2ecf20Sopenharmony_ci	return 0;
6888c2ecf20Sopenharmony_ci}
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci#define DP_TP_CTL_TO_PORT(offset) \
6918c2ecf20Sopenharmony_ci	calc_index(offset, _DP_TP_CTL_A, _DP_TP_CTL_B, 0, DP_TP_CTL(PORT_E))
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_cistatic int dp_tp_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
6948c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
6958c2ecf20Sopenharmony_ci{
6968c2ecf20Sopenharmony_ci	i915_reg_t status_reg;
6978c2ecf20Sopenharmony_ci	unsigned int index;
6988c2ecf20Sopenharmony_ci	u32 data;
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci	index = DP_TP_CTL_TO_PORT(offset);
7038c2ecf20Sopenharmony_ci	data = (vgpu_vreg(vgpu, offset) & GENMASK(10, 8)) >> 8;
7048c2ecf20Sopenharmony_ci	if (data == 0x2) {
7058c2ecf20Sopenharmony_ci		status_reg = DP_TP_STATUS(index);
7068c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, status_reg) |= (1 << 25);
7078c2ecf20Sopenharmony_ci	}
7088c2ecf20Sopenharmony_ci	return 0;
7098c2ecf20Sopenharmony_ci}
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_cistatic int dp_tp_status_mmio_write(struct intel_vgpu *vgpu,
7128c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
7138c2ecf20Sopenharmony_ci{
7148c2ecf20Sopenharmony_ci	u32 reg_val;
7158c2ecf20Sopenharmony_ci	u32 sticky_mask;
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci	reg_val = *((u32 *)p_data);
7188c2ecf20Sopenharmony_ci	sticky_mask = GENMASK(27, 26) | (1 << 24);
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = (reg_val & ~sticky_mask) |
7218c2ecf20Sopenharmony_ci		(vgpu_vreg(vgpu, offset) & sticky_mask);
7228c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) &= ~(reg_val & sticky_mask);
7238c2ecf20Sopenharmony_ci	return 0;
7248c2ecf20Sopenharmony_ci}
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_cistatic int pch_adpa_mmio_write(struct intel_vgpu *vgpu,
7278c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
7288c2ecf20Sopenharmony_ci{
7298c2ecf20Sopenharmony_ci	u32 data;
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
7328c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci	if (data & ADPA_CRT_HOTPLUG_FORCE_TRIGGER)
7358c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
7368c2ecf20Sopenharmony_ci	return 0;
7378c2ecf20Sopenharmony_ci}
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_cistatic int south_chicken2_mmio_write(struct intel_vgpu *vgpu,
7408c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
7418c2ecf20Sopenharmony_ci{
7428c2ecf20Sopenharmony_ci	u32 data;
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
7458c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci	if (data & FDI_MPHY_IOSFSB_RESET_CTL)
7488c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= FDI_MPHY_IOSFSB_RESET_STATUS;
7498c2ecf20Sopenharmony_ci	else
7508c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~FDI_MPHY_IOSFSB_RESET_STATUS;
7518c2ecf20Sopenharmony_ci	return 0;
7528c2ecf20Sopenharmony_ci}
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci#define DSPSURF_TO_PIPE(offset) \
7558c2ecf20Sopenharmony_ci	calc_index(offset, _DSPASURF, _DSPBSURF, 0, DSPSURF(PIPE_C))
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_cistatic int pri_surf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
7588c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
7598c2ecf20Sopenharmony_ci{
7608c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
7618c2ecf20Sopenharmony_ci	u32 pipe = DSPSURF_TO_PIPE(offset);
7628c2ecf20Sopenharmony_ci	int event = SKL_FLIP_EVENT(pipe, PLANE_PRIMARY);
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
7658c2ecf20Sopenharmony_ci	vgpu_vreg_t(vgpu, DSPSURFLIVE(pipe)) = vgpu_vreg(vgpu, offset);
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_ci	vgpu_vreg_t(vgpu, PIPE_FLIPCOUNT_G4X(pipe))++;
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_ci	if (vgpu_vreg_t(vgpu, DSPCNTR(pipe)) & PLANE_CTL_ASYNC_FLIP)
7708c2ecf20Sopenharmony_ci		intel_vgpu_trigger_virtual_event(vgpu, event);
7718c2ecf20Sopenharmony_ci	else
7728c2ecf20Sopenharmony_ci		set_bit(event, vgpu->irq.flip_done_event[pipe]);
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci	return 0;
7758c2ecf20Sopenharmony_ci}
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci#define SPRSURF_TO_PIPE(offset) \
7788c2ecf20Sopenharmony_ci	calc_index(offset, _SPRA_SURF, _SPRB_SURF, 0, SPRSURF(PIPE_C))
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_cistatic int spr_surf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
7818c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
7828c2ecf20Sopenharmony_ci{
7838c2ecf20Sopenharmony_ci	u32 pipe = SPRSURF_TO_PIPE(offset);
7848c2ecf20Sopenharmony_ci	int event = SKL_FLIP_EVENT(pipe, PLANE_SPRITE0);
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
7878c2ecf20Sopenharmony_ci	vgpu_vreg_t(vgpu, SPRSURFLIVE(pipe)) = vgpu_vreg(vgpu, offset);
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci	if (vgpu_vreg_t(vgpu, SPRCTL(pipe)) & PLANE_CTL_ASYNC_FLIP)
7908c2ecf20Sopenharmony_ci		intel_vgpu_trigger_virtual_event(vgpu, event);
7918c2ecf20Sopenharmony_ci	else
7928c2ecf20Sopenharmony_ci		set_bit(event, vgpu->irq.flip_done_event[pipe]);
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci	return 0;
7958c2ecf20Sopenharmony_ci}
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_cistatic int reg50080_mmio_write(struct intel_vgpu *vgpu,
7988c2ecf20Sopenharmony_ci			       unsigned int offset, void *p_data,
7998c2ecf20Sopenharmony_ci			       unsigned int bytes)
8008c2ecf20Sopenharmony_ci{
8018c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
8028c2ecf20Sopenharmony_ci	enum pipe pipe = REG_50080_TO_PIPE(offset);
8038c2ecf20Sopenharmony_ci	enum plane_id plane = REG_50080_TO_PLANE(offset);
8048c2ecf20Sopenharmony_ci	int event = SKL_FLIP_EVENT(pipe, plane);
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
8078c2ecf20Sopenharmony_ci	if (plane == PLANE_PRIMARY) {
8088c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, DSPSURFLIVE(pipe)) = vgpu_vreg(vgpu, offset);
8098c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, PIPE_FLIPCOUNT_G4X(pipe))++;
8108c2ecf20Sopenharmony_ci	} else {
8118c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, SPRSURFLIVE(pipe)) = vgpu_vreg(vgpu, offset);
8128c2ecf20Sopenharmony_ci	}
8138c2ecf20Sopenharmony_ci
8148c2ecf20Sopenharmony_ci	if ((vgpu_vreg(vgpu, offset) & REG50080_FLIP_TYPE_MASK) == REG50080_FLIP_TYPE_ASYNC)
8158c2ecf20Sopenharmony_ci		intel_vgpu_trigger_virtual_event(vgpu, event);
8168c2ecf20Sopenharmony_ci	else
8178c2ecf20Sopenharmony_ci		set_bit(event, vgpu->irq.flip_done_event[pipe]);
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci	return 0;
8208c2ecf20Sopenharmony_ci}
8218c2ecf20Sopenharmony_ci
8228c2ecf20Sopenharmony_cistatic int trigger_aux_channel_interrupt(struct intel_vgpu *vgpu,
8238c2ecf20Sopenharmony_ci		unsigned int reg)
8248c2ecf20Sopenharmony_ci{
8258c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
8268c2ecf20Sopenharmony_ci	enum intel_gvt_event_type event;
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_ci	if (reg == i915_mmio_reg_offset(DP_AUX_CH_CTL(AUX_CH_A)))
8298c2ecf20Sopenharmony_ci		event = AUX_CHANNEL_A;
8308c2ecf20Sopenharmony_ci	else if (reg == _PCH_DPB_AUX_CH_CTL ||
8318c2ecf20Sopenharmony_ci		 reg == i915_mmio_reg_offset(DP_AUX_CH_CTL(AUX_CH_B)))
8328c2ecf20Sopenharmony_ci		event = AUX_CHANNEL_B;
8338c2ecf20Sopenharmony_ci	else if (reg == _PCH_DPC_AUX_CH_CTL ||
8348c2ecf20Sopenharmony_ci		 reg == i915_mmio_reg_offset(DP_AUX_CH_CTL(AUX_CH_C)))
8358c2ecf20Sopenharmony_ci		event = AUX_CHANNEL_C;
8368c2ecf20Sopenharmony_ci	else if (reg == _PCH_DPD_AUX_CH_CTL ||
8378c2ecf20Sopenharmony_ci		 reg == i915_mmio_reg_offset(DP_AUX_CH_CTL(AUX_CH_D)))
8388c2ecf20Sopenharmony_ci		event = AUX_CHANNEL_D;
8398c2ecf20Sopenharmony_ci	else {
8408c2ecf20Sopenharmony_ci		drm_WARN_ON(&dev_priv->drm, true);
8418c2ecf20Sopenharmony_ci		return -EINVAL;
8428c2ecf20Sopenharmony_ci	}
8438c2ecf20Sopenharmony_ci
8448c2ecf20Sopenharmony_ci	intel_vgpu_trigger_virtual_event(vgpu, event);
8458c2ecf20Sopenharmony_ci	return 0;
8468c2ecf20Sopenharmony_ci}
8478c2ecf20Sopenharmony_ci
8488c2ecf20Sopenharmony_cistatic int dp_aux_ch_ctl_trans_done(struct intel_vgpu *vgpu, u32 value,
8498c2ecf20Sopenharmony_ci		unsigned int reg, int len, bool data_valid)
8508c2ecf20Sopenharmony_ci{
8518c2ecf20Sopenharmony_ci	/* mark transaction done */
8528c2ecf20Sopenharmony_ci	value |= DP_AUX_CH_CTL_DONE;
8538c2ecf20Sopenharmony_ci	value &= ~DP_AUX_CH_CTL_SEND_BUSY;
8548c2ecf20Sopenharmony_ci	value &= ~DP_AUX_CH_CTL_RECEIVE_ERROR;
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci	if (data_valid)
8578c2ecf20Sopenharmony_ci		value &= ~DP_AUX_CH_CTL_TIME_OUT_ERROR;
8588c2ecf20Sopenharmony_ci	else
8598c2ecf20Sopenharmony_ci		value |= DP_AUX_CH_CTL_TIME_OUT_ERROR;
8608c2ecf20Sopenharmony_ci
8618c2ecf20Sopenharmony_ci	/* message size */
8628c2ecf20Sopenharmony_ci	value &= ~(0xf << 20);
8638c2ecf20Sopenharmony_ci	value |= (len << 20);
8648c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, reg) = value;
8658c2ecf20Sopenharmony_ci
8668c2ecf20Sopenharmony_ci	if (value & DP_AUX_CH_CTL_INTERRUPT)
8678c2ecf20Sopenharmony_ci		return trigger_aux_channel_interrupt(vgpu, reg);
8688c2ecf20Sopenharmony_ci	return 0;
8698c2ecf20Sopenharmony_ci}
8708c2ecf20Sopenharmony_ci
8718c2ecf20Sopenharmony_cistatic void dp_aux_ch_ctl_link_training(struct intel_vgpu_dpcd_data *dpcd,
8728c2ecf20Sopenharmony_ci		u8 t)
8738c2ecf20Sopenharmony_ci{
8748c2ecf20Sopenharmony_ci	if ((t & DPCD_TRAINING_PATTERN_SET_MASK) == DPCD_TRAINING_PATTERN_1) {
8758c2ecf20Sopenharmony_ci		/* training pattern 1 for CR */
8768c2ecf20Sopenharmony_ci		/* set LANE0_CR_DONE, LANE1_CR_DONE */
8778c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE0_1_STATUS] |= DPCD_LANES_CR_DONE;
8788c2ecf20Sopenharmony_ci		/* set LANE2_CR_DONE, LANE3_CR_DONE */
8798c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE2_3_STATUS] |= DPCD_LANES_CR_DONE;
8808c2ecf20Sopenharmony_ci	} else if ((t & DPCD_TRAINING_PATTERN_SET_MASK) ==
8818c2ecf20Sopenharmony_ci			DPCD_TRAINING_PATTERN_2) {
8828c2ecf20Sopenharmony_ci		/* training pattern 2 for EQ */
8838c2ecf20Sopenharmony_ci		/* Set CHANNEL_EQ_DONE and  SYMBOL_LOCKED for Lane0_1 */
8848c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE0_1_STATUS] |= DPCD_LANES_EQ_DONE;
8858c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE0_1_STATUS] |= DPCD_SYMBOL_LOCKED;
8868c2ecf20Sopenharmony_ci		/* Set CHANNEL_EQ_DONE and  SYMBOL_LOCKED for Lane2_3 */
8878c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE2_3_STATUS] |= DPCD_LANES_EQ_DONE;
8888c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE2_3_STATUS] |= DPCD_SYMBOL_LOCKED;
8898c2ecf20Sopenharmony_ci		/* set INTERLANE_ALIGN_DONE */
8908c2ecf20Sopenharmony_ci		dpcd->data[DPCD_LANE_ALIGN_STATUS_UPDATED] |=
8918c2ecf20Sopenharmony_ci			DPCD_INTERLANE_ALIGN_DONE;
8928c2ecf20Sopenharmony_ci	} else if ((t & DPCD_TRAINING_PATTERN_SET_MASK) ==
8938c2ecf20Sopenharmony_ci			DPCD_LINK_TRAINING_DISABLED) {
8948c2ecf20Sopenharmony_ci		/* finish link training */
8958c2ecf20Sopenharmony_ci		/* set sink status as synchronized */
8968c2ecf20Sopenharmony_ci		dpcd->data[DPCD_SINK_STATUS] = DPCD_SINK_IN_SYNC;
8978c2ecf20Sopenharmony_ci	}
8988c2ecf20Sopenharmony_ci}
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci#define _REG_HSW_DP_AUX_CH_CTL(dp) \
9018c2ecf20Sopenharmony_ci	((dp) ? (_PCH_DPB_AUX_CH_CTL + ((dp)-1)*0x100) : 0x64010)
9028c2ecf20Sopenharmony_ci
9038c2ecf20Sopenharmony_ci#define _REG_SKL_DP_AUX_CH_CTL(dp) (0x64010 + (dp) * 0x100)
9048c2ecf20Sopenharmony_ci
9058c2ecf20Sopenharmony_ci#define OFFSET_TO_DP_AUX_PORT(offset) (((offset) & 0xF00) >> 8)
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci#define dpy_is_valid_port(port)	\
9088c2ecf20Sopenharmony_ci		(((port) >= PORT_A) && ((port) < I915_MAX_PORTS))
9098c2ecf20Sopenharmony_ci
9108c2ecf20Sopenharmony_cistatic int dp_aux_ch_ctl_mmio_write(struct intel_vgpu *vgpu,
9118c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
9128c2ecf20Sopenharmony_ci{
9138c2ecf20Sopenharmony_ci	struct intel_vgpu_display *display = &vgpu->display;
9148c2ecf20Sopenharmony_ci	int msg, addr, ctrl, op, len;
9158c2ecf20Sopenharmony_ci	int port_index = OFFSET_TO_DP_AUX_PORT(offset);
9168c2ecf20Sopenharmony_ci	struct intel_vgpu_dpcd_data *dpcd = NULL;
9178c2ecf20Sopenharmony_ci	struct intel_vgpu_port *port = NULL;
9188c2ecf20Sopenharmony_ci	u32 data;
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_ci	if (!dpy_is_valid_port(port_index)) {
9218c2ecf20Sopenharmony_ci		gvt_vgpu_err("Unsupported DP port access!\n");
9228c2ecf20Sopenharmony_ci		return 0;
9238c2ecf20Sopenharmony_ci	}
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
9268c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_ci	if ((INTEL_GEN(vgpu->gvt->gt->i915) >= 9)
9298c2ecf20Sopenharmony_ci		&& offset != _REG_SKL_DP_AUX_CH_CTL(port_index)) {
9308c2ecf20Sopenharmony_ci		/* SKL DPB/C/D aux ctl register changed */
9318c2ecf20Sopenharmony_ci		return 0;
9328c2ecf20Sopenharmony_ci	} else if (IS_BROADWELL(vgpu->gvt->gt->i915) &&
9338c2ecf20Sopenharmony_ci		   offset != _REG_HSW_DP_AUX_CH_CTL(port_index)) {
9348c2ecf20Sopenharmony_ci		/* write to the data registers */
9358c2ecf20Sopenharmony_ci		return 0;
9368c2ecf20Sopenharmony_ci	}
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ci	if (!(data & DP_AUX_CH_CTL_SEND_BUSY)) {
9398c2ecf20Sopenharmony_ci		/* just want to clear the sticky bits */
9408c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) = 0;
9418c2ecf20Sopenharmony_ci		return 0;
9428c2ecf20Sopenharmony_ci	}
9438c2ecf20Sopenharmony_ci
9448c2ecf20Sopenharmony_ci	port = &display->ports[port_index];
9458c2ecf20Sopenharmony_ci	dpcd = port->dpcd;
9468c2ecf20Sopenharmony_ci
9478c2ecf20Sopenharmony_ci	/* read out message from DATA1 register */
9488c2ecf20Sopenharmony_ci	msg = vgpu_vreg(vgpu, offset + 4);
9498c2ecf20Sopenharmony_ci	addr = (msg >> 8) & 0xffff;
9508c2ecf20Sopenharmony_ci	ctrl = (msg >> 24) & 0xff;
9518c2ecf20Sopenharmony_ci	len = msg & 0xff;
9528c2ecf20Sopenharmony_ci	op = ctrl >> 4;
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ci	if (op == GVT_AUX_NATIVE_WRITE) {
9558c2ecf20Sopenharmony_ci		int t;
9568c2ecf20Sopenharmony_ci		u8 buf[16];
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_ci		if ((addr + len + 1) >= DPCD_SIZE) {
9598c2ecf20Sopenharmony_ci			/*
9608c2ecf20Sopenharmony_ci			 * Write request exceeds what we supported,
9618c2ecf20Sopenharmony_ci			 * DCPD spec: When a Source Device is writing a DPCD
9628c2ecf20Sopenharmony_ci			 * address not supported by the Sink Device, the Sink
9638c2ecf20Sopenharmony_ci			 * Device shall reply with AUX NACK and “M” equal to
9648c2ecf20Sopenharmony_ci			 * zero.
9658c2ecf20Sopenharmony_ci			 */
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci			/* NAK the write */
9688c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 4) = AUX_NATIVE_REPLY_NAK;
9698c2ecf20Sopenharmony_ci			dp_aux_ch_ctl_trans_done(vgpu, data, offset, 2, true);
9708c2ecf20Sopenharmony_ci			return 0;
9718c2ecf20Sopenharmony_ci		}
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_ci		/*
9748c2ecf20Sopenharmony_ci		 * Write request format: Headr (command + address + size) occupies
9758c2ecf20Sopenharmony_ci		 * 4 bytes, followed by (len + 1) bytes of data. See details at
9768c2ecf20Sopenharmony_ci		 * intel_dp_aux_transfer().
9778c2ecf20Sopenharmony_ci		 */
9788c2ecf20Sopenharmony_ci		if ((len + 1 + 4) > AUX_BURST_SIZE) {
9798c2ecf20Sopenharmony_ci			gvt_vgpu_err("dp_aux_header: len %d is too large\n", len);
9808c2ecf20Sopenharmony_ci			return -EINVAL;
9818c2ecf20Sopenharmony_ci		}
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci		/* unpack data from vreg to buf */
9848c2ecf20Sopenharmony_ci		for (t = 0; t < 4; t++) {
9858c2ecf20Sopenharmony_ci			u32 r = vgpu_vreg(vgpu, offset + 8 + t * 4);
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci			buf[t * 4] = (r >> 24) & 0xff;
9888c2ecf20Sopenharmony_ci			buf[t * 4 + 1] = (r >> 16) & 0xff;
9898c2ecf20Sopenharmony_ci			buf[t * 4 + 2] = (r >> 8) & 0xff;
9908c2ecf20Sopenharmony_ci			buf[t * 4 + 3] = r & 0xff;
9918c2ecf20Sopenharmony_ci		}
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ci		/* write to virtual DPCD */
9948c2ecf20Sopenharmony_ci		if (dpcd && dpcd->data_valid) {
9958c2ecf20Sopenharmony_ci			for (t = 0; t <= len; t++) {
9968c2ecf20Sopenharmony_ci				int p = addr + t;
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_ci				dpcd->data[p] = buf[t];
9998c2ecf20Sopenharmony_ci				/* check for link training */
10008c2ecf20Sopenharmony_ci				if (p == DPCD_TRAINING_PATTERN_SET)
10018c2ecf20Sopenharmony_ci					dp_aux_ch_ctl_link_training(dpcd,
10028c2ecf20Sopenharmony_ci							buf[t]);
10038c2ecf20Sopenharmony_ci			}
10048c2ecf20Sopenharmony_ci		}
10058c2ecf20Sopenharmony_ci
10068c2ecf20Sopenharmony_ci		/* ACK the write */
10078c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset + 4) = 0;
10088c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_trans_done(vgpu, data, offset, 1,
10098c2ecf20Sopenharmony_ci				dpcd && dpcd->data_valid);
10108c2ecf20Sopenharmony_ci		return 0;
10118c2ecf20Sopenharmony_ci	}
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci	if (op == GVT_AUX_NATIVE_READ) {
10148c2ecf20Sopenharmony_ci		int idx, i, ret = 0;
10158c2ecf20Sopenharmony_ci
10168c2ecf20Sopenharmony_ci		if ((addr + len + 1) >= DPCD_SIZE) {
10178c2ecf20Sopenharmony_ci			/*
10188c2ecf20Sopenharmony_ci			 * read request exceeds what we supported
10198c2ecf20Sopenharmony_ci			 * DPCD spec: A Sink Device receiving a Native AUX CH
10208c2ecf20Sopenharmony_ci			 * read request for an unsupported DPCD address must
10218c2ecf20Sopenharmony_ci			 * reply with an AUX ACK and read data set equal to
10228c2ecf20Sopenharmony_ci			 * zero instead of replying with AUX NACK.
10238c2ecf20Sopenharmony_ci			 */
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci			/* ACK the READ*/
10268c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 4) = 0;
10278c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 8) = 0;
10288c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 12) = 0;
10298c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 16) = 0;
10308c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 20) = 0;
10318c2ecf20Sopenharmony_ci
10328c2ecf20Sopenharmony_ci			dp_aux_ch_ctl_trans_done(vgpu, data, offset, len + 2,
10338c2ecf20Sopenharmony_ci					true);
10348c2ecf20Sopenharmony_ci			return 0;
10358c2ecf20Sopenharmony_ci		}
10368c2ecf20Sopenharmony_ci
10378c2ecf20Sopenharmony_ci		for (idx = 1; idx <= 5; idx++) {
10388c2ecf20Sopenharmony_ci			/* clear the data registers */
10398c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset + 4 * idx) = 0;
10408c2ecf20Sopenharmony_ci		}
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci		/*
10438c2ecf20Sopenharmony_ci		 * Read reply format: ACK (1 byte) plus (len + 1) bytes of data.
10448c2ecf20Sopenharmony_ci		 */
10458c2ecf20Sopenharmony_ci		if ((len + 2) > AUX_BURST_SIZE) {
10468c2ecf20Sopenharmony_ci			gvt_vgpu_err("dp_aux_header: len %d is too large\n", len);
10478c2ecf20Sopenharmony_ci			return -EINVAL;
10488c2ecf20Sopenharmony_ci		}
10498c2ecf20Sopenharmony_ci
10508c2ecf20Sopenharmony_ci		/* read from virtual DPCD to vreg */
10518c2ecf20Sopenharmony_ci		/* first 4 bytes: [ACK][addr][addr+1][addr+2] */
10528c2ecf20Sopenharmony_ci		if (dpcd && dpcd->data_valid) {
10538c2ecf20Sopenharmony_ci			for (i = 1; i <= (len + 1); i++) {
10548c2ecf20Sopenharmony_ci				int t;
10558c2ecf20Sopenharmony_ci
10568c2ecf20Sopenharmony_ci				t = dpcd->data[addr + i - 1];
10578c2ecf20Sopenharmony_ci				t <<= (24 - 8 * (i % 4));
10588c2ecf20Sopenharmony_ci				ret |= t;
10598c2ecf20Sopenharmony_ci
10608c2ecf20Sopenharmony_ci				if ((i % 4 == 3) || (i == (len + 1))) {
10618c2ecf20Sopenharmony_ci					vgpu_vreg(vgpu, offset +
10628c2ecf20Sopenharmony_ci							(i / 4 + 1) * 4) = ret;
10638c2ecf20Sopenharmony_ci					ret = 0;
10648c2ecf20Sopenharmony_ci				}
10658c2ecf20Sopenharmony_ci			}
10668c2ecf20Sopenharmony_ci		}
10678c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_trans_done(vgpu, data, offset, len + 2,
10688c2ecf20Sopenharmony_ci				dpcd && dpcd->data_valid);
10698c2ecf20Sopenharmony_ci		return 0;
10708c2ecf20Sopenharmony_ci	}
10718c2ecf20Sopenharmony_ci
10728c2ecf20Sopenharmony_ci	/* i2c transaction starts */
10738c2ecf20Sopenharmony_ci	intel_gvt_i2c_handle_aux_ch_write(vgpu, port_index, offset, p_data);
10748c2ecf20Sopenharmony_ci
10758c2ecf20Sopenharmony_ci	if (data & DP_AUX_CH_CTL_INTERRUPT)
10768c2ecf20Sopenharmony_ci		trigger_aux_channel_interrupt(vgpu, offset);
10778c2ecf20Sopenharmony_ci	return 0;
10788c2ecf20Sopenharmony_ci}
10798c2ecf20Sopenharmony_ci
10808c2ecf20Sopenharmony_cistatic int mbctl_write(struct intel_vgpu *vgpu, unsigned int offset,
10818c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
10828c2ecf20Sopenharmony_ci{
10838c2ecf20Sopenharmony_ci	*(u32 *)p_data &= (~GEN6_MBCTL_ENABLE_BOOT_FETCH);
10848c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
10858c2ecf20Sopenharmony_ci	return 0;
10868c2ecf20Sopenharmony_ci}
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_cistatic int vga_control_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
10898c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
10908c2ecf20Sopenharmony_ci{
10918c2ecf20Sopenharmony_ci	bool vga_disable;
10928c2ecf20Sopenharmony_ci
10938c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
10948c2ecf20Sopenharmony_ci	vga_disable = vgpu_vreg(vgpu, offset) & VGA_DISP_DISABLE;
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci	gvt_dbg_core("vgpu%d: %s VGA mode\n", vgpu->id,
10978c2ecf20Sopenharmony_ci			vga_disable ? "Disable" : "Enable");
10988c2ecf20Sopenharmony_ci	return 0;
10998c2ecf20Sopenharmony_ci}
11008c2ecf20Sopenharmony_ci
11018c2ecf20Sopenharmony_cistatic u32 read_virtual_sbi_register(struct intel_vgpu *vgpu,
11028c2ecf20Sopenharmony_ci		unsigned int sbi_offset)
11038c2ecf20Sopenharmony_ci{
11048c2ecf20Sopenharmony_ci	struct intel_vgpu_display *display = &vgpu->display;
11058c2ecf20Sopenharmony_ci	int num = display->sbi.number;
11068c2ecf20Sopenharmony_ci	int i;
11078c2ecf20Sopenharmony_ci
11088c2ecf20Sopenharmony_ci	for (i = 0; i < num; ++i)
11098c2ecf20Sopenharmony_ci		if (display->sbi.registers[i].offset == sbi_offset)
11108c2ecf20Sopenharmony_ci			break;
11118c2ecf20Sopenharmony_ci
11128c2ecf20Sopenharmony_ci	if (i == num)
11138c2ecf20Sopenharmony_ci		return 0;
11148c2ecf20Sopenharmony_ci
11158c2ecf20Sopenharmony_ci	return display->sbi.registers[i].value;
11168c2ecf20Sopenharmony_ci}
11178c2ecf20Sopenharmony_ci
11188c2ecf20Sopenharmony_cistatic void write_virtual_sbi_register(struct intel_vgpu *vgpu,
11198c2ecf20Sopenharmony_ci		unsigned int offset, u32 value)
11208c2ecf20Sopenharmony_ci{
11218c2ecf20Sopenharmony_ci	struct intel_vgpu_display *display = &vgpu->display;
11228c2ecf20Sopenharmony_ci	int num = display->sbi.number;
11238c2ecf20Sopenharmony_ci	int i;
11248c2ecf20Sopenharmony_ci
11258c2ecf20Sopenharmony_ci	for (i = 0; i < num; ++i) {
11268c2ecf20Sopenharmony_ci		if (display->sbi.registers[i].offset == offset)
11278c2ecf20Sopenharmony_ci			break;
11288c2ecf20Sopenharmony_ci	}
11298c2ecf20Sopenharmony_ci
11308c2ecf20Sopenharmony_ci	if (i == num) {
11318c2ecf20Sopenharmony_ci		if (num == SBI_REG_MAX) {
11328c2ecf20Sopenharmony_ci			gvt_vgpu_err("SBI caching meets maximum limits\n");
11338c2ecf20Sopenharmony_ci			return;
11348c2ecf20Sopenharmony_ci		}
11358c2ecf20Sopenharmony_ci		display->sbi.number++;
11368c2ecf20Sopenharmony_ci	}
11378c2ecf20Sopenharmony_ci
11388c2ecf20Sopenharmony_ci	display->sbi.registers[i].offset = offset;
11398c2ecf20Sopenharmony_ci	display->sbi.registers[i].value = value;
11408c2ecf20Sopenharmony_ci}
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_cistatic int sbi_data_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
11438c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
11448c2ecf20Sopenharmony_ci{
11458c2ecf20Sopenharmony_ci	if (((vgpu_vreg_t(vgpu, SBI_CTL_STAT) & SBI_OPCODE_MASK) >>
11468c2ecf20Sopenharmony_ci				SBI_OPCODE_SHIFT) == SBI_CMD_CRRD) {
11478c2ecf20Sopenharmony_ci		unsigned int sbi_offset = (vgpu_vreg_t(vgpu, SBI_ADDR) &
11488c2ecf20Sopenharmony_ci				SBI_ADDR_OFFSET_MASK) >> SBI_ADDR_OFFSET_SHIFT;
11498c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) = read_virtual_sbi_register(vgpu,
11508c2ecf20Sopenharmony_ci				sbi_offset);
11518c2ecf20Sopenharmony_ci	}
11528c2ecf20Sopenharmony_ci	read_vreg(vgpu, offset, p_data, bytes);
11538c2ecf20Sopenharmony_ci	return 0;
11548c2ecf20Sopenharmony_ci}
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_cistatic int sbi_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
11578c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
11588c2ecf20Sopenharmony_ci{
11598c2ecf20Sopenharmony_ci	u32 data;
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
11628c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci	data &= ~(SBI_STAT_MASK << SBI_STAT_SHIFT);
11658c2ecf20Sopenharmony_ci	data |= SBI_READY;
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_ci	data &= ~(SBI_RESPONSE_MASK << SBI_RESPONSE_SHIFT);
11688c2ecf20Sopenharmony_ci	data |= SBI_RESPONSE_SUCCESS;
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = data;
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_ci	if (((vgpu_vreg_t(vgpu, SBI_CTL_STAT) & SBI_OPCODE_MASK) >>
11738c2ecf20Sopenharmony_ci				SBI_OPCODE_SHIFT) == SBI_CMD_CRWR) {
11748c2ecf20Sopenharmony_ci		unsigned int sbi_offset = (vgpu_vreg_t(vgpu, SBI_ADDR) &
11758c2ecf20Sopenharmony_ci				SBI_ADDR_OFFSET_MASK) >> SBI_ADDR_OFFSET_SHIFT;
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci		write_virtual_sbi_register(vgpu, sbi_offset,
11788c2ecf20Sopenharmony_ci					   vgpu_vreg_t(vgpu, SBI_DATA));
11798c2ecf20Sopenharmony_ci	}
11808c2ecf20Sopenharmony_ci	return 0;
11818c2ecf20Sopenharmony_ci}
11828c2ecf20Sopenharmony_ci
11838c2ecf20Sopenharmony_ci#define _vgtif_reg(x) \
11848c2ecf20Sopenharmony_ci	(VGT_PVINFO_PAGE + offsetof(struct vgt_if, x))
11858c2ecf20Sopenharmony_ci
11868c2ecf20Sopenharmony_cistatic int pvinfo_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
11878c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
11888c2ecf20Sopenharmony_ci{
11898c2ecf20Sopenharmony_ci	bool invalid_read = false;
11908c2ecf20Sopenharmony_ci
11918c2ecf20Sopenharmony_ci	read_vreg(vgpu, offset, p_data, bytes);
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_ci	switch (offset) {
11948c2ecf20Sopenharmony_ci	case _vgtif_reg(magic) ... _vgtif_reg(vgt_id):
11958c2ecf20Sopenharmony_ci		if (offset + bytes > _vgtif_reg(vgt_id) + 4)
11968c2ecf20Sopenharmony_ci			invalid_read = true;
11978c2ecf20Sopenharmony_ci		break;
11988c2ecf20Sopenharmony_ci	case _vgtif_reg(avail_rs.mappable_gmadr.base) ...
11998c2ecf20Sopenharmony_ci		_vgtif_reg(avail_rs.fence_num):
12008c2ecf20Sopenharmony_ci		if (offset + bytes >
12018c2ecf20Sopenharmony_ci			_vgtif_reg(avail_rs.fence_num) + 4)
12028c2ecf20Sopenharmony_ci			invalid_read = true;
12038c2ecf20Sopenharmony_ci		break;
12048c2ecf20Sopenharmony_ci	case 0x78010:	/* vgt_caps */
12058c2ecf20Sopenharmony_ci	case 0x7881c:
12068c2ecf20Sopenharmony_ci		break;
12078c2ecf20Sopenharmony_ci	default:
12088c2ecf20Sopenharmony_ci		invalid_read = true;
12098c2ecf20Sopenharmony_ci		break;
12108c2ecf20Sopenharmony_ci	}
12118c2ecf20Sopenharmony_ci	if (invalid_read)
12128c2ecf20Sopenharmony_ci		gvt_vgpu_err("invalid pvinfo read: [%x:%x] = %x\n",
12138c2ecf20Sopenharmony_ci				offset, bytes, *(u32 *)p_data);
12148c2ecf20Sopenharmony_ci	vgpu->pv_notified = true;
12158c2ecf20Sopenharmony_ci	return 0;
12168c2ecf20Sopenharmony_ci}
12178c2ecf20Sopenharmony_ci
12188c2ecf20Sopenharmony_cistatic int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
12198c2ecf20Sopenharmony_ci{
12208c2ecf20Sopenharmony_ci	enum intel_gvt_gtt_type root_entry_type = GTT_TYPE_PPGTT_ROOT_L4_ENTRY;
12218c2ecf20Sopenharmony_ci	struct intel_vgpu_mm *mm;
12228c2ecf20Sopenharmony_ci	u64 *pdps;
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	pdps = (u64 *)&vgpu_vreg64_t(vgpu, vgtif_reg(pdp[0]));
12258c2ecf20Sopenharmony_ci
12268c2ecf20Sopenharmony_ci	switch (notification) {
12278c2ecf20Sopenharmony_ci	case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE:
12288c2ecf20Sopenharmony_ci		root_entry_type = GTT_TYPE_PPGTT_ROOT_L3_ENTRY;
12298c2ecf20Sopenharmony_ci		fallthrough;
12308c2ecf20Sopenharmony_ci	case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE:
12318c2ecf20Sopenharmony_ci		mm = intel_vgpu_get_ppgtt_mm(vgpu, root_entry_type, pdps);
12328c2ecf20Sopenharmony_ci		return PTR_ERR_OR_ZERO(mm);
12338c2ecf20Sopenharmony_ci	case VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY:
12348c2ecf20Sopenharmony_ci	case VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY:
12358c2ecf20Sopenharmony_ci		return intel_vgpu_put_ppgtt_mm(vgpu, pdps);
12368c2ecf20Sopenharmony_ci	case VGT_G2V_EXECLIST_CONTEXT_CREATE:
12378c2ecf20Sopenharmony_ci	case VGT_G2V_EXECLIST_CONTEXT_DESTROY:
12388c2ecf20Sopenharmony_ci	case 1:	/* Remove this in guest driver. */
12398c2ecf20Sopenharmony_ci		break;
12408c2ecf20Sopenharmony_ci	default:
12418c2ecf20Sopenharmony_ci		gvt_vgpu_err("Invalid PV notification %d\n", notification);
12428c2ecf20Sopenharmony_ci	}
12438c2ecf20Sopenharmony_ci	return 0;
12448c2ecf20Sopenharmony_ci}
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_cistatic int send_display_ready_uevent(struct intel_vgpu *vgpu, int ready)
12478c2ecf20Sopenharmony_ci{
12488c2ecf20Sopenharmony_ci	struct kobject *kobj = &vgpu->gvt->gt->i915->drm.primary->kdev->kobj;
12498c2ecf20Sopenharmony_ci	char *env[3] = {NULL, NULL, NULL};
12508c2ecf20Sopenharmony_ci	char vmid_str[20];
12518c2ecf20Sopenharmony_ci	char display_ready_str[20];
12528c2ecf20Sopenharmony_ci
12538c2ecf20Sopenharmony_ci	snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=%d", ready);
12548c2ecf20Sopenharmony_ci	env[0] = display_ready_str;
12558c2ecf20Sopenharmony_ci
12568c2ecf20Sopenharmony_ci	snprintf(vmid_str, 20, "VMID=%d", vgpu->id);
12578c2ecf20Sopenharmony_ci	env[1] = vmid_str;
12588c2ecf20Sopenharmony_ci
12598c2ecf20Sopenharmony_ci	return kobject_uevent_env(kobj, KOBJ_ADD, env);
12608c2ecf20Sopenharmony_ci}
12618c2ecf20Sopenharmony_ci
12628c2ecf20Sopenharmony_cistatic int pvinfo_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
12638c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
12648c2ecf20Sopenharmony_ci{
12658c2ecf20Sopenharmony_ci	u32 data = *(u32 *)p_data;
12668c2ecf20Sopenharmony_ci	bool invalid_write = false;
12678c2ecf20Sopenharmony_ci
12688c2ecf20Sopenharmony_ci	switch (offset) {
12698c2ecf20Sopenharmony_ci	case _vgtif_reg(display_ready):
12708c2ecf20Sopenharmony_ci		send_display_ready_uevent(vgpu, data ? 1 : 0);
12718c2ecf20Sopenharmony_ci		break;
12728c2ecf20Sopenharmony_ci	case _vgtif_reg(g2v_notify):
12738c2ecf20Sopenharmony_ci		handle_g2v_notification(vgpu, data);
12748c2ecf20Sopenharmony_ci		break;
12758c2ecf20Sopenharmony_ci	/* add xhot and yhot to handled list to avoid error log */
12768c2ecf20Sopenharmony_ci	case _vgtif_reg(cursor_x_hot):
12778c2ecf20Sopenharmony_ci	case _vgtif_reg(cursor_y_hot):
12788c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[0].lo):
12798c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[0].hi):
12808c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[1].lo):
12818c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[1].hi):
12828c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[2].lo):
12838c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[2].hi):
12848c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[3].lo):
12858c2ecf20Sopenharmony_ci	case _vgtif_reg(pdp[3].hi):
12868c2ecf20Sopenharmony_ci	case _vgtif_reg(execlist_context_descriptor_lo):
12878c2ecf20Sopenharmony_ci	case _vgtif_reg(execlist_context_descriptor_hi):
12888c2ecf20Sopenharmony_ci		break;
12898c2ecf20Sopenharmony_ci	case _vgtif_reg(rsv5[0])..._vgtif_reg(rsv5[3]):
12908c2ecf20Sopenharmony_ci		invalid_write = true;
12918c2ecf20Sopenharmony_ci		enter_failsafe_mode(vgpu, GVT_FAILSAFE_INSUFFICIENT_RESOURCE);
12928c2ecf20Sopenharmony_ci		break;
12938c2ecf20Sopenharmony_ci	default:
12948c2ecf20Sopenharmony_ci		invalid_write = true;
12958c2ecf20Sopenharmony_ci		gvt_vgpu_err("invalid pvinfo write offset %x bytes %x data %x\n",
12968c2ecf20Sopenharmony_ci				offset, bytes, data);
12978c2ecf20Sopenharmony_ci		break;
12988c2ecf20Sopenharmony_ci	}
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	if (!invalid_write)
13018c2ecf20Sopenharmony_ci		write_vreg(vgpu, offset, p_data, bytes);
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci	return 0;
13048c2ecf20Sopenharmony_ci}
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_cistatic int pf_write(struct intel_vgpu *vgpu,
13078c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
13088c2ecf20Sopenharmony_ci{
13098c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
13108c2ecf20Sopenharmony_ci	u32 val = *(u32 *)p_data;
13118c2ecf20Sopenharmony_ci
13128c2ecf20Sopenharmony_ci	if ((offset == _PS_1A_CTRL || offset == _PS_2A_CTRL ||
13138c2ecf20Sopenharmony_ci	   offset == _PS_1B_CTRL || offset == _PS_2B_CTRL ||
13148c2ecf20Sopenharmony_ci	   offset == _PS_1C_CTRL) && (val & PS_PLANE_SEL_MASK) != 0) {
13158c2ecf20Sopenharmony_ci		drm_WARN_ONCE(&i915->drm, true,
13168c2ecf20Sopenharmony_ci			      "VM(%d): guest is trying to scaling a plane\n",
13178c2ecf20Sopenharmony_ci			      vgpu->id);
13188c2ecf20Sopenharmony_ci		return 0;
13198c2ecf20Sopenharmony_ci	}
13208c2ecf20Sopenharmony_ci
13218c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_write(vgpu, offset, p_data, bytes);
13228c2ecf20Sopenharmony_ci}
13238c2ecf20Sopenharmony_ci
13248c2ecf20Sopenharmony_cistatic int power_well_ctl_mmio_write(struct intel_vgpu *vgpu,
13258c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
13268c2ecf20Sopenharmony_ci{
13278c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) &
13308c2ecf20Sopenharmony_ci	    HSW_PWR_WELL_CTL_REQ(HSW_PW_CTL_IDX_GLOBAL))
13318c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |=
13328c2ecf20Sopenharmony_ci			HSW_PWR_WELL_CTL_STATE(HSW_PW_CTL_IDX_GLOBAL);
13338c2ecf20Sopenharmony_ci	else
13348c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &=
13358c2ecf20Sopenharmony_ci			~HSW_PWR_WELL_CTL_STATE(HSW_PW_CTL_IDX_GLOBAL);
13368c2ecf20Sopenharmony_ci	return 0;
13378c2ecf20Sopenharmony_ci}
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_cistatic int gen9_dbuf_ctl_mmio_write(struct intel_vgpu *vgpu,
13408c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
13418c2ecf20Sopenharmony_ci{
13428c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
13438c2ecf20Sopenharmony_ci
13448c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & DBUF_POWER_REQUEST)
13458c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) |= DBUF_POWER_STATE;
13468c2ecf20Sopenharmony_ci	else
13478c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~DBUF_POWER_STATE;
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	return 0;
13508c2ecf20Sopenharmony_ci}
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_cistatic int fpga_dbg_mmio_write(struct intel_vgpu *vgpu,
13538c2ecf20Sopenharmony_ci	unsigned int offset, void *p_data, unsigned int bytes)
13548c2ecf20Sopenharmony_ci{
13558c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
13568c2ecf20Sopenharmony_ci
13578c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, offset) & FPGA_DBG_RM_NOCLAIM)
13588c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) &= ~FPGA_DBG_RM_NOCLAIM;
13598c2ecf20Sopenharmony_ci	return 0;
13608c2ecf20Sopenharmony_ci}
13618c2ecf20Sopenharmony_ci
13628c2ecf20Sopenharmony_cistatic int dma_ctrl_write(struct intel_vgpu *vgpu, unsigned int offset,
13638c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
13648c2ecf20Sopenharmony_ci{
13658c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
13668c2ecf20Sopenharmony_ci	u32 mode;
13678c2ecf20Sopenharmony_ci
13688c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
13698c2ecf20Sopenharmony_ci	mode = vgpu_vreg(vgpu, offset);
13708c2ecf20Sopenharmony_ci
13718c2ecf20Sopenharmony_ci	if (GFX_MODE_BIT_SET_IN_MASK(mode, START_DMA)) {
13728c2ecf20Sopenharmony_ci		drm_WARN_ONCE(&i915->drm, 1,
13738c2ecf20Sopenharmony_ci				"VM(%d): iGVT-g doesn't support GuC\n",
13748c2ecf20Sopenharmony_ci				vgpu->id);
13758c2ecf20Sopenharmony_ci		return 0;
13768c2ecf20Sopenharmony_ci	}
13778c2ecf20Sopenharmony_ci
13788c2ecf20Sopenharmony_ci	return 0;
13798c2ecf20Sopenharmony_ci}
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_cistatic int gen9_trtte_write(struct intel_vgpu *vgpu, unsigned int offset,
13828c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
13838c2ecf20Sopenharmony_ci{
13848c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
13858c2ecf20Sopenharmony_ci	u32 trtte = *(u32 *)p_data;
13868c2ecf20Sopenharmony_ci
13878c2ecf20Sopenharmony_ci	if ((trtte & 1) && (trtte & (1 << 1)) == 0) {
13888c2ecf20Sopenharmony_ci		drm_WARN(&i915->drm, 1,
13898c2ecf20Sopenharmony_ci				"VM(%d): Use physical address for TRTT!\n",
13908c2ecf20Sopenharmony_ci				vgpu->id);
13918c2ecf20Sopenharmony_ci		return -EINVAL;
13928c2ecf20Sopenharmony_ci	}
13938c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
13948c2ecf20Sopenharmony_ci
13958c2ecf20Sopenharmony_ci	return 0;
13968c2ecf20Sopenharmony_ci}
13978c2ecf20Sopenharmony_ci
13988c2ecf20Sopenharmony_cistatic int gen9_trtt_chicken_write(struct intel_vgpu *vgpu, unsigned int offset,
13998c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
14008c2ecf20Sopenharmony_ci{
14018c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
14028c2ecf20Sopenharmony_ci	return 0;
14038c2ecf20Sopenharmony_ci}
14048c2ecf20Sopenharmony_ci
14058c2ecf20Sopenharmony_cistatic int dpll_status_read(struct intel_vgpu *vgpu, unsigned int offset,
14068c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
14078c2ecf20Sopenharmony_ci{
14088c2ecf20Sopenharmony_ci	u32 v = 0;
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, 0x46010) & (1 << 31))
14118c2ecf20Sopenharmony_ci		v |= (1 << 0);
14128c2ecf20Sopenharmony_ci
14138c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, 0x46014) & (1 << 31))
14148c2ecf20Sopenharmony_ci		v |= (1 << 8);
14158c2ecf20Sopenharmony_ci
14168c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, 0x46040) & (1 << 31))
14178c2ecf20Sopenharmony_ci		v |= (1 << 16);
14188c2ecf20Sopenharmony_ci
14198c2ecf20Sopenharmony_ci	if (vgpu_vreg(vgpu, 0x46060) & (1 << 31))
14208c2ecf20Sopenharmony_ci		v |= (1 << 24);
14218c2ecf20Sopenharmony_ci
14228c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
14238c2ecf20Sopenharmony_ci
14248c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_read(vgpu, offset, p_data, bytes);
14258c2ecf20Sopenharmony_ci}
14268c2ecf20Sopenharmony_ci
14278c2ecf20Sopenharmony_cistatic int mailbox_write(struct intel_vgpu *vgpu, unsigned int offset,
14288c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
14298c2ecf20Sopenharmony_ci{
14308c2ecf20Sopenharmony_ci	u32 value = *(u32 *)p_data;
14318c2ecf20Sopenharmony_ci	u32 cmd = value & 0xff;
14328c2ecf20Sopenharmony_ci	u32 *data0 = &vgpu_vreg_t(vgpu, GEN6_PCODE_DATA);
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_ci	switch (cmd) {
14358c2ecf20Sopenharmony_ci	case GEN9_PCODE_READ_MEM_LATENCY:
14368c2ecf20Sopenharmony_ci		if (IS_SKYLAKE(vgpu->gvt->gt->i915) ||
14378c2ecf20Sopenharmony_ci		    IS_KABYLAKE(vgpu->gvt->gt->i915) ||
14388c2ecf20Sopenharmony_ci		    IS_COFFEELAKE(vgpu->gvt->gt->i915) ||
14398c2ecf20Sopenharmony_ci		    IS_COMETLAKE(vgpu->gvt->gt->i915)) {
14408c2ecf20Sopenharmony_ci			/**
14418c2ecf20Sopenharmony_ci			 * "Read memory latency" command on gen9.
14428c2ecf20Sopenharmony_ci			 * Below memory latency values are read
14438c2ecf20Sopenharmony_ci			 * from skylake platform.
14448c2ecf20Sopenharmony_ci			 */
14458c2ecf20Sopenharmony_ci			if (!*data0)
14468c2ecf20Sopenharmony_ci				*data0 = 0x1e1a1100;
14478c2ecf20Sopenharmony_ci			else
14488c2ecf20Sopenharmony_ci				*data0 = 0x61514b3d;
14498c2ecf20Sopenharmony_ci		} else if (IS_BROXTON(vgpu->gvt->gt->i915)) {
14508c2ecf20Sopenharmony_ci			/**
14518c2ecf20Sopenharmony_ci			 * "Read memory latency" command on gen9.
14528c2ecf20Sopenharmony_ci			 * Below memory latency values are read
14538c2ecf20Sopenharmony_ci			 * from Broxton MRB.
14548c2ecf20Sopenharmony_ci			 */
14558c2ecf20Sopenharmony_ci			if (!*data0)
14568c2ecf20Sopenharmony_ci				*data0 = 0x16080707;
14578c2ecf20Sopenharmony_ci			else
14588c2ecf20Sopenharmony_ci				*data0 = 0x16161616;
14598c2ecf20Sopenharmony_ci		}
14608c2ecf20Sopenharmony_ci		break;
14618c2ecf20Sopenharmony_ci	case SKL_PCODE_CDCLK_CONTROL:
14628c2ecf20Sopenharmony_ci		if (IS_SKYLAKE(vgpu->gvt->gt->i915) ||
14638c2ecf20Sopenharmony_ci		    IS_KABYLAKE(vgpu->gvt->gt->i915) ||
14648c2ecf20Sopenharmony_ci		    IS_COFFEELAKE(vgpu->gvt->gt->i915) ||
14658c2ecf20Sopenharmony_ci		    IS_COMETLAKE(vgpu->gvt->gt->i915))
14668c2ecf20Sopenharmony_ci			*data0 = SKL_CDCLK_READY_FOR_CHANGE;
14678c2ecf20Sopenharmony_ci		break;
14688c2ecf20Sopenharmony_ci	case GEN6_PCODE_READ_RC6VIDS:
14698c2ecf20Sopenharmony_ci		*data0 |= 0x1;
14708c2ecf20Sopenharmony_ci		break;
14718c2ecf20Sopenharmony_ci	}
14728c2ecf20Sopenharmony_ci
14738c2ecf20Sopenharmony_ci	gvt_dbg_core("VM(%d) write %x to mailbox, return data0 %x\n",
14748c2ecf20Sopenharmony_ci		     vgpu->id, value, *data0);
14758c2ecf20Sopenharmony_ci	/**
14768c2ecf20Sopenharmony_ci	 * PCODE_READY clear means ready for pcode read/write,
14778c2ecf20Sopenharmony_ci	 * PCODE_ERROR_MASK clear means no error happened. In GVT-g we
14788c2ecf20Sopenharmony_ci	 * always emulate as pcode read/write success and ready for access
14798c2ecf20Sopenharmony_ci	 * anytime, since we don't touch real physical registers here.
14808c2ecf20Sopenharmony_ci	 */
14818c2ecf20Sopenharmony_ci	value &= ~(GEN6_PCODE_READY | GEN6_PCODE_ERROR_MASK);
14828c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_write(vgpu, offset, &value, bytes);
14838c2ecf20Sopenharmony_ci}
14848c2ecf20Sopenharmony_ci
14858c2ecf20Sopenharmony_cistatic int hws_pga_write(struct intel_vgpu *vgpu, unsigned int offset,
14868c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
14878c2ecf20Sopenharmony_ci{
14888c2ecf20Sopenharmony_ci	u32 value = *(u32 *)p_data;
14898c2ecf20Sopenharmony_ci	const struct intel_engine_cs *engine =
14908c2ecf20Sopenharmony_ci		intel_gvt_render_mmio_to_engine(vgpu->gvt, offset);
14918c2ecf20Sopenharmony_ci
14928c2ecf20Sopenharmony_ci	if (value != 0 &&
14938c2ecf20Sopenharmony_ci	    !intel_gvt_ggtt_validate_range(vgpu, value, I915_GTT_PAGE_SIZE)) {
14948c2ecf20Sopenharmony_ci		gvt_vgpu_err("write invalid HWSP address, reg:0x%x, value:0x%x\n",
14958c2ecf20Sopenharmony_ci			      offset, value);
14968c2ecf20Sopenharmony_ci		return -EINVAL;
14978c2ecf20Sopenharmony_ci	}
14988c2ecf20Sopenharmony_ci
14998c2ecf20Sopenharmony_ci	/*
15008c2ecf20Sopenharmony_ci	 * Need to emulate all the HWSP register write to ensure host can
15018c2ecf20Sopenharmony_ci	 * update the VM CSB status correctly. Here listed registers can
15028c2ecf20Sopenharmony_ci	 * support BDW, SKL or other platforms with same HWSP registers.
15038c2ecf20Sopenharmony_ci	 */
15048c2ecf20Sopenharmony_ci	if (unlikely(!engine)) {
15058c2ecf20Sopenharmony_ci		gvt_vgpu_err("access unknown hardware status page register:0x%x\n",
15068c2ecf20Sopenharmony_ci			     offset);
15078c2ecf20Sopenharmony_ci		return -EINVAL;
15088c2ecf20Sopenharmony_ci	}
15098c2ecf20Sopenharmony_ci	vgpu->hws_pga[engine->id] = value;
15108c2ecf20Sopenharmony_ci	gvt_dbg_mmio("VM(%d) write: 0x%x to HWSP: 0x%x\n",
15118c2ecf20Sopenharmony_ci		     vgpu->id, value, offset);
15128c2ecf20Sopenharmony_ci
15138c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_write(vgpu, offset, &value, bytes);
15148c2ecf20Sopenharmony_ci}
15158c2ecf20Sopenharmony_ci
15168c2ecf20Sopenharmony_cistatic int skl_power_well_ctl_write(struct intel_vgpu *vgpu,
15178c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
15188c2ecf20Sopenharmony_ci{
15198c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
15208c2ecf20Sopenharmony_ci
15218c2ecf20Sopenharmony_ci	if (IS_BROXTON(vgpu->gvt->gt->i915))
15228c2ecf20Sopenharmony_ci		v &= (1 << 31) | (1 << 29);
15238c2ecf20Sopenharmony_ci	else
15248c2ecf20Sopenharmony_ci		v &= (1 << 31) | (1 << 29) | (1 << 9) |
15258c2ecf20Sopenharmony_ci			(1 << 7) | (1 << 5) | (1 << 3) | (1 << 1);
15268c2ecf20Sopenharmony_ci	v |= (v >> 1);
15278c2ecf20Sopenharmony_ci
15288c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_write(vgpu, offset, &v, bytes);
15298c2ecf20Sopenharmony_ci}
15308c2ecf20Sopenharmony_ci
15318c2ecf20Sopenharmony_cistatic int skl_lcpll_write(struct intel_vgpu *vgpu, unsigned int offset,
15328c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
15338c2ecf20Sopenharmony_ci{
15348c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
15358c2ecf20Sopenharmony_ci
15368c2ecf20Sopenharmony_ci	/* other bits are MBZ. */
15378c2ecf20Sopenharmony_ci	v &= (1 << 31) | (1 << 30);
15388c2ecf20Sopenharmony_ci	v & (1 << 31) ? (v |= (1 << 30)) : (v &= ~(1 << 30));
15398c2ecf20Sopenharmony_ci
15408c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
15418c2ecf20Sopenharmony_ci
15428c2ecf20Sopenharmony_ci	return 0;
15438c2ecf20Sopenharmony_ci}
15448c2ecf20Sopenharmony_ci
15458c2ecf20Sopenharmony_cistatic int bxt_de_pll_enable_write(struct intel_vgpu *vgpu,
15468c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
15478c2ecf20Sopenharmony_ci{
15488c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ci	if (v & BXT_DE_PLL_PLL_ENABLE)
15518c2ecf20Sopenharmony_ci		v |= BXT_DE_PLL_LOCK;
15528c2ecf20Sopenharmony_ci
15538c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
15548c2ecf20Sopenharmony_ci
15558c2ecf20Sopenharmony_ci	return 0;
15568c2ecf20Sopenharmony_ci}
15578c2ecf20Sopenharmony_ci
15588c2ecf20Sopenharmony_cistatic int bxt_port_pll_enable_write(struct intel_vgpu *vgpu,
15598c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
15608c2ecf20Sopenharmony_ci{
15618c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
15628c2ecf20Sopenharmony_ci
15638c2ecf20Sopenharmony_ci	if (v & PORT_PLL_ENABLE)
15648c2ecf20Sopenharmony_ci		v |= PORT_PLL_LOCK;
15658c2ecf20Sopenharmony_ci
15668c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
15678c2ecf20Sopenharmony_ci
15688c2ecf20Sopenharmony_ci	return 0;
15698c2ecf20Sopenharmony_ci}
15708c2ecf20Sopenharmony_ci
15718c2ecf20Sopenharmony_cistatic int bxt_phy_ctl_family_write(struct intel_vgpu *vgpu,
15728c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
15738c2ecf20Sopenharmony_ci{
15748c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
15758c2ecf20Sopenharmony_ci	u32 data = v & COMMON_RESET_DIS ? BXT_PHY_LANE_ENABLED : 0;
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_ci	switch (offset) {
15788c2ecf20Sopenharmony_ci	case _PHY_CTL_FAMILY_EDP:
15798c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_A) = data;
15808c2ecf20Sopenharmony_ci		break;
15818c2ecf20Sopenharmony_ci	case _PHY_CTL_FAMILY_DDI:
15828c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_B) = data;
15838c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, _BXT_PHY_CTL_DDI_C) = data;
15848c2ecf20Sopenharmony_ci		break;
15858c2ecf20Sopenharmony_ci	}
15868c2ecf20Sopenharmony_ci
15878c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
15888c2ecf20Sopenharmony_ci
15898c2ecf20Sopenharmony_ci	return 0;
15908c2ecf20Sopenharmony_ci}
15918c2ecf20Sopenharmony_ci
15928c2ecf20Sopenharmony_cistatic int bxt_port_tx_dw3_read(struct intel_vgpu *vgpu,
15938c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
15948c2ecf20Sopenharmony_ci{
15958c2ecf20Sopenharmony_ci	u32 v = vgpu_vreg(vgpu, offset);
15968c2ecf20Sopenharmony_ci
15978c2ecf20Sopenharmony_ci	v &= ~UNIQUE_TRANGE_EN_METHOD;
15988c2ecf20Sopenharmony_ci
15998c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
16008c2ecf20Sopenharmony_ci
16018c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_read(vgpu, offset, p_data, bytes);
16028c2ecf20Sopenharmony_ci}
16038c2ecf20Sopenharmony_ci
16048c2ecf20Sopenharmony_cistatic int bxt_pcs_dw12_grp_write(struct intel_vgpu *vgpu,
16058c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
16068c2ecf20Sopenharmony_ci{
16078c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
16088c2ecf20Sopenharmony_ci
16098c2ecf20Sopenharmony_ci	if (offset == _PORT_PCS_DW12_GRP_A || offset == _PORT_PCS_DW12_GRP_B) {
16108c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset - 0x600) = v;
16118c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset - 0x800) = v;
16128c2ecf20Sopenharmony_ci	} else {
16138c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset - 0x400) = v;
16148c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset - 0x600) = v;
16158c2ecf20Sopenharmony_ci	}
16168c2ecf20Sopenharmony_ci
16178c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
16188c2ecf20Sopenharmony_ci
16198c2ecf20Sopenharmony_ci	return 0;
16208c2ecf20Sopenharmony_ci}
16218c2ecf20Sopenharmony_ci
16228c2ecf20Sopenharmony_cistatic int bxt_gt_disp_pwron_write(struct intel_vgpu *vgpu,
16238c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
16248c2ecf20Sopenharmony_ci{
16258c2ecf20Sopenharmony_ci	u32 v = *(u32 *)p_data;
16268c2ecf20Sopenharmony_ci
16278c2ecf20Sopenharmony_ci	if (v & BIT(0)) {
16288c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) &=
16298c2ecf20Sopenharmony_ci			~PHY_RESERVED;
16308c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) |=
16318c2ecf20Sopenharmony_ci			PHY_POWER_GOOD;
16328c2ecf20Sopenharmony_ci	}
16338c2ecf20Sopenharmony_ci
16348c2ecf20Sopenharmony_ci	if (v & BIT(1)) {
16358c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) &=
16368c2ecf20Sopenharmony_ci			~PHY_RESERVED;
16378c2ecf20Sopenharmony_ci		vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) |=
16388c2ecf20Sopenharmony_ci			PHY_POWER_GOOD;
16398c2ecf20Sopenharmony_ci	}
16408c2ecf20Sopenharmony_ci
16418c2ecf20Sopenharmony_ci
16428c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = v;
16438c2ecf20Sopenharmony_ci
16448c2ecf20Sopenharmony_ci	return 0;
16458c2ecf20Sopenharmony_ci}
16468c2ecf20Sopenharmony_ci
16478c2ecf20Sopenharmony_cistatic int edp_psr_imr_iir_write(struct intel_vgpu *vgpu,
16488c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
16498c2ecf20Sopenharmony_ci{
16508c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = 0;
16518c2ecf20Sopenharmony_ci	return 0;
16528c2ecf20Sopenharmony_ci}
16538c2ecf20Sopenharmony_ci
16548c2ecf20Sopenharmony_ci/**
16558c2ecf20Sopenharmony_ci * FixMe:
16568c2ecf20Sopenharmony_ci * If guest fills non-priv batch buffer on ApolloLake/Broxton as Mesa i965 did:
16578c2ecf20Sopenharmony_ci * 717e7539124d (i965: Use a WC map and memcpy for the batch instead of pwrite.)
16588c2ecf20Sopenharmony_ci * Due to the missing flush of bb filled by VM vCPU, host GPU hangs on executing
16598c2ecf20Sopenharmony_ci * these MI_BATCH_BUFFER.
16608c2ecf20Sopenharmony_ci * Temporarily workaround this by setting SNOOP bit for PAT3 used by PPGTT
16618c2ecf20Sopenharmony_ci * PML4 PTE: PAT(0) PCD(1) PWT(1).
16628c2ecf20Sopenharmony_ci * The performance is still expected to be low, will need further improvement.
16638c2ecf20Sopenharmony_ci */
16648c2ecf20Sopenharmony_cistatic int bxt_ppat_low_write(struct intel_vgpu *vgpu, unsigned int offset,
16658c2ecf20Sopenharmony_ci			      void *p_data, unsigned int bytes)
16668c2ecf20Sopenharmony_ci{
16678c2ecf20Sopenharmony_ci	u64 pat =
16688c2ecf20Sopenharmony_ci		GEN8_PPAT(0, CHV_PPAT_SNOOP) |
16698c2ecf20Sopenharmony_ci		GEN8_PPAT(1, 0) |
16708c2ecf20Sopenharmony_ci		GEN8_PPAT(2, 0) |
16718c2ecf20Sopenharmony_ci		GEN8_PPAT(3, CHV_PPAT_SNOOP) |
16728c2ecf20Sopenharmony_ci		GEN8_PPAT(4, CHV_PPAT_SNOOP) |
16738c2ecf20Sopenharmony_ci		GEN8_PPAT(5, CHV_PPAT_SNOOP) |
16748c2ecf20Sopenharmony_ci		GEN8_PPAT(6, CHV_PPAT_SNOOP) |
16758c2ecf20Sopenharmony_ci		GEN8_PPAT(7, CHV_PPAT_SNOOP);
16768c2ecf20Sopenharmony_ci
16778c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = lower_32_bits(pat);
16788c2ecf20Sopenharmony_ci
16798c2ecf20Sopenharmony_ci	return 0;
16808c2ecf20Sopenharmony_ci}
16818c2ecf20Sopenharmony_ci
16828c2ecf20Sopenharmony_cistatic int guc_status_read(struct intel_vgpu *vgpu,
16838c2ecf20Sopenharmony_ci			   unsigned int offset, void *p_data,
16848c2ecf20Sopenharmony_ci			   unsigned int bytes)
16858c2ecf20Sopenharmony_ci{
16868c2ecf20Sopenharmony_ci	/* keep MIA_IN_RESET before clearing */
16878c2ecf20Sopenharmony_ci	read_vreg(vgpu, offset, p_data, bytes);
16888c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) &= ~GS_MIA_IN_RESET;
16898c2ecf20Sopenharmony_ci	return 0;
16908c2ecf20Sopenharmony_ci}
16918c2ecf20Sopenharmony_ci
16928c2ecf20Sopenharmony_cistatic int mmio_read_from_hw(struct intel_vgpu *vgpu,
16938c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
16948c2ecf20Sopenharmony_ci{
16958c2ecf20Sopenharmony_ci	struct intel_gvt *gvt = vgpu->gvt;
16968c2ecf20Sopenharmony_ci	const struct intel_engine_cs *engine =
16978c2ecf20Sopenharmony_ci		intel_gvt_render_mmio_to_engine(gvt, offset);
16988c2ecf20Sopenharmony_ci
16998c2ecf20Sopenharmony_ci	/**
17008c2ecf20Sopenharmony_ci	 * Read HW reg in following case
17018c2ecf20Sopenharmony_ci	 * a. the offset isn't a ring mmio
17028c2ecf20Sopenharmony_ci	 * b. the offset's ring is running on hw.
17038c2ecf20Sopenharmony_ci	 * c. the offset is ring time stamp mmio
17048c2ecf20Sopenharmony_ci	 */
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_ci	if (!engine ||
17078c2ecf20Sopenharmony_ci	    vgpu == gvt->scheduler.engine_owner[engine->id] ||
17088c2ecf20Sopenharmony_ci	    offset == i915_mmio_reg_offset(RING_TIMESTAMP(engine->mmio_base)) ||
17098c2ecf20Sopenharmony_ci	    offset == i915_mmio_reg_offset(RING_TIMESTAMP_UDW(engine->mmio_base))) {
17108c2ecf20Sopenharmony_ci		mmio_hw_access_pre(gvt->gt);
17118c2ecf20Sopenharmony_ci		vgpu_vreg(vgpu, offset) =
17128c2ecf20Sopenharmony_ci			intel_uncore_read(gvt->gt->uncore, _MMIO(offset));
17138c2ecf20Sopenharmony_ci		mmio_hw_access_post(gvt->gt);
17148c2ecf20Sopenharmony_ci	}
17158c2ecf20Sopenharmony_ci
17168c2ecf20Sopenharmony_ci	return intel_vgpu_default_mmio_read(vgpu, offset, p_data, bytes);
17178c2ecf20Sopenharmony_ci}
17188c2ecf20Sopenharmony_ci
17198c2ecf20Sopenharmony_cistatic int elsp_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
17208c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
17218c2ecf20Sopenharmony_ci{
17228c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
17238c2ecf20Sopenharmony_ci	const struct intel_engine_cs *engine = intel_gvt_render_mmio_to_engine(vgpu->gvt, offset);
17248c2ecf20Sopenharmony_ci	struct intel_vgpu_execlist *execlist;
17258c2ecf20Sopenharmony_ci	u32 data = *(u32 *)p_data;
17268c2ecf20Sopenharmony_ci	int ret = 0;
17278c2ecf20Sopenharmony_ci
17288c2ecf20Sopenharmony_ci	if (drm_WARN_ON(&i915->drm, !engine))
17298c2ecf20Sopenharmony_ci		return -EINVAL;
17308c2ecf20Sopenharmony_ci
17318c2ecf20Sopenharmony_ci	/*
17328c2ecf20Sopenharmony_ci	 * Due to d3_entered is used to indicate skipping PPGTT invalidation on
17338c2ecf20Sopenharmony_ci	 * vGPU reset, it's set on D0->D3 on PCI config write, and cleared after
17348c2ecf20Sopenharmony_ci	 * vGPU reset if in resuming.
17358c2ecf20Sopenharmony_ci	 * In S0ix exit, the device power state also transite from D3 to D0 as
17368c2ecf20Sopenharmony_ci	 * S3 resume, but no vGPU reset (triggered by QEMU devic model). After
17378c2ecf20Sopenharmony_ci	 * S0ix exit, all engines continue to work. However the d3_entered
17388c2ecf20Sopenharmony_ci	 * remains set which will break next vGPU reset logic (miss the expected
17398c2ecf20Sopenharmony_ci	 * PPGTT invalidation).
17408c2ecf20Sopenharmony_ci	 * Engines can only work in D0. Thus the 1st elsp write gives GVT a
17418c2ecf20Sopenharmony_ci	 * chance to clear d3_entered.
17428c2ecf20Sopenharmony_ci	 */
17438c2ecf20Sopenharmony_ci	if (vgpu->d3_entered)
17448c2ecf20Sopenharmony_ci		vgpu->d3_entered = false;
17458c2ecf20Sopenharmony_ci
17468c2ecf20Sopenharmony_ci	execlist = &vgpu->submission.execlist[engine->id];
17478c2ecf20Sopenharmony_ci
17488c2ecf20Sopenharmony_ci	execlist->elsp_dwords.data[3 - execlist->elsp_dwords.index] = data;
17498c2ecf20Sopenharmony_ci	if (execlist->elsp_dwords.index == 3) {
17508c2ecf20Sopenharmony_ci		ret = intel_vgpu_submit_execlist(vgpu, engine);
17518c2ecf20Sopenharmony_ci		if(ret)
17528c2ecf20Sopenharmony_ci			gvt_vgpu_err("fail submit workload on ring %s\n",
17538c2ecf20Sopenharmony_ci				     engine->name);
17548c2ecf20Sopenharmony_ci	}
17558c2ecf20Sopenharmony_ci
17568c2ecf20Sopenharmony_ci	++execlist->elsp_dwords.index;
17578c2ecf20Sopenharmony_ci	execlist->elsp_dwords.index &= 0x3;
17588c2ecf20Sopenharmony_ci	return ret;
17598c2ecf20Sopenharmony_ci}
17608c2ecf20Sopenharmony_ci
17618c2ecf20Sopenharmony_cistatic int ring_mode_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
17628c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
17638c2ecf20Sopenharmony_ci{
17648c2ecf20Sopenharmony_ci	u32 data = *(u32 *)p_data;
17658c2ecf20Sopenharmony_ci	const struct intel_engine_cs *engine =
17668c2ecf20Sopenharmony_ci		intel_gvt_render_mmio_to_engine(vgpu->gvt, offset);
17678c2ecf20Sopenharmony_ci	bool enable_execlist;
17688c2ecf20Sopenharmony_ci	int ret;
17698c2ecf20Sopenharmony_ci
17708c2ecf20Sopenharmony_ci	(*(u32 *)p_data) &= ~_MASKED_BIT_ENABLE(1);
17718c2ecf20Sopenharmony_ci	if (IS_COFFEELAKE(vgpu->gvt->gt->i915) ||
17728c2ecf20Sopenharmony_ci	    IS_COMETLAKE(vgpu->gvt->gt->i915))
17738c2ecf20Sopenharmony_ci		(*(u32 *)p_data) &= ~_MASKED_BIT_ENABLE(2);
17748c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
17758c2ecf20Sopenharmony_ci
17768c2ecf20Sopenharmony_ci	if (IS_MASKED_BITS_ENABLED(data, 1)) {
17778c2ecf20Sopenharmony_ci		enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
17788c2ecf20Sopenharmony_ci		return 0;
17798c2ecf20Sopenharmony_ci	}
17808c2ecf20Sopenharmony_ci
17818c2ecf20Sopenharmony_ci	if ((IS_COFFEELAKE(vgpu->gvt->gt->i915) ||
17828c2ecf20Sopenharmony_ci	     IS_COMETLAKE(vgpu->gvt->gt->i915)) &&
17838c2ecf20Sopenharmony_ci	    IS_MASKED_BITS_ENABLED(data, 2)) {
17848c2ecf20Sopenharmony_ci		enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
17858c2ecf20Sopenharmony_ci		return 0;
17868c2ecf20Sopenharmony_ci	}
17878c2ecf20Sopenharmony_ci
17888c2ecf20Sopenharmony_ci	/* when PPGTT mode enabled, we will check if guest has called
17898c2ecf20Sopenharmony_ci	 * pvinfo, if not, we will treat this guest as non-gvtg-aware
17908c2ecf20Sopenharmony_ci	 * guest, and stop emulating its cfg space, mmio, gtt, etc.
17918c2ecf20Sopenharmony_ci	 */
17928c2ecf20Sopenharmony_ci	if ((IS_MASKED_BITS_ENABLED(data, GFX_PPGTT_ENABLE) ||
17938c2ecf20Sopenharmony_ci	    IS_MASKED_BITS_ENABLED(data, GFX_RUN_LIST_ENABLE)) &&
17948c2ecf20Sopenharmony_ci	    !vgpu->pv_notified) {
17958c2ecf20Sopenharmony_ci		enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
17968c2ecf20Sopenharmony_ci		return 0;
17978c2ecf20Sopenharmony_ci	}
17988c2ecf20Sopenharmony_ci	if (IS_MASKED_BITS_ENABLED(data, GFX_RUN_LIST_ENABLE) ||
17998c2ecf20Sopenharmony_ci	    IS_MASKED_BITS_DISABLED(data, GFX_RUN_LIST_ENABLE)) {
18008c2ecf20Sopenharmony_ci		enable_execlist = !!(data & GFX_RUN_LIST_ENABLE);
18018c2ecf20Sopenharmony_ci
18028c2ecf20Sopenharmony_ci		gvt_dbg_core("EXECLIST %s on ring %s\n",
18038c2ecf20Sopenharmony_ci			     (enable_execlist ? "enabling" : "disabling"),
18048c2ecf20Sopenharmony_ci			     engine->name);
18058c2ecf20Sopenharmony_ci
18068c2ecf20Sopenharmony_ci		if (!enable_execlist)
18078c2ecf20Sopenharmony_ci			return 0;
18088c2ecf20Sopenharmony_ci
18098c2ecf20Sopenharmony_ci		ret = intel_vgpu_select_submission_ops(vgpu,
18108c2ecf20Sopenharmony_ci						       engine->mask,
18118c2ecf20Sopenharmony_ci						       INTEL_VGPU_EXECLIST_SUBMISSION);
18128c2ecf20Sopenharmony_ci		if (ret)
18138c2ecf20Sopenharmony_ci			return ret;
18148c2ecf20Sopenharmony_ci
18158c2ecf20Sopenharmony_ci		intel_vgpu_start_schedule(vgpu);
18168c2ecf20Sopenharmony_ci	}
18178c2ecf20Sopenharmony_ci	return 0;
18188c2ecf20Sopenharmony_ci}
18198c2ecf20Sopenharmony_ci
18208c2ecf20Sopenharmony_cistatic int gvt_reg_tlb_control_handler(struct intel_vgpu *vgpu,
18218c2ecf20Sopenharmony_ci		unsigned int offset, void *p_data, unsigned int bytes)
18228c2ecf20Sopenharmony_ci{
18238c2ecf20Sopenharmony_ci	unsigned int id = 0;
18248c2ecf20Sopenharmony_ci
18258c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
18268c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = 0;
18278c2ecf20Sopenharmony_ci
18288c2ecf20Sopenharmony_ci	switch (offset) {
18298c2ecf20Sopenharmony_ci	case 0x4260:
18308c2ecf20Sopenharmony_ci		id = RCS0;
18318c2ecf20Sopenharmony_ci		break;
18328c2ecf20Sopenharmony_ci	case 0x4264:
18338c2ecf20Sopenharmony_ci		id = VCS0;
18348c2ecf20Sopenharmony_ci		break;
18358c2ecf20Sopenharmony_ci	case 0x4268:
18368c2ecf20Sopenharmony_ci		id = VCS1;
18378c2ecf20Sopenharmony_ci		break;
18388c2ecf20Sopenharmony_ci	case 0x426c:
18398c2ecf20Sopenharmony_ci		id = BCS0;
18408c2ecf20Sopenharmony_ci		break;
18418c2ecf20Sopenharmony_ci	case 0x4270:
18428c2ecf20Sopenharmony_ci		id = VECS0;
18438c2ecf20Sopenharmony_ci		break;
18448c2ecf20Sopenharmony_ci	default:
18458c2ecf20Sopenharmony_ci		return -EINVAL;
18468c2ecf20Sopenharmony_ci	}
18478c2ecf20Sopenharmony_ci	set_bit(id, (void *)vgpu->submission.tlb_handle_pending);
18488c2ecf20Sopenharmony_ci
18498c2ecf20Sopenharmony_ci	return 0;
18508c2ecf20Sopenharmony_ci}
18518c2ecf20Sopenharmony_ci
18528c2ecf20Sopenharmony_cistatic int ring_reset_ctl_write(struct intel_vgpu *vgpu,
18538c2ecf20Sopenharmony_ci	unsigned int offset, void *p_data, unsigned int bytes)
18548c2ecf20Sopenharmony_ci{
18558c2ecf20Sopenharmony_ci	u32 data;
18568c2ecf20Sopenharmony_ci
18578c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
18588c2ecf20Sopenharmony_ci	data = vgpu_vreg(vgpu, offset);
18598c2ecf20Sopenharmony_ci
18608c2ecf20Sopenharmony_ci	if (IS_MASKED_BITS_ENABLED(data, RESET_CTL_REQUEST_RESET))
18618c2ecf20Sopenharmony_ci		data |= RESET_CTL_READY_TO_RESET;
18628c2ecf20Sopenharmony_ci	else if (data & _MASKED_BIT_DISABLE(RESET_CTL_REQUEST_RESET))
18638c2ecf20Sopenharmony_ci		data &= ~RESET_CTL_READY_TO_RESET;
18648c2ecf20Sopenharmony_ci
18658c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = data;
18668c2ecf20Sopenharmony_ci	return 0;
18678c2ecf20Sopenharmony_ci}
18688c2ecf20Sopenharmony_ci
18698c2ecf20Sopenharmony_cistatic int csfe_chicken1_mmio_write(struct intel_vgpu *vgpu,
18708c2ecf20Sopenharmony_ci				    unsigned int offset, void *p_data,
18718c2ecf20Sopenharmony_ci				    unsigned int bytes)
18728c2ecf20Sopenharmony_ci{
18738c2ecf20Sopenharmony_ci	u32 data = *(u32 *)p_data;
18748c2ecf20Sopenharmony_ci
18758c2ecf20Sopenharmony_ci	(*(u32 *)p_data) &= ~_MASKED_BIT_ENABLE(0x18);
18768c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
18778c2ecf20Sopenharmony_ci
18788c2ecf20Sopenharmony_ci	if (IS_MASKED_BITS_ENABLED(data, 0x10) ||
18798c2ecf20Sopenharmony_ci	    IS_MASKED_BITS_ENABLED(data, 0x8))
18808c2ecf20Sopenharmony_ci		enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
18818c2ecf20Sopenharmony_ci
18828c2ecf20Sopenharmony_ci	return 0;
18838c2ecf20Sopenharmony_ci}
18848c2ecf20Sopenharmony_ci
18858c2ecf20Sopenharmony_ci#define MMIO_F(reg, s, f, am, rm, d, r, w) do { \
18868c2ecf20Sopenharmony_ci	ret = new_mmio_info(gvt, i915_mmio_reg_offset(reg), \
18878c2ecf20Sopenharmony_ci		f, s, am, rm, d, r, w); \
18888c2ecf20Sopenharmony_ci	if (ret) \
18898c2ecf20Sopenharmony_ci		return ret; \
18908c2ecf20Sopenharmony_ci} while (0)
18918c2ecf20Sopenharmony_ci
18928c2ecf20Sopenharmony_ci#define MMIO_D(reg, d) \
18938c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, 0, 0, 0, d, NULL, NULL)
18948c2ecf20Sopenharmony_ci
18958c2ecf20Sopenharmony_ci#define MMIO_DH(reg, d, r, w) \
18968c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, 0, 0, 0, d, r, w)
18978c2ecf20Sopenharmony_ci
18988c2ecf20Sopenharmony_ci#define MMIO_DFH(reg, d, f, r, w) \
18998c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, f, 0, 0, d, r, w)
19008c2ecf20Sopenharmony_ci
19018c2ecf20Sopenharmony_ci#define MMIO_GM(reg, d, r, w) \
19028c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, F_GMADR, 0xFFFFF000, 0, d, r, w)
19038c2ecf20Sopenharmony_ci
19048c2ecf20Sopenharmony_ci#define MMIO_GM_RDR(reg, d, r, w) \
19058c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, F_GMADR | F_CMD_ACCESS, 0xFFFFF000, 0, d, r, w)
19068c2ecf20Sopenharmony_ci
19078c2ecf20Sopenharmony_ci#define MMIO_RO(reg, d, f, rm, r, w) \
19088c2ecf20Sopenharmony_ci	MMIO_F(reg, 4, F_RO | f, 0, rm, d, r, w)
19098c2ecf20Sopenharmony_ci
19108c2ecf20Sopenharmony_ci#define MMIO_RING_F(prefix, s, f, am, rm, d, r, w) do { \
19118c2ecf20Sopenharmony_ci	MMIO_F(prefix(RENDER_RING_BASE), s, f, am, rm, d, r, w); \
19128c2ecf20Sopenharmony_ci	MMIO_F(prefix(BLT_RING_BASE), s, f, am, rm, d, r, w); \
19138c2ecf20Sopenharmony_ci	MMIO_F(prefix(GEN6_BSD_RING_BASE), s, f, am, rm, d, r, w); \
19148c2ecf20Sopenharmony_ci	MMIO_F(prefix(VEBOX_RING_BASE), s, f, am, rm, d, r, w); \
19158c2ecf20Sopenharmony_ci	if (HAS_ENGINE(gvt->gt, VCS1)) \
19168c2ecf20Sopenharmony_ci		MMIO_F(prefix(GEN8_BSD2_RING_BASE), s, f, am, rm, d, r, w); \
19178c2ecf20Sopenharmony_ci} while (0)
19188c2ecf20Sopenharmony_ci
19198c2ecf20Sopenharmony_ci#define MMIO_RING_D(prefix, d) \
19208c2ecf20Sopenharmony_ci	MMIO_RING_F(prefix, 4, 0, 0, 0, d, NULL, NULL)
19218c2ecf20Sopenharmony_ci
19228c2ecf20Sopenharmony_ci#define MMIO_RING_DFH(prefix, d, f, r, w) \
19238c2ecf20Sopenharmony_ci	MMIO_RING_F(prefix, 4, f, 0, 0, d, r, w)
19248c2ecf20Sopenharmony_ci
19258c2ecf20Sopenharmony_ci#define MMIO_RING_GM(prefix, d, r, w) \
19268c2ecf20Sopenharmony_ci	MMIO_RING_F(prefix, 4, F_GMADR, 0xFFFF0000, 0, d, r, w)
19278c2ecf20Sopenharmony_ci
19288c2ecf20Sopenharmony_ci#define MMIO_RING_GM_RDR(prefix, d, r, w) \
19298c2ecf20Sopenharmony_ci	MMIO_RING_F(prefix, 4, F_GMADR | F_CMD_ACCESS, 0xFFFF0000, 0, d, r, w)
19308c2ecf20Sopenharmony_ci
19318c2ecf20Sopenharmony_ci#define MMIO_RING_RO(prefix, d, f, rm, r, w) \
19328c2ecf20Sopenharmony_ci	MMIO_RING_F(prefix, 4, F_RO | f, 0, rm, d, r, w)
19338c2ecf20Sopenharmony_ci
19348c2ecf20Sopenharmony_cistatic int init_generic_mmio_info(struct intel_gvt *gvt)
19358c2ecf20Sopenharmony_ci{
19368c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = gvt->gt->i915;
19378c2ecf20Sopenharmony_ci	int ret;
19388c2ecf20Sopenharmony_ci
19398c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_IMR, D_ALL, 0, NULL,
19408c2ecf20Sopenharmony_ci		intel_vgpu_reg_imr_handler);
19418c2ecf20Sopenharmony_ci
19428c2ecf20Sopenharmony_ci	MMIO_DFH(SDEIMR, D_ALL, 0, NULL, intel_vgpu_reg_imr_handler);
19438c2ecf20Sopenharmony_ci	MMIO_DFH(SDEIER, D_ALL, 0, NULL, intel_vgpu_reg_ier_handler);
19448c2ecf20Sopenharmony_ci	MMIO_DFH(SDEIIR, D_ALL, 0, NULL, intel_vgpu_reg_iir_handler);
19458c2ecf20Sopenharmony_ci	MMIO_D(SDEISR, D_ALL);
19468c2ecf20Sopenharmony_ci
19478c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_HWSTAM, D_ALL, 0, NULL, NULL);
19488c2ecf20Sopenharmony_ci
19498c2ecf20Sopenharmony_ci
19508c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GAMW_ECO_DEV_RW_IA, D_BDW_PLUS, NULL,
19518c2ecf20Sopenharmony_ci		gamw_echo_dev_rw_ia_write);
19528c2ecf20Sopenharmony_ci
19538c2ecf20Sopenharmony_ci	MMIO_GM_RDR(BSD_HWS_PGA_GEN7, D_ALL, NULL, NULL);
19548c2ecf20Sopenharmony_ci	MMIO_GM_RDR(BLT_HWS_PGA_GEN7, D_ALL, NULL, NULL);
19558c2ecf20Sopenharmony_ci	MMIO_GM_RDR(VEBOX_HWS_PGA_GEN7, D_ALL, NULL, NULL);
19568c2ecf20Sopenharmony_ci
19578c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x28)
19588c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_ALL, F_CMD_ACCESS, NULL, NULL);
19598c2ecf20Sopenharmony_ci#undef RING_REG
19608c2ecf20Sopenharmony_ci
19618c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x134)
19628c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_ALL, F_CMD_ACCESS, NULL, NULL);
19638c2ecf20Sopenharmony_ci#undef RING_REG
19648c2ecf20Sopenharmony_ci
19658c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x6c)
19668c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_ALL, 0, mmio_read_from_hw, NULL);
19678c2ecf20Sopenharmony_ci#undef RING_REG
19688c2ecf20Sopenharmony_ci	MMIO_DH(GEN7_SC_INSTDONE, D_BDW_PLUS, mmio_read_from_hw, NULL);
19698c2ecf20Sopenharmony_ci
19708c2ecf20Sopenharmony_ci	MMIO_GM_RDR(_MMIO(0x2148), D_ALL, NULL, NULL);
19718c2ecf20Sopenharmony_ci	MMIO_GM_RDR(CCID(RENDER_RING_BASE), D_ALL, NULL, NULL);
19728c2ecf20Sopenharmony_ci	MMIO_GM_RDR(_MMIO(0x12198), D_ALL, NULL, NULL);
19738c2ecf20Sopenharmony_ci	MMIO_D(GEN7_CXT_SIZE, D_ALL);
19748c2ecf20Sopenharmony_ci
19758c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_TAIL, D_ALL, 0, NULL, NULL);
19768c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_HEAD, D_ALL, 0, NULL, NULL);
19778c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_CTL, D_ALL, 0, NULL, NULL);
19788c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_ACTHD, D_ALL, 0, mmio_read_from_hw, NULL);
19798c2ecf20Sopenharmony_ci	MMIO_RING_GM(RING_START, D_ALL, NULL, NULL);
19808c2ecf20Sopenharmony_ci
19818c2ecf20Sopenharmony_ci	/* RING MODE */
19828c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x29c)
19838c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL,
19848c2ecf20Sopenharmony_ci		ring_mode_mmio_write);
19858c2ecf20Sopenharmony_ci#undef RING_REG
19868c2ecf20Sopenharmony_ci
19878c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_MI_MODE, D_ALL, F_MODE_MASK | F_CMD_ACCESS,
19888c2ecf20Sopenharmony_ci		NULL, NULL);
19898c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_INSTPM, D_ALL, F_MODE_MASK | F_CMD_ACCESS,
19908c2ecf20Sopenharmony_ci			NULL, NULL);
19918c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_TIMESTAMP, D_ALL, F_CMD_ACCESS,
19928c2ecf20Sopenharmony_ci			mmio_read_from_hw, NULL);
19938c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_TIMESTAMP_UDW, D_ALL, F_CMD_ACCESS,
19948c2ecf20Sopenharmony_ci			mmio_read_from_hw, NULL);
19958c2ecf20Sopenharmony_ci
19968c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_GT_MODE, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
19978c2ecf20Sopenharmony_ci	MMIO_DFH(CACHE_MODE_0_GEN7, D_ALL, F_MODE_MASK | F_CMD_ACCESS,
19988c2ecf20Sopenharmony_ci		NULL, NULL);
19998c2ecf20Sopenharmony_ci	MMIO_DFH(CACHE_MODE_1, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20008c2ecf20Sopenharmony_ci	MMIO_DFH(CACHE_MODE_0, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20018c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2124), D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20028c2ecf20Sopenharmony_ci
20038c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x20dc), D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20048c2ecf20Sopenharmony_ci	MMIO_DFH(_3D_CHICKEN3, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20058c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2088), D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20068c2ecf20Sopenharmony_ci	MMIO_DFH(FF_SLICE_CS_CHICKEN2, D_ALL,
20078c2ecf20Sopenharmony_ci		 F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20088c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2470), D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20098c2ecf20Sopenharmony_ci	MMIO_DFH(GAM_ECOCHK, D_ALL, F_CMD_ACCESS, NULL, NULL);
20108c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_COMMON_SLICE_CHICKEN1, D_ALL, F_MODE_MASK | F_CMD_ACCESS,
20118c2ecf20Sopenharmony_ci		NULL, NULL);
20128c2ecf20Sopenharmony_ci	MMIO_DFH(COMMON_SLICE_CHICKEN2, D_ALL, F_MODE_MASK | F_CMD_ACCESS,
20138c2ecf20Sopenharmony_ci		 NULL, NULL);
20148c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x9030), D_ALL, F_CMD_ACCESS, NULL, NULL);
20158c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x20a0), D_ALL, F_CMD_ACCESS, NULL, NULL);
20168c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2420), D_ALL, F_CMD_ACCESS, NULL, NULL);
20178c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2430), D_ALL, F_CMD_ACCESS, NULL, NULL);
20188c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2434), D_ALL, F_CMD_ACCESS, NULL, NULL);
20198c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2438), D_ALL, F_CMD_ACCESS, NULL, NULL);
20208c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x243c), D_ALL, F_CMD_ACCESS, NULL, NULL);
20218c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x7018), D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20228c2ecf20Sopenharmony_ci	MMIO_DFH(HALF_SLICE_CHICKEN3, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20238c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_HALF_SLICE_CHICKEN1, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
20248c2ecf20Sopenharmony_ci
20258c2ecf20Sopenharmony_ci	/* display */
20268c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x60220), 0x20, 0, 0, 0, D_ALL, NULL, NULL);
20278c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x602a0), D_ALL);
20288c2ecf20Sopenharmony_ci
20298c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x65050), D_ALL);
20308c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x650b4), D_ALL);
20318c2ecf20Sopenharmony_ci
20328c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xc4040), D_ALL);
20338c2ecf20Sopenharmony_ci	MMIO_D(DERRMR, D_ALL);
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_ci	MMIO_D(PIPEDSL(PIPE_A), D_ALL);
20368c2ecf20Sopenharmony_ci	MMIO_D(PIPEDSL(PIPE_B), D_ALL);
20378c2ecf20Sopenharmony_ci	MMIO_D(PIPEDSL(PIPE_C), D_ALL);
20388c2ecf20Sopenharmony_ci	MMIO_D(PIPEDSL(_PIPE_EDP), D_ALL);
20398c2ecf20Sopenharmony_ci
20408c2ecf20Sopenharmony_ci	MMIO_DH(PIPECONF(PIPE_A), D_ALL, NULL, pipeconf_mmio_write);
20418c2ecf20Sopenharmony_ci	MMIO_DH(PIPECONF(PIPE_B), D_ALL, NULL, pipeconf_mmio_write);
20428c2ecf20Sopenharmony_ci	MMIO_DH(PIPECONF(PIPE_C), D_ALL, NULL, pipeconf_mmio_write);
20438c2ecf20Sopenharmony_ci	MMIO_DH(PIPECONF(_PIPE_EDP), D_ALL, NULL, pipeconf_mmio_write);
20448c2ecf20Sopenharmony_ci
20458c2ecf20Sopenharmony_ci	MMIO_D(PIPESTAT(PIPE_A), D_ALL);
20468c2ecf20Sopenharmony_ci	MMIO_D(PIPESTAT(PIPE_B), D_ALL);
20478c2ecf20Sopenharmony_ci	MMIO_D(PIPESTAT(PIPE_C), D_ALL);
20488c2ecf20Sopenharmony_ci	MMIO_D(PIPESTAT(_PIPE_EDP), D_ALL);
20498c2ecf20Sopenharmony_ci
20508c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FLIPCOUNT_G4X(PIPE_A), D_ALL);
20518c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FLIPCOUNT_G4X(PIPE_B), D_ALL);
20528c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FLIPCOUNT_G4X(PIPE_C), D_ALL);
20538c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FLIPCOUNT_G4X(_PIPE_EDP), D_ALL);
20548c2ecf20Sopenharmony_ci
20558c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FRMCOUNT_G4X(PIPE_A), D_ALL);
20568c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FRMCOUNT_G4X(PIPE_B), D_ALL);
20578c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FRMCOUNT_G4X(PIPE_C), D_ALL);
20588c2ecf20Sopenharmony_ci	MMIO_D(PIPE_FRMCOUNT_G4X(_PIPE_EDP), D_ALL);
20598c2ecf20Sopenharmony_ci
20608c2ecf20Sopenharmony_ci	MMIO_D(CURCNTR(PIPE_A), D_ALL);
20618c2ecf20Sopenharmony_ci	MMIO_D(CURCNTR(PIPE_B), D_ALL);
20628c2ecf20Sopenharmony_ci	MMIO_D(CURCNTR(PIPE_C), D_ALL);
20638c2ecf20Sopenharmony_ci
20648c2ecf20Sopenharmony_ci	MMIO_D(CURPOS(PIPE_A), D_ALL);
20658c2ecf20Sopenharmony_ci	MMIO_D(CURPOS(PIPE_B), D_ALL);
20668c2ecf20Sopenharmony_ci	MMIO_D(CURPOS(PIPE_C), D_ALL);
20678c2ecf20Sopenharmony_ci
20688c2ecf20Sopenharmony_ci	MMIO_D(CURBASE(PIPE_A), D_ALL);
20698c2ecf20Sopenharmony_ci	MMIO_D(CURBASE(PIPE_B), D_ALL);
20708c2ecf20Sopenharmony_ci	MMIO_D(CURBASE(PIPE_C), D_ALL);
20718c2ecf20Sopenharmony_ci
20728c2ecf20Sopenharmony_ci	MMIO_D(CUR_FBC_CTL(PIPE_A), D_ALL);
20738c2ecf20Sopenharmony_ci	MMIO_D(CUR_FBC_CTL(PIPE_B), D_ALL);
20748c2ecf20Sopenharmony_ci	MMIO_D(CUR_FBC_CTL(PIPE_C), D_ALL);
20758c2ecf20Sopenharmony_ci
20768c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x700ac), D_ALL);
20778c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x710ac), D_ALL);
20788c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x720ac), D_ALL);
20798c2ecf20Sopenharmony_ci
20808c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x70090), D_ALL);
20818c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x70094), D_ALL);
20828c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x70098), D_ALL);
20838c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7009c), D_ALL);
20848c2ecf20Sopenharmony_ci
20858c2ecf20Sopenharmony_ci	MMIO_D(DSPCNTR(PIPE_A), D_ALL);
20868c2ecf20Sopenharmony_ci	MMIO_D(DSPADDR(PIPE_A), D_ALL);
20878c2ecf20Sopenharmony_ci	MMIO_D(DSPSTRIDE(PIPE_A), D_ALL);
20888c2ecf20Sopenharmony_ci	MMIO_D(DSPPOS(PIPE_A), D_ALL);
20898c2ecf20Sopenharmony_ci	MMIO_D(DSPSIZE(PIPE_A), D_ALL);
20908c2ecf20Sopenharmony_ci	MMIO_DH(DSPSURF(PIPE_A), D_ALL, NULL, pri_surf_mmio_write);
20918c2ecf20Sopenharmony_ci	MMIO_D(DSPOFFSET(PIPE_A), D_ALL);
20928c2ecf20Sopenharmony_ci	MMIO_D(DSPSURFLIVE(PIPE_A), D_ALL);
20938c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_A, PLANE_PRIMARY), D_ALL, NULL,
20948c2ecf20Sopenharmony_ci		reg50080_mmio_write);
20958c2ecf20Sopenharmony_ci
20968c2ecf20Sopenharmony_ci	MMIO_D(DSPCNTR(PIPE_B), D_ALL);
20978c2ecf20Sopenharmony_ci	MMIO_D(DSPADDR(PIPE_B), D_ALL);
20988c2ecf20Sopenharmony_ci	MMIO_D(DSPSTRIDE(PIPE_B), D_ALL);
20998c2ecf20Sopenharmony_ci	MMIO_D(DSPPOS(PIPE_B), D_ALL);
21008c2ecf20Sopenharmony_ci	MMIO_D(DSPSIZE(PIPE_B), D_ALL);
21018c2ecf20Sopenharmony_ci	MMIO_DH(DSPSURF(PIPE_B), D_ALL, NULL, pri_surf_mmio_write);
21028c2ecf20Sopenharmony_ci	MMIO_D(DSPOFFSET(PIPE_B), D_ALL);
21038c2ecf20Sopenharmony_ci	MMIO_D(DSPSURFLIVE(PIPE_B), D_ALL);
21048c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_B, PLANE_PRIMARY), D_ALL, NULL,
21058c2ecf20Sopenharmony_ci		reg50080_mmio_write);
21068c2ecf20Sopenharmony_ci
21078c2ecf20Sopenharmony_ci	MMIO_D(DSPCNTR(PIPE_C), D_ALL);
21088c2ecf20Sopenharmony_ci	MMIO_D(DSPADDR(PIPE_C), D_ALL);
21098c2ecf20Sopenharmony_ci	MMIO_D(DSPSTRIDE(PIPE_C), D_ALL);
21108c2ecf20Sopenharmony_ci	MMIO_D(DSPPOS(PIPE_C), D_ALL);
21118c2ecf20Sopenharmony_ci	MMIO_D(DSPSIZE(PIPE_C), D_ALL);
21128c2ecf20Sopenharmony_ci	MMIO_DH(DSPSURF(PIPE_C), D_ALL, NULL, pri_surf_mmio_write);
21138c2ecf20Sopenharmony_ci	MMIO_D(DSPOFFSET(PIPE_C), D_ALL);
21148c2ecf20Sopenharmony_ci	MMIO_D(DSPSURFLIVE(PIPE_C), D_ALL);
21158c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_C, PLANE_PRIMARY), D_ALL, NULL,
21168c2ecf20Sopenharmony_ci		reg50080_mmio_write);
21178c2ecf20Sopenharmony_ci
21188c2ecf20Sopenharmony_ci	MMIO_D(SPRCTL(PIPE_A), D_ALL);
21198c2ecf20Sopenharmony_ci	MMIO_D(SPRLINOFF(PIPE_A), D_ALL);
21208c2ecf20Sopenharmony_ci	MMIO_D(SPRSTRIDE(PIPE_A), D_ALL);
21218c2ecf20Sopenharmony_ci	MMIO_D(SPRPOS(PIPE_A), D_ALL);
21228c2ecf20Sopenharmony_ci	MMIO_D(SPRSIZE(PIPE_A), D_ALL);
21238c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYVAL(PIPE_A), D_ALL);
21248c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMSK(PIPE_A), D_ALL);
21258c2ecf20Sopenharmony_ci	MMIO_DH(SPRSURF(PIPE_A), D_ALL, NULL, spr_surf_mmio_write);
21268c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMAX(PIPE_A), D_ALL);
21278c2ecf20Sopenharmony_ci	MMIO_D(SPROFFSET(PIPE_A), D_ALL);
21288c2ecf20Sopenharmony_ci	MMIO_D(SPRSCALE(PIPE_A), D_ALL);
21298c2ecf20Sopenharmony_ci	MMIO_D(SPRSURFLIVE(PIPE_A), D_ALL);
21308c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_A, PLANE_SPRITE0), D_ALL, NULL,
21318c2ecf20Sopenharmony_ci		reg50080_mmio_write);
21328c2ecf20Sopenharmony_ci
21338c2ecf20Sopenharmony_ci	MMIO_D(SPRCTL(PIPE_B), D_ALL);
21348c2ecf20Sopenharmony_ci	MMIO_D(SPRLINOFF(PIPE_B), D_ALL);
21358c2ecf20Sopenharmony_ci	MMIO_D(SPRSTRIDE(PIPE_B), D_ALL);
21368c2ecf20Sopenharmony_ci	MMIO_D(SPRPOS(PIPE_B), D_ALL);
21378c2ecf20Sopenharmony_ci	MMIO_D(SPRSIZE(PIPE_B), D_ALL);
21388c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYVAL(PIPE_B), D_ALL);
21398c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMSK(PIPE_B), D_ALL);
21408c2ecf20Sopenharmony_ci	MMIO_DH(SPRSURF(PIPE_B), D_ALL, NULL, spr_surf_mmio_write);
21418c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMAX(PIPE_B), D_ALL);
21428c2ecf20Sopenharmony_ci	MMIO_D(SPROFFSET(PIPE_B), D_ALL);
21438c2ecf20Sopenharmony_ci	MMIO_D(SPRSCALE(PIPE_B), D_ALL);
21448c2ecf20Sopenharmony_ci	MMIO_D(SPRSURFLIVE(PIPE_B), D_ALL);
21458c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_B, PLANE_SPRITE0), D_ALL, NULL,
21468c2ecf20Sopenharmony_ci		reg50080_mmio_write);
21478c2ecf20Sopenharmony_ci
21488c2ecf20Sopenharmony_ci	MMIO_D(SPRCTL(PIPE_C), D_ALL);
21498c2ecf20Sopenharmony_ci	MMIO_D(SPRLINOFF(PIPE_C), D_ALL);
21508c2ecf20Sopenharmony_ci	MMIO_D(SPRSTRIDE(PIPE_C), D_ALL);
21518c2ecf20Sopenharmony_ci	MMIO_D(SPRPOS(PIPE_C), D_ALL);
21528c2ecf20Sopenharmony_ci	MMIO_D(SPRSIZE(PIPE_C), D_ALL);
21538c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYVAL(PIPE_C), D_ALL);
21548c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMSK(PIPE_C), D_ALL);
21558c2ecf20Sopenharmony_ci	MMIO_DH(SPRSURF(PIPE_C), D_ALL, NULL, spr_surf_mmio_write);
21568c2ecf20Sopenharmony_ci	MMIO_D(SPRKEYMAX(PIPE_C), D_ALL);
21578c2ecf20Sopenharmony_ci	MMIO_D(SPROFFSET(PIPE_C), D_ALL);
21588c2ecf20Sopenharmony_ci	MMIO_D(SPRSCALE(PIPE_C), D_ALL);
21598c2ecf20Sopenharmony_ci	MMIO_D(SPRSURFLIVE(PIPE_C), D_ALL);
21608c2ecf20Sopenharmony_ci	MMIO_DH(REG_50080(PIPE_C, PLANE_SPRITE0), D_ALL, NULL,
21618c2ecf20Sopenharmony_ci		reg50080_mmio_write);
21628c2ecf20Sopenharmony_ci
21638c2ecf20Sopenharmony_ci	MMIO_D(HTOTAL(TRANSCODER_A), D_ALL);
21648c2ecf20Sopenharmony_ci	MMIO_D(HBLANK(TRANSCODER_A), D_ALL);
21658c2ecf20Sopenharmony_ci	MMIO_D(HSYNC(TRANSCODER_A), D_ALL);
21668c2ecf20Sopenharmony_ci	MMIO_D(VTOTAL(TRANSCODER_A), D_ALL);
21678c2ecf20Sopenharmony_ci	MMIO_D(VBLANK(TRANSCODER_A), D_ALL);
21688c2ecf20Sopenharmony_ci	MMIO_D(VSYNC(TRANSCODER_A), D_ALL);
21698c2ecf20Sopenharmony_ci	MMIO_D(BCLRPAT(TRANSCODER_A), D_ALL);
21708c2ecf20Sopenharmony_ci	MMIO_D(VSYNCSHIFT(TRANSCODER_A), D_ALL);
21718c2ecf20Sopenharmony_ci	MMIO_D(PIPESRC(TRANSCODER_A), D_ALL);
21728c2ecf20Sopenharmony_ci
21738c2ecf20Sopenharmony_ci	MMIO_D(HTOTAL(TRANSCODER_B), D_ALL);
21748c2ecf20Sopenharmony_ci	MMIO_D(HBLANK(TRANSCODER_B), D_ALL);
21758c2ecf20Sopenharmony_ci	MMIO_D(HSYNC(TRANSCODER_B), D_ALL);
21768c2ecf20Sopenharmony_ci	MMIO_D(VTOTAL(TRANSCODER_B), D_ALL);
21778c2ecf20Sopenharmony_ci	MMIO_D(VBLANK(TRANSCODER_B), D_ALL);
21788c2ecf20Sopenharmony_ci	MMIO_D(VSYNC(TRANSCODER_B), D_ALL);
21798c2ecf20Sopenharmony_ci	MMIO_D(BCLRPAT(TRANSCODER_B), D_ALL);
21808c2ecf20Sopenharmony_ci	MMIO_D(VSYNCSHIFT(TRANSCODER_B), D_ALL);
21818c2ecf20Sopenharmony_ci	MMIO_D(PIPESRC(TRANSCODER_B), D_ALL);
21828c2ecf20Sopenharmony_ci
21838c2ecf20Sopenharmony_ci	MMIO_D(HTOTAL(TRANSCODER_C), D_ALL);
21848c2ecf20Sopenharmony_ci	MMIO_D(HBLANK(TRANSCODER_C), D_ALL);
21858c2ecf20Sopenharmony_ci	MMIO_D(HSYNC(TRANSCODER_C), D_ALL);
21868c2ecf20Sopenharmony_ci	MMIO_D(VTOTAL(TRANSCODER_C), D_ALL);
21878c2ecf20Sopenharmony_ci	MMIO_D(VBLANK(TRANSCODER_C), D_ALL);
21888c2ecf20Sopenharmony_ci	MMIO_D(VSYNC(TRANSCODER_C), D_ALL);
21898c2ecf20Sopenharmony_ci	MMIO_D(BCLRPAT(TRANSCODER_C), D_ALL);
21908c2ecf20Sopenharmony_ci	MMIO_D(VSYNCSHIFT(TRANSCODER_C), D_ALL);
21918c2ecf20Sopenharmony_ci	MMIO_D(PIPESRC(TRANSCODER_C), D_ALL);
21928c2ecf20Sopenharmony_ci
21938c2ecf20Sopenharmony_ci	MMIO_D(HTOTAL(TRANSCODER_EDP), D_ALL);
21948c2ecf20Sopenharmony_ci	MMIO_D(HBLANK(TRANSCODER_EDP), D_ALL);
21958c2ecf20Sopenharmony_ci	MMIO_D(HSYNC(TRANSCODER_EDP), D_ALL);
21968c2ecf20Sopenharmony_ci	MMIO_D(VTOTAL(TRANSCODER_EDP), D_ALL);
21978c2ecf20Sopenharmony_ci	MMIO_D(VBLANK(TRANSCODER_EDP), D_ALL);
21988c2ecf20Sopenharmony_ci	MMIO_D(VSYNC(TRANSCODER_EDP), D_ALL);
21998c2ecf20Sopenharmony_ci	MMIO_D(BCLRPAT(TRANSCODER_EDP), D_ALL);
22008c2ecf20Sopenharmony_ci	MMIO_D(VSYNCSHIFT(TRANSCODER_EDP), D_ALL);
22018c2ecf20Sopenharmony_ci
22028c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M1(TRANSCODER_A), D_ALL);
22038c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N1(TRANSCODER_A), D_ALL);
22048c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M2(TRANSCODER_A), D_ALL);
22058c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N2(TRANSCODER_A), D_ALL);
22068c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M1(TRANSCODER_A), D_ALL);
22078c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N1(TRANSCODER_A), D_ALL);
22088c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M2(TRANSCODER_A), D_ALL);
22098c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N2(TRANSCODER_A), D_ALL);
22108c2ecf20Sopenharmony_ci
22118c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M1(TRANSCODER_B), D_ALL);
22128c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N1(TRANSCODER_B), D_ALL);
22138c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M2(TRANSCODER_B), D_ALL);
22148c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N2(TRANSCODER_B), D_ALL);
22158c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M1(TRANSCODER_B), D_ALL);
22168c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N1(TRANSCODER_B), D_ALL);
22178c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M2(TRANSCODER_B), D_ALL);
22188c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N2(TRANSCODER_B), D_ALL);
22198c2ecf20Sopenharmony_ci
22208c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M1(TRANSCODER_C), D_ALL);
22218c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N1(TRANSCODER_C), D_ALL);
22228c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M2(TRANSCODER_C), D_ALL);
22238c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N2(TRANSCODER_C), D_ALL);
22248c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M1(TRANSCODER_C), D_ALL);
22258c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N1(TRANSCODER_C), D_ALL);
22268c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M2(TRANSCODER_C), D_ALL);
22278c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N2(TRANSCODER_C), D_ALL);
22288c2ecf20Sopenharmony_ci
22298c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M1(TRANSCODER_EDP), D_ALL);
22308c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N1(TRANSCODER_EDP), D_ALL);
22318c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_M2(TRANSCODER_EDP), D_ALL);
22328c2ecf20Sopenharmony_ci	MMIO_D(PIPE_DATA_N2(TRANSCODER_EDP), D_ALL);
22338c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M1(TRANSCODER_EDP), D_ALL);
22348c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N1(TRANSCODER_EDP), D_ALL);
22358c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_M2(TRANSCODER_EDP), D_ALL);
22368c2ecf20Sopenharmony_ci	MMIO_D(PIPE_LINK_N2(TRANSCODER_EDP), D_ALL);
22378c2ecf20Sopenharmony_ci
22388c2ecf20Sopenharmony_ci	MMIO_D(PF_CTL(PIPE_A), D_ALL);
22398c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_SZ(PIPE_A), D_ALL);
22408c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_POS(PIPE_A), D_ALL);
22418c2ecf20Sopenharmony_ci	MMIO_D(PF_VSCALE(PIPE_A), D_ALL);
22428c2ecf20Sopenharmony_ci	MMIO_D(PF_HSCALE(PIPE_A), D_ALL);
22438c2ecf20Sopenharmony_ci
22448c2ecf20Sopenharmony_ci	MMIO_D(PF_CTL(PIPE_B), D_ALL);
22458c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_SZ(PIPE_B), D_ALL);
22468c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_POS(PIPE_B), D_ALL);
22478c2ecf20Sopenharmony_ci	MMIO_D(PF_VSCALE(PIPE_B), D_ALL);
22488c2ecf20Sopenharmony_ci	MMIO_D(PF_HSCALE(PIPE_B), D_ALL);
22498c2ecf20Sopenharmony_ci
22508c2ecf20Sopenharmony_ci	MMIO_D(PF_CTL(PIPE_C), D_ALL);
22518c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_SZ(PIPE_C), D_ALL);
22528c2ecf20Sopenharmony_ci	MMIO_D(PF_WIN_POS(PIPE_C), D_ALL);
22538c2ecf20Sopenharmony_ci	MMIO_D(PF_VSCALE(PIPE_C), D_ALL);
22548c2ecf20Sopenharmony_ci	MMIO_D(PF_HSCALE(PIPE_C), D_ALL);
22558c2ecf20Sopenharmony_ci
22568c2ecf20Sopenharmony_ci	MMIO_D(WM0_PIPEA_ILK, D_ALL);
22578c2ecf20Sopenharmony_ci	MMIO_D(WM0_PIPEB_ILK, D_ALL);
22588c2ecf20Sopenharmony_ci	MMIO_D(WM0_PIPEC_IVB, D_ALL);
22598c2ecf20Sopenharmony_ci	MMIO_D(WM1_LP_ILK, D_ALL);
22608c2ecf20Sopenharmony_ci	MMIO_D(WM2_LP_ILK, D_ALL);
22618c2ecf20Sopenharmony_ci	MMIO_D(WM3_LP_ILK, D_ALL);
22628c2ecf20Sopenharmony_ci	MMIO_D(WM1S_LP_ILK, D_ALL);
22638c2ecf20Sopenharmony_ci	MMIO_D(WM2S_LP_IVB, D_ALL);
22648c2ecf20Sopenharmony_ci	MMIO_D(WM3S_LP_IVB, D_ALL);
22658c2ecf20Sopenharmony_ci
22668c2ecf20Sopenharmony_ci	MMIO_D(BLC_PWM_CPU_CTL2, D_ALL);
22678c2ecf20Sopenharmony_ci	MMIO_D(BLC_PWM_CPU_CTL, D_ALL);
22688c2ecf20Sopenharmony_ci	MMIO_D(BLC_PWM_PCH_CTL1, D_ALL);
22698c2ecf20Sopenharmony_ci	MMIO_D(BLC_PWM_PCH_CTL2, D_ALL);
22708c2ecf20Sopenharmony_ci
22718c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x48268), D_ALL);
22728c2ecf20Sopenharmony_ci
22738c2ecf20Sopenharmony_ci	MMIO_F(PCH_GMBUS0, 4 * 4, 0, 0, 0, D_ALL, gmbus_mmio_read,
22748c2ecf20Sopenharmony_ci		gmbus_mmio_write);
22758c2ecf20Sopenharmony_ci	MMIO_F(PCH_GPIO_BASE, 6 * 4, F_UNALIGN, 0, 0, D_ALL, NULL, NULL);
22768c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0xe4f00), 0x28, 0, 0, 0, D_ALL, NULL, NULL);
22778c2ecf20Sopenharmony_ci
22788c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(_PCH_DPB_AUX_CH_CTL), 6 * 4, 0, 0, 0, D_PRE_SKL, NULL,
22798c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_mmio_write);
22808c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(_PCH_DPC_AUX_CH_CTL), 6 * 4, 0, 0, 0, D_PRE_SKL, NULL,
22818c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_mmio_write);
22828c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(_PCH_DPD_AUX_CH_CTL), 6 * 4, 0, 0, 0, D_PRE_SKL, NULL,
22838c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_mmio_write);
22848c2ecf20Sopenharmony_ci
22858c2ecf20Sopenharmony_ci	MMIO_DH(PCH_ADPA, D_PRE_SKL, NULL, pch_adpa_mmio_write);
22868c2ecf20Sopenharmony_ci
22878c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_PCH_TRANSACONF), D_ALL, NULL, transconf_mmio_write);
22888c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_PCH_TRANSBCONF), D_ALL, NULL, transconf_mmio_write);
22898c2ecf20Sopenharmony_ci
22908c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IIR(PIPE_A), D_ALL, NULL, fdi_rx_iir_mmio_write);
22918c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IIR(PIPE_B), D_ALL, NULL, fdi_rx_iir_mmio_write);
22928c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IIR(PIPE_C), D_ALL, NULL, fdi_rx_iir_mmio_write);
22938c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IMR(PIPE_A), D_ALL, NULL, update_fdi_rx_iir_status);
22948c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IMR(PIPE_B), D_ALL, NULL, update_fdi_rx_iir_status);
22958c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_IMR(PIPE_C), D_ALL, NULL, update_fdi_rx_iir_status);
22968c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_CTL(PIPE_A), D_ALL, NULL, update_fdi_rx_iir_status);
22978c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_CTL(PIPE_B), D_ALL, NULL, update_fdi_rx_iir_status);
22988c2ecf20Sopenharmony_ci	MMIO_DH(FDI_RX_CTL(PIPE_C), D_ALL, NULL, update_fdi_rx_iir_status);
22998c2ecf20Sopenharmony_ci
23008c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HTOTAL_A), D_ALL);
23018c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HBLANK_A), D_ALL);
23028c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HSYNC_A), D_ALL);
23038c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VTOTAL_A), D_ALL);
23048c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VBLANK_A), D_ALL);
23058c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VSYNC_A), D_ALL);
23068c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VSYNCSHIFT_A), D_ALL);
23078c2ecf20Sopenharmony_ci
23088c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HTOTAL_B), D_ALL);
23098c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HBLANK_B), D_ALL);
23108c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_HSYNC_B), D_ALL);
23118c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VTOTAL_B), D_ALL);
23128c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VBLANK_B), D_ALL);
23138c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VSYNC_B), D_ALL);
23148c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANS_VSYNCSHIFT_B), D_ALL);
23158c2ecf20Sopenharmony_ci
23168c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_DATA_M1), D_ALL);
23178c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_DATA_N1), D_ALL);
23188c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_DATA_M2), D_ALL);
23198c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_DATA_N2), D_ALL);
23208c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_LINK_M1), D_ALL);
23218c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_LINK_N1), D_ALL);
23228c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_LINK_M2), D_ALL);
23238c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_TRANSA_LINK_N2), D_ALL);
23248c2ecf20Sopenharmony_ci
23258c2ecf20Sopenharmony_ci	MMIO_D(TRANS_DP_CTL(PIPE_A), D_ALL);
23268c2ecf20Sopenharmony_ci	MMIO_D(TRANS_DP_CTL(PIPE_B), D_ALL);
23278c2ecf20Sopenharmony_ci	MMIO_D(TRANS_DP_CTL(PIPE_C), D_ALL);
23288c2ecf20Sopenharmony_ci
23298c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_CTL(PIPE_A), D_ALL);
23308c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_DATA(PIPE_A), D_ALL);
23318c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_GCP(PIPE_A), D_ALL);
23328c2ecf20Sopenharmony_ci
23338c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_CTL(PIPE_B), D_ALL);
23348c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_DATA(PIPE_B), D_ALL);
23358c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_GCP(PIPE_B), D_ALL);
23368c2ecf20Sopenharmony_ci
23378c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_CTL(PIPE_C), D_ALL);
23388c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_DATA(PIPE_C), D_ALL);
23398c2ecf20Sopenharmony_ci	MMIO_D(TVIDEO_DIP_GCP(PIPE_C), D_ALL);
23408c2ecf20Sopenharmony_ci
23418c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXA_MISC), D_ALL);
23428c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXB_MISC), D_ALL);
23438c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXA_TUSIZE1), D_ALL);
23448c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXA_TUSIZE2), D_ALL);
23458c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXB_TUSIZE1), D_ALL);
23468c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_FDI_RXB_TUSIZE2), D_ALL);
23478c2ecf20Sopenharmony_ci
23488c2ecf20Sopenharmony_ci	MMIO_DH(PCH_PP_CONTROL, D_ALL, NULL, pch_pp_control_mmio_write);
23498c2ecf20Sopenharmony_ci	MMIO_D(PCH_PP_DIVISOR, D_ALL);
23508c2ecf20Sopenharmony_ci	MMIO_D(PCH_PP_STATUS,  D_ALL);
23518c2ecf20Sopenharmony_ci	MMIO_D(PCH_LVDS, D_ALL);
23528c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_DPLL_A), D_ALL);
23538c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_DPLL_B), D_ALL);
23548c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_FPA0), D_ALL);
23558c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_FPA1), D_ALL);
23568c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_FPB0), D_ALL);
23578c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PCH_FPB1), D_ALL);
23588c2ecf20Sopenharmony_ci	MMIO_D(PCH_DREF_CONTROL, D_ALL);
23598c2ecf20Sopenharmony_ci	MMIO_D(PCH_RAWCLK_FREQ, D_ALL);
23608c2ecf20Sopenharmony_ci	MMIO_D(PCH_DPLL_SEL, D_ALL);
23618c2ecf20Sopenharmony_ci
23628c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x61208), D_ALL);
23638c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6120c), D_ALL);
23648c2ecf20Sopenharmony_ci	MMIO_D(PCH_PP_ON_DELAYS, D_ALL);
23658c2ecf20Sopenharmony_ci	MMIO_D(PCH_PP_OFF_DELAYS, D_ALL);
23668c2ecf20Sopenharmony_ci
23678c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe651c), D_ALL, dpy_reg_mmio_read, NULL);
23688c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe661c), D_ALL, dpy_reg_mmio_read, NULL);
23698c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe671c), D_ALL, dpy_reg_mmio_read, NULL);
23708c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe681c), D_ALL, dpy_reg_mmio_read, NULL);
23718c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe6c04), D_ALL, dpy_reg_mmio_read, NULL);
23728c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0xe6e1c), D_ALL, dpy_reg_mmio_read, NULL);
23738c2ecf20Sopenharmony_ci
23748c2ecf20Sopenharmony_ci	MMIO_RO(PCH_PORT_HOTPLUG, D_ALL, 0,
23758c2ecf20Sopenharmony_ci		PORTA_HOTPLUG_STATUS_MASK
23768c2ecf20Sopenharmony_ci		| PORTB_HOTPLUG_STATUS_MASK
23778c2ecf20Sopenharmony_ci		| PORTC_HOTPLUG_STATUS_MASK
23788c2ecf20Sopenharmony_ci		| PORTD_HOTPLUG_STATUS_MASK,
23798c2ecf20Sopenharmony_ci		NULL, NULL);
23808c2ecf20Sopenharmony_ci
23818c2ecf20Sopenharmony_ci	MMIO_DH(LCPLL_CTL, D_ALL, NULL, lcpll_ctl_mmio_write);
23828c2ecf20Sopenharmony_ci	MMIO_D(FUSE_STRAP, D_ALL);
23838c2ecf20Sopenharmony_ci	MMIO_D(DIGITAL_PORT_HOTPLUG_CNTRL, D_ALL);
23848c2ecf20Sopenharmony_ci
23858c2ecf20Sopenharmony_ci	MMIO_D(DISP_ARB_CTL, D_ALL);
23868c2ecf20Sopenharmony_ci	MMIO_D(DISP_ARB_CTL2, D_ALL);
23878c2ecf20Sopenharmony_ci
23888c2ecf20Sopenharmony_ci	MMIO_D(ILK_DISPLAY_CHICKEN1, D_ALL);
23898c2ecf20Sopenharmony_ci	MMIO_D(ILK_DISPLAY_CHICKEN2, D_ALL);
23908c2ecf20Sopenharmony_ci	MMIO_D(ILK_DSPCLK_GATE_D, D_ALL);
23918c2ecf20Sopenharmony_ci
23928c2ecf20Sopenharmony_ci	MMIO_D(SOUTH_CHICKEN1, D_ALL);
23938c2ecf20Sopenharmony_ci	MMIO_DH(SOUTH_CHICKEN2, D_ALL, NULL, south_chicken2_mmio_write);
23948c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSA_CHICKEN1), D_ALL);
23958c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSB_CHICKEN1), D_ALL);
23968c2ecf20Sopenharmony_ci	MMIO_D(SOUTH_DSPCLK_GATE_D, D_ALL);
23978c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSA_CHICKEN2), D_ALL);
23988c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSB_CHICKEN2), D_ALL);
23998c2ecf20Sopenharmony_ci
24008c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_CB_BASE, D_ALL);
24018c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_CONTROL, D_ALL);
24028c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_RECOMP_CTL, D_ALL);
24038c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_STATUS, D_ALL);
24048c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_FENCE_YOFF, D_ALL);
24058c2ecf20Sopenharmony_ci	MMIO_D(ILK_DPFC_CHICKEN, D_ALL);
24068c2ecf20Sopenharmony_ci	MMIO_D(ILK_FBC_RT_BASE, D_ALL);
24078c2ecf20Sopenharmony_ci
24088c2ecf20Sopenharmony_ci	MMIO_D(IPS_CTL, D_ALL);
24098c2ecf20Sopenharmony_ci
24108c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RY_GY(PIPE_A), D_ALL);
24118c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BY(PIPE_A), D_ALL);
24128c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RU_GU(PIPE_A), D_ALL);
24138c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BU(PIPE_A), D_ALL);
24148c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RV_GV(PIPE_A), D_ALL);
24158c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BV(PIPE_A), D_ALL);
24168c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_MODE(PIPE_A), D_ALL);
24178c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_HI(PIPE_A), D_ALL);
24188c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_ME(PIPE_A), D_ALL);
24198c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_LO(PIPE_A), D_ALL);
24208c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_HI(PIPE_A), D_ALL);
24218c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_ME(PIPE_A), D_ALL);
24228c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_LO(PIPE_A), D_ALL);
24238c2ecf20Sopenharmony_ci
24248c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RY_GY(PIPE_B), D_ALL);
24258c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BY(PIPE_B), D_ALL);
24268c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RU_GU(PIPE_B), D_ALL);
24278c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BU(PIPE_B), D_ALL);
24288c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RV_GV(PIPE_B), D_ALL);
24298c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BV(PIPE_B), D_ALL);
24308c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_MODE(PIPE_B), D_ALL);
24318c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_HI(PIPE_B), D_ALL);
24328c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_ME(PIPE_B), D_ALL);
24338c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_LO(PIPE_B), D_ALL);
24348c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_HI(PIPE_B), D_ALL);
24358c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_ME(PIPE_B), D_ALL);
24368c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_LO(PIPE_B), D_ALL);
24378c2ecf20Sopenharmony_ci
24388c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RY_GY(PIPE_C), D_ALL);
24398c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BY(PIPE_C), D_ALL);
24408c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RU_GU(PIPE_C), D_ALL);
24418c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BU(PIPE_C), D_ALL);
24428c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_RV_GV(PIPE_C), D_ALL);
24438c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_COEFF_BV(PIPE_C), D_ALL);
24448c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_MODE(PIPE_C), D_ALL);
24458c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_HI(PIPE_C), D_ALL);
24468c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_ME(PIPE_C), D_ALL);
24478c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_PREOFF_LO(PIPE_C), D_ALL);
24488c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_HI(PIPE_C), D_ALL);
24498c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_ME(PIPE_C), D_ALL);
24508c2ecf20Sopenharmony_ci	MMIO_D(PIPE_CSC_POSTOFF_LO(PIPE_C), D_ALL);
24518c2ecf20Sopenharmony_ci
24528c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_INDEX(PIPE_A), D_ALL);
24538c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_DATA(PIPE_A), D_ALL);
24548c2ecf20Sopenharmony_ci	MMIO_F(PREC_PAL_GC_MAX(PIPE_A, 0), 4 * 3, 0, 0, 0, D_ALL, NULL, NULL);
24558c2ecf20Sopenharmony_ci
24568c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_INDEX(PIPE_B), D_ALL);
24578c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_DATA(PIPE_B), D_ALL);
24588c2ecf20Sopenharmony_ci	MMIO_F(PREC_PAL_GC_MAX(PIPE_B, 0), 4 * 3, 0, 0, 0, D_ALL, NULL, NULL);
24598c2ecf20Sopenharmony_ci
24608c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_INDEX(PIPE_C), D_ALL);
24618c2ecf20Sopenharmony_ci	MMIO_D(PREC_PAL_DATA(PIPE_C), D_ALL);
24628c2ecf20Sopenharmony_ci	MMIO_F(PREC_PAL_GC_MAX(PIPE_C, 0), 4 * 3, 0, 0, 0, D_ALL, NULL, NULL);
24638c2ecf20Sopenharmony_ci
24648c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x60110), D_ALL);
24658c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x61110), D_ALL);
24668c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x70400), 0x40, 0, 0, 0, D_ALL, NULL, NULL);
24678c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x71400), 0x40, 0, 0, 0, D_ALL, NULL, NULL);
24688c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x72400), 0x40, 0, 0, 0, D_ALL, NULL, NULL);
24698c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x70440), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24708c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x71440), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24718c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x72440), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24728c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x7044c), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24738c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x7144c), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24748c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x7244c), 0xc, 0, 0, 0, D_PRE_SKL, NULL, NULL);
24758c2ecf20Sopenharmony_ci
24768c2ecf20Sopenharmony_ci	MMIO_D(WM_LINETIME(PIPE_A), D_ALL);
24778c2ecf20Sopenharmony_ci	MMIO_D(WM_LINETIME(PIPE_B), D_ALL);
24788c2ecf20Sopenharmony_ci	MMIO_D(WM_LINETIME(PIPE_C), D_ALL);
24798c2ecf20Sopenharmony_ci	MMIO_D(SPLL_CTL, D_ALL);
24808c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_WRPLL_CTL1), D_ALL);
24818c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_WRPLL_CTL2), D_ALL);
24828c2ecf20Sopenharmony_ci	MMIO_D(PORT_CLK_SEL(PORT_A), D_ALL);
24838c2ecf20Sopenharmony_ci	MMIO_D(PORT_CLK_SEL(PORT_B), D_ALL);
24848c2ecf20Sopenharmony_ci	MMIO_D(PORT_CLK_SEL(PORT_C), D_ALL);
24858c2ecf20Sopenharmony_ci	MMIO_D(PORT_CLK_SEL(PORT_D), D_ALL);
24868c2ecf20Sopenharmony_ci	MMIO_D(PORT_CLK_SEL(PORT_E), D_ALL);
24878c2ecf20Sopenharmony_ci	MMIO_D(TRANS_CLK_SEL(TRANSCODER_A), D_ALL);
24888c2ecf20Sopenharmony_ci	MMIO_D(TRANS_CLK_SEL(TRANSCODER_B), D_ALL);
24898c2ecf20Sopenharmony_ci	MMIO_D(TRANS_CLK_SEL(TRANSCODER_C), D_ALL);
24908c2ecf20Sopenharmony_ci
24918c2ecf20Sopenharmony_ci	MMIO_D(HSW_NDE_RSTWRN_OPT, D_ALL);
24928c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x46508), D_ALL);
24938c2ecf20Sopenharmony_ci
24948c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x49080), D_ALL);
24958c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x49180), D_ALL);
24968c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x49280), D_ALL);
24978c2ecf20Sopenharmony_ci
24988c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x49090), 0x14, 0, 0, 0, D_ALL, NULL, NULL);
24998c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x49190), 0x14, 0, 0, 0, D_ALL, NULL, NULL);
25008c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x49290), 0x14, 0, 0, 0, D_ALL, NULL, NULL);
25018c2ecf20Sopenharmony_ci
25028c2ecf20Sopenharmony_ci	MMIO_D(GAMMA_MODE(PIPE_A), D_ALL);
25038c2ecf20Sopenharmony_ci	MMIO_D(GAMMA_MODE(PIPE_B), D_ALL);
25048c2ecf20Sopenharmony_ci	MMIO_D(GAMMA_MODE(PIPE_C), D_ALL);
25058c2ecf20Sopenharmony_ci
25068c2ecf20Sopenharmony_ci	MMIO_D(PIPE_MULT(PIPE_A), D_ALL);
25078c2ecf20Sopenharmony_ci	MMIO_D(PIPE_MULT(PIPE_B), D_ALL);
25088c2ecf20Sopenharmony_ci	MMIO_D(PIPE_MULT(PIPE_C), D_ALL);
25098c2ecf20Sopenharmony_ci
25108c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_CTL(TRANSCODER_A), D_ALL);
25118c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_CTL(TRANSCODER_B), D_ALL);
25128c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_CTL(TRANSCODER_C), D_ALL);
25138c2ecf20Sopenharmony_ci
25148c2ecf20Sopenharmony_ci	MMIO_DH(SFUSE_STRAP, D_ALL, NULL, NULL);
25158c2ecf20Sopenharmony_ci	MMIO_D(SBI_ADDR, D_ALL);
25168c2ecf20Sopenharmony_ci	MMIO_DH(SBI_DATA, D_ALL, sbi_data_mmio_read, NULL);
25178c2ecf20Sopenharmony_ci	MMIO_DH(SBI_CTL_STAT, D_ALL, NULL, sbi_ctl_mmio_write);
25188c2ecf20Sopenharmony_ci	MMIO_D(PIXCLK_GATE, D_ALL);
25198c2ecf20Sopenharmony_ci
25208c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(_DPA_AUX_CH_CTL), 6 * 4, 0, 0, 0, D_ALL, NULL,
25218c2ecf20Sopenharmony_ci		dp_aux_ch_ctl_mmio_write);
25228c2ecf20Sopenharmony_ci
25238c2ecf20Sopenharmony_ci	MMIO_DH(DDI_BUF_CTL(PORT_A), D_ALL, NULL, ddi_buf_ctl_mmio_write);
25248c2ecf20Sopenharmony_ci	MMIO_DH(DDI_BUF_CTL(PORT_B), D_ALL, NULL, ddi_buf_ctl_mmio_write);
25258c2ecf20Sopenharmony_ci	MMIO_DH(DDI_BUF_CTL(PORT_C), D_ALL, NULL, ddi_buf_ctl_mmio_write);
25268c2ecf20Sopenharmony_ci	MMIO_DH(DDI_BUF_CTL(PORT_D), D_ALL, NULL, ddi_buf_ctl_mmio_write);
25278c2ecf20Sopenharmony_ci	MMIO_DH(DDI_BUF_CTL(PORT_E), D_ALL, NULL, ddi_buf_ctl_mmio_write);
25288c2ecf20Sopenharmony_ci
25298c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_CTL(PORT_A), D_ALL, NULL, dp_tp_ctl_mmio_write);
25308c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_CTL(PORT_B), D_ALL, NULL, dp_tp_ctl_mmio_write);
25318c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_CTL(PORT_C), D_ALL, NULL, dp_tp_ctl_mmio_write);
25328c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_CTL(PORT_D), D_ALL, NULL, dp_tp_ctl_mmio_write);
25338c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_CTL(PORT_E), D_ALL, NULL, dp_tp_ctl_mmio_write);
25348c2ecf20Sopenharmony_ci
25358c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_STATUS(PORT_A), D_ALL, NULL, dp_tp_status_mmio_write);
25368c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_STATUS(PORT_B), D_ALL, NULL, dp_tp_status_mmio_write);
25378c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_STATUS(PORT_C), D_ALL, NULL, dp_tp_status_mmio_write);
25388c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_STATUS(PORT_D), D_ALL, NULL, dp_tp_status_mmio_write);
25398c2ecf20Sopenharmony_ci	MMIO_DH(DP_TP_STATUS(PORT_E), D_ALL, NULL, NULL);
25408c2ecf20Sopenharmony_ci
25418c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(_DDI_BUF_TRANS_A), 0x50, 0, 0, 0, D_ALL, NULL, NULL);
25428c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x64e60), 0x50, 0, 0, 0, D_ALL, NULL, NULL);
25438c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x64eC0), 0x50, 0, 0, 0, D_ALL, NULL, NULL);
25448c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x64f20), 0x50, 0, 0, 0, D_ALL, NULL, NULL);
25458c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x64f80), 0x50, 0, 0, 0, D_ALL, NULL, NULL);
25468c2ecf20Sopenharmony_ci
25478c2ecf20Sopenharmony_ci	MMIO_D(HSW_AUD_CFG(PIPE_A), D_ALL);
25488c2ecf20Sopenharmony_ci	MMIO_D(HSW_AUD_PIN_ELD_CP_VLD, D_ALL);
25498c2ecf20Sopenharmony_ci	MMIO_D(HSW_AUD_MISC_CTRL(PIPE_A), D_ALL);
25508c2ecf20Sopenharmony_ci
25518c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_TRANS_DDI_FUNC_CTL_A), D_ALL, NULL, NULL);
25528c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_TRANS_DDI_FUNC_CTL_B), D_ALL, NULL, NULL);
25538c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_TRANS_DDI_FUNC_CTL_C), D_ALL, NULL, NULL);
25548c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_TRANS_DDI_FUNC_CTL_EDP), D_ALL, NULL, NULL);
25558c2ecf20Sopenharmony_ci
25568c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSA_MSA_MISC), D_ALL);
25578c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSB_MSA_MISC), D_ALL);
25588c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANSC_MSA_MISC), D_ALL);
25598c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_TRANS_EDP_MSA_MISC), D_ALL);
25608c2ecf20Sopenharmony_ci
25618c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE, D_ALL, NULL, NULL);
25628c2ecf20Sopenharmony_ci	MMIO_D(FORCEWAKE_ACK, D_ALL);
25638c2ecf20Sopenharmony_ci	MMIO_D(GEN6_GT_CORE_STATUS, D_ALL);
25648c2ecf20Sopenharmony_ci	MMIO_D(GEN6_GT_THREAD_STATUS_REG, D_ALL);
25658c2ecf20Sopenharmony_ci	MMIO_DFH(GTFIFODBG, D_ALL, F_CMD_ACCESS, NULL, NULL);
25668c2ecf20Sopenharmony_ci	MMIO_DFH(GTFIFOCTL, D_ALL, F_CMD_ACCESS, NULL, NULL);
25678c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_MT, D_PRE_SKL, NULL, mul_force_wake_write);
25688c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_ACK_HSW, D_BDW, NULL, NULL);
25698c2ecf20Sopenharmony_ci	MMIO_D(ECOBUS, D_ALL);
25708c2ecf20Sopenharmony_ci	MMIO_DH(GEN6_RC_CONTROL, D_ALL, NULL, NULL);
25718c2ecf20Sopenharmony_ci	MMIO_DH(GEN6_RC_STATE, D_ALL, NULL, NULL);
25728c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RPNSWREQ, D_ALL);
25738c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC_VIDEO_FREQ, D_ALL);
25748c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_DOWN_TIMEOUT, D_ALL);
25758c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_INTERRUPT_LIMITS, D_ALL);
25768c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RPSTAT1, D_ALL);
25778c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_CONTROL, D_ALL);
25788c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_UP_THRESHOLD, D_ALL);
25798c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_DOWN_THRESHOLD, D_ALL);
25808c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_CUR_UP_EI, D_ALL);
25818c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_CUR_UP, D_ALL);
25828c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_PREV_UP, D_ALL);
25838c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_CUR_DOWN_EI, D_ALL);
25848c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_CUR_DOWN, D_ALL);
25858c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_PREV_DOWN, D_ALL);
25868c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_UP_EI, D_ALL);
25878c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_DOWN_EI, D_ALL);
25888c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RP_IDLE_HYSTERSIS, D_ALL);
25898c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC1_WAKE_RATE_LIMIT, D_ALL);
25908c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC6_WAKE_RATE_LIMIT, D_ALL);
25918c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC6pp_WAKE_RATE_LIMIT, D_ALL);
25928c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC_EVALUATION_INTERVAL, D_ALL);
25938c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC_IDLE_HYSTERSIS, D_ALL);
25948c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC_SLEEP, D_ALL);
25958c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC1e_THRESHOLD, D_ALL);
25968c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC6_THRESHOLD, D_ALL);
25978c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC6p_THRESHOLD, D_ALL);
25988c2ecf20Sopenharmony_ci	MMIO_D(GEN6_RC6pp_THRESHOLD, D_ALL);
25998c2ecf20Sopenharmony_ci	MMIO_D(GEN6_PMINTRMSK, D_ALL);
26008c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL1, D_BDW, NULL, power_well_ctl_mmio_write);
26018c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL2, D_BDW, NULL, power_well_ctl_mmio_write);
26028c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL3, D_BDW, NULL, power_well_ctl_mmio_write);
26038c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL4, D_BDW, NULL, power_well_ctl_mmio_write);
26048c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL5, D_BDW, NULL, power_well_ctl_mmio_write);
26058c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL6, D_BDW, NULL, power_well_ctl_mmio_write);
26068c2ecf20Sopenharmony_ci
26078c2ecf20Sopenharmony_ci	MMIO_D(RSTDBYCTL, D_ALL);
26088c2ecf20Sopenharmony_ci
26098c2ecf20Sopenharmony_ci	MMIO_DH(GEN6_GDRST, D_ALL, NULL, gdrst_mmio_write);
26108c2ecf20Sopenharmony_ci	MMIO_F(FENCE_REG_GEN6_LO(0), 0x80, 0, 0, 0, D_ALL, fence_mmio_read, fence_mmio_write);
26118c2ecf20Sopenharmony_ci	MMIO_DH(CPU_VGACNTRL, D_ALL, NULL, vga_control_mmio_write);
26128c2ecf20Sopenharmony_ci
26138c2ecf20Sopenharmony_ci	MMIO_D(TILECTL, D_ALL);
26148c2ecf20Sopenharmony_ci
26158c2ecf20Sopenharmony_ci	MMIO_D(GEN6_UCGCTL1, D_ALL);
26168c2ecf20Sopenharmony_ci	MMIO_D(GEN6_UCGCTL2, D_ALL);
26178c2ecf20Sopenharmony_ci
26188c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x4f000), 0x90, 0, 0, 0, D_ALL, NULL, NULL);
26198c2ecf20Sopenharmony_ci
26208c2ecf20Sopenharmony_ci	MMIO_D(GEN6_PCODE_DATA, D_ALL);
26218c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x13812c), D_ALL);
26228c2ecf20Sopenharmony_ci	MMIO_DH(GEN7_ERR_INT, D_ALL, NULL, NULL);
26238c2ecf20Sopenharmony_ci	MMIO_D(HSW_EDRAM_CAP, D_ALL);
26248c2ecf20Sopenharmony_ci	MMIO_D(HSW_IDICR, D_ALL);
26258c2ecf20Sopenharmony_ci	MMIO_DH(GFX_FLSH_CNTL_GEN6, D_ALL, NULL, NULL);
26268c2ecf20Sopenharmony_ci
26278c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x3c), D_ALL);
26288c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x860), D_ALL);
26298c2ecf20Sopenharmony_ci	MMIO_D(ECOSKPD, D_ALL);
26308c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x121d0), D_ALL);
26318c2ecf20Sopenharmony_ci	MMIO_D(GEN6_BLITTER_ECOSKPD, D_ALL);
26328c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x41d0), D_ALL);
26338c2ecf20Sopenharmony_ci	MMIO_D(GAC_ECO_BITS, D_ALL);
26348c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6200), D_ALL);
26358c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6204), D_ALL);
26368c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6208), D_ALL);
26378c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7118), D_ALL);
26388c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7180), D_ALL);
26398c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7408), D_ALL);
26408c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7c00), D_ALL);
26418c2ecf20Sopenharmony_ci	MMIO_DH(GEN6_MBCTL, D_ALL, NULL, mbctl_write);
26428c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x911c), D_ALL);
26438c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x9120), D_ALL);
26448c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_UCGCTL4, D_ALL, F_CMD_ACCESS, NULL, NULL);
26458c2ecf20Sopenharmony_ci
26468c2ecf20Sopenharmony_ci	MMIO_D(GAB_CTL, D_ALL);
26478c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x48800), D_ALL);
26488c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xce044), D_ALL);
26498c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6500), D_ALL);
26508c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6504), D_ALL);
26518c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6600), D_ALL);
26528c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6604), D_ALL);
26538c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6700), D_ALL);
26548c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6704), D_ALL);
26558c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6800), D_ALL);
26568c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xe6804), D_ALL);
26578c2ecf20Sopenharmony_ci	MMIO_D(PCH_GMBUS4, D_ALL);
26588c2ecf20Sopenharmony_ci	MMIO_D(PCH_GMBUS5, D_ALL);
26598c2ecf20Sopenharmony_ci
26608c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x902c), D_ALL);
26618c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec008), D_ALL);
26628c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec00c), D_ALL);
26638c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec008 + 0x18), D_ALL);
26648c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec00c + 0x18), D_ALL);
26658c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec008 + 0x18 * 2), D_ALL);
26668c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec00c + 0x18 * 2), D_ALL);
26678c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec008 + 0x18 * 3), D_ALL);
26688c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec00c + 0x18 * 3), D_ALL);
26698c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec408), D_ALL);
26708c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec40c), D_ALL);
26718c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec408 + 0x18), D_ALL);
26728c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec40c + 0x18), D_ALL);
26738c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec408 + 0x18 * 2), D_ALL);
26748c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec40c + 0x18 * 2), D_ALL);
26758c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec408 + 0x18 * 3), D_ALL);
26768c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xec40c + 0x18 * 3), D_ALL);
26778c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfc810), D_ALL);
26788c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfc81c), D_ALL);
26798c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfc828), D_ALL);
26808c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfc834), D_ALL);
26818c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfcc00), D_ALL);
26828c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfcc0c), D_ALL);
26838c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfcc18), D_ALL);
26848c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfcc24), D_ALL);
26858c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfd000), D_ALL);
26868c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfd00c), D_ALL);
26878c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfd018), D_ALL);
26888c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfd024), D_ALL);
26898c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfd034), D_ALL);
26908c2ecf20Sopenharmony_ci
26918c2ecf20Sopenharmony_ci	MMIO_DH(FPGA_DBG, D_ALL, NULL, fpga_dbg_mmio_write);
26928c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x2054), D_ALL);
26938c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x12054), D_ALL);
26948c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x22054), D_ALL);
26958c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x1a054), D_ALL);
26968c2ecf20Sopenharmony_ci
26978c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x44070), D_ALL);
26988c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x215c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
26998c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2178), D_ALL, F_CMD_ACCESS, NULL, NULL);
27008c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x217c), D_ALL, F_CMD_ACCESS, NULL, NULL);
27018c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x12178), D_ALL, F_CMD_ACCESS, NULL, NULL);
27028c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x1217c), D_ALL, F_CMD_ACCESS, NULL, NULL);
27038c2ecf20Sopenharmony_ci
27048c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x2290), 8, F_CMD_ACCESS, 0, 0, D_BDW_PLUS, NULL, NULL);
27058c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x2b00), D_BDW_PLUS);
27068c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x2360), D_BDW_PLUS);
27078c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x5200), 32, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27088c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x5240), 32, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27098c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x5280), 16, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27108c2ecf20Sopenharmony_ci
27118c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x1c17c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27128c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x1c178), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27138c2ecf20Sopenharmony_ci	MMIO_DFH(BCS_SWCTRL, D_ALL, F_CMD_ACCESS, NULL, NULL);
27148c2ecf20Sopenharmony_ci
27158c2ecf20Sopenharmony_ci	MMIO_F(HS_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27168c2ecf20Sopenharmony_ci	MMIO_F(DS_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27178c2ecf20Sopenharmony_ci	MMIO_F(IA_VERTICES_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27188c2ecf20Sopenharmony_ci	MMIO_F(IA_PRIMITIVES_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27198c2ecf20Sopenharmony_ci	MMIO_F(VS_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27208c2ecf20Sopenharmony_ci	MMIO_F(GS_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27218c2ecf20Sopenharmony_ci	MMIO_F(GS_PRIMITIVES_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27228c2ecf20Sopenharmony_ci	MMIO_F(CL_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27238c2ecf20Sopenharmony_ci	MMIO_F(CL_PRIMITIVES_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27248c2ecf20Sopenharmony_ci	MMIO_F(PS_INVOCATION_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27258c2ecf20Sopenharmony_ci	MMIO_F(PS_DEPTH_COUNT, 8, F_CMD_ACCESS, 0, 0, D_ALL, NULL, NULL);
27268c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0x4260), D_BDW_PLUS, NULL, gvt_reg_tlb_control_handler);
27278c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0x4264), D_BDW_PLUS, NULL, gvt_reg_tlb_control_handler);
27288c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0x4268), D_BDW_PLUS, NULL, gvt_reg_tlb_control_handler);
27298c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0x426c), D_BDW_PLUS, NULL, gvt_reg_tlb_control_handler);
27308c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(0x4270), D_BDW_PLUS, NULL, gvt_reg_tlb_control_handler);
27318c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x4094), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27328c2ecf20Sopenharmony_ci
27338c2ecf20Sopenharmony_ci	MMIO_DFH(ARB_MODE, D_ALL, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
27348c2ecf20Sopenharmony_ci	MMIO_RING_GM(RING_BBADDR, D_ALL, NULL, NULL);
27358c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2220), D_ALL, F_CMD_ACCESS, NULL, NULL);
27368c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x12220), D_ALL, F_CMD_ACCESS, NULL, NULL);
27378c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x22220), D_ALL, F_CMD_ACCESS, NULL, NULL);
27388c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_SYNC_1, D_ALL, F_CMD_ACCESS, NULL, NULL);
27398c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_SYNC_0, D_ALL, F_CMD_ACCESS, NULL, NULL);
27408c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x22178), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27418c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x1a178), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27428c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x1a17c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27438c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2217c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
27448c2ecf20Sopenharmony_ci
27458c2ecf20Sopenharmony_ci	MMIO_DH(EDP_PSR_IMR, D_BDW_PLUS, NULL, edp_psr_imr_iir_write);
27468c2ecf20Sopenharmony_ci	MMIO_DH(EDP_PSR_IIR, D_BDW_PLUS, NULL, edp_psr_imr_iir_write);
27478c2ecf20Sopenharmony_ci	MMIO_DH(GUC_STATUS, D_ALL, guc_status_read, NULL);
27488c2ecf20Sopenharmony_ci
27498c2ecf20Sopenharmony_ci	return 0;
27508c2ecf20Sopenharmony_ci}
27518c2ecf20Sopenharmony_ci
27528c2ecf20Sopenharmony_cistatic int init_bdw_mmio_info(struct intel_gvt *gvt)
27538c2ecf20Sopenharmony_ci{
27548c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = gvt->gt->i915;
27558c2ecf20Sopenharmony_ci	int ret;
27568c2ecf20Sopenharmony_ci
27578c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IMR(0), D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
27588c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IER(0), D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
27598c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IIR(0), D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
27608c2ecf20Sopenharmony_ci	MMIO_D(GEN8_GT_ISR(0), D_BDW_PLUS);
27618c2ecf20Sopenharmony_ci
27628c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IMR(1), D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
27638c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IER(1), D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
27648c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IIR(1), D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
27658c2ecf20Sopenharmony_ci	MMIO_D(GEN8_GT_ISR(1), D_BDW_PLUS);
27668c2ecf20Sopenharmony_ci
27678c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IMR(2), D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
27688c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IER(2), D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
27698c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IIR(2), D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
27708c2ecf20Sopenharmony_ci	MMIO_D(GEN8_GT_ISR(2), D_BDW_PLUS);
27718c2ecf20Sopenharmony_ci
27728c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IMR(3), D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
27738c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IER(3), D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
27748c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_GT_IIR(3), D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
27758c2ecf20Sopenharmony_ci	MMIO_D(GEN8_GT_ISR(3), D_BDW_PLUS);
27768c2ecf20Sopenharmony_ci
27778c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IMR(PIPE_A), D_BDW_PLUS, NULL,
27788c2ecf20Sopenharmony_ci		intel_vgpu_reg_imr_handler);
27798c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IER(PIPE_A), D_BDW_PLUS, NULL,
27808c2ecf20Sopenharmony_ci		intel_vgpu_reg_ier_handler);
27818c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IIR(PIPE_A), D_BDW_PLUS, NULL,
27828c2ecf20Sopenharmony_ci		intel_vgpu_reg_iir_handler);
27838c2ecf20Sopenharmony_ci	MMIO_D(GEN8_DE_PIPE_ISR(PIPE_A), D_BDW_PLUS);
27848c2ecf20Sopenharmony_ci
27858c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IMR(PIPE_B), D_BDW_PLUS, NULL,
27868c2ecf20Sopenharmony_ci		intel_vgpu_reg_imr_handler);
27878c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IER(PIPE_B), D_BDW_PLUS, NULL,
27888c2ecf20Sopenharmony_ci		intel_vgpu_reg_ier_handler);
27898c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IIR(PIPE_B), D_BDW_PLUS, NULL,
27908c2ecf20Sopenharmony_ci		intel_vgpu_reg_iir_handler);
27918c2ecf20Sopenharmony_ci	MMIO_D(GEN8_DE_PIPE_ISR(PIPE_B), D_BDW_PLUS);
27928c2ecf20Sopenharmony_ci
27938c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IMR(PIPE_C), D_BDW_PLUS, NULL,
27948c2ecf20Sopenharmony_ci		intel_vgpu_reg_imr_handler);
27958c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IER(PIPE_C), D_BDW_PLUS, NULL,
27968c2ecf20Sopenharmony_ci		intel_vgpu_reg_ier_handler);
27978c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PIPE_IIR(PIPE_C), D_BDW_PLUS, NULL,
27988c2ecf20Sopenharmony_ci		intel_vgpu_reg_iir_handler);
27998c2ecf20Sopenharmony_ci	MMIO_D(GEN8_DE_PIPE_ISR(PIPE_C), D_BDW_PLUS);
28008c2ecf20Sopenharmony_ci
28018c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PORT_IMR, D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
28028c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PORT_IER, D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
28038c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_PORT_IIR, D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
28048c2ecf20Sopenharmony_ci	MMIO_D(GEN8_DE_PORT_ISR, D_BDW_PLUS);
28058c2ecf20Sopenharmony_ci
28068c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_MISC_IMR, D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
28078c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_MISC_IER, D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
28088c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_DE_MISC_IIR, D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
28098c2ecf20Sopenharmony_ci	MMIO_D(GEN8_DE_MISC_ISR, D_BDW_PLUS);
28108c2ecf20Sopenharmony_ci
28118c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_PCU_IMR, D_BDW_PLUS, NULL, intel_vgpu_reg_imr_handler);
28128c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_PCU_IER, D_BDW_PLUS, NULL, intel_vgpu_reg_ier_handler);
28138c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_PCU_IIR, D_BDW_PLUS, NULL, intel_vgpu_reg_iir_handler);
28148c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PCU_ISR, D_BDW_PLUS);
28158c2ecf20Sopenharmony_ci
28168c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_MASTER_IRQ, D_BDW_PLUS, NULL,
28178c2ecf20Sopenharmony_ci		intel_vgpu_reg_master_irq_handler);
28188c2ecf20Sopenharmony_ci
28198c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_ACTHD_UDW, D_BDW_PLUS, 0,
28208c2ecf20Sopenharmony_ci		mmio_read_from_hw, NULL);
28218c2ecf20Sopenharmony_ci
28228c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0xd0)
28238c2ecf20Sopenharmony_ci	MMIO_RING_F(RING_REG, 4, F_RO, 0,
28248c2ecf20Sopenharmony_ci		~_MASKED_BIT_ENABLE(RESET_CTL_REQUEST_RESET), D_BDW_PLUS, NULL,
28258c2ecf20Sopenharmony_ci		ring_reset_ctl_write);
28268c2ecf20Sopenharmony_ci#undef RING_REG
28278c2ecf20Sopenharmony_ci
28288c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x230)
28298c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_BDW_PLUS, 0, NULL, elsp_mmio_write);
28308c2ecf20Sopenharmony_ci#undef RING_REG
28318c2ecf20Sopenharmony_ci
28328c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x234)
28338c2ecf20Sopenharmony_ci	MMIO_RING_F(RING_REG, 8, F_RO, 0, ~0, D_BDW_PLUS,
28348c2ecf20Sopenharmony_ci		NULL, NULL);
28358c2ecf20Sopenharmony_ci#undef RING_REG
28368c2ecf20Sopenharmony_ci
28378c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x244)
28388c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
28398c2ecf20Sopenharmony_ci#undef RING_REG
28408c2ecf20Sopenharmony_ci
28418c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x370)
28428c2ecf20Sopenharmony_ci	MMIO_RING_F(RING_REG, 48, F_RO, 0, ~0, D_BDW_PLUS, NULL, NULL);
28438c2ecf20Sopenharmony_ci#undef RING_REG
28448c2ecf20Sopenharmony_ci
28458c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x3a0)
28468c2ecf20Sopenharmony_ci	MMIO_RING_DFH(RING_REG, D_BDW_PLUS, F_MODE_MASK, NULL, NULL);
28478c2ecf20Sopenharmony_ci#undef RING_REG
28488c2ecf20Sopenharmony_ci
28498c2ecf20Sopenharmony_ci	MMIO_D(PIPEMISC(PIPE_A), D_BDW_PLUS);
28508c2ecf20Sopenharmony_ci	MMIO_D(PIPEMISC(PIPE_B), D_BDW_PLUS);
28518c2ecf20Sopenharmony_ci	MMIO_D(PIPEMISC(PIPE_C), D_BDW_PLUS);
28528c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x1c1d0), D_BDW_PLUS);
28538c2ecf20Sopenharmony_ci	MMIO_D(GEN6_MBCUNIT_SNPCR, D_BDW_PLUS);
28548c2ecf20Sopenharmony_ci	MMIO_D(GEN7_MISCCPCTL, D_BDW_PLUS);
28558c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x1c054), D_BDW_PLUS);
28568c2ecf20Sopenharmony_ci
28578c2ecf20Sopenharmony_ci	MMIO_DH(GEN6_PCODE_MAILBOX, D_BDW_PLUS, NULL, mailbox_write);
28588c2ecf20Sopenharmony_ci
28598c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PRIVATE_PAT_LO, D_BDW_PLUS & ~D_BXT);
28608c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PRIVATE_PAT_HI, D_BDW_PLUS);
28618c2ecf20Sopenharmony_ci
28628c2ecf20Sopenharmony_ci	MMIO_D(GAMTARBMODE, D_BDW_PLUS);
28638c2ecf20Sopenharmony_ci
28648c2ecf20Sopenharmony_ci#define RING_REG(base) _MMIO((base) + 0x270)
28658c2ecf20Sopenharmony_ci	MMIO_RING_F(RING_REG, 32, F_CMD_ACCESS, 0, 0, D_BDW_PLUS, NULL, NULL);
28668c2ecf20Sopenharmony_ci#undef RING_REG
28678c2ecf20Sopenharmony_ci
28688c2ecf20Sopenharmony_ci	MMIO_RING_GM(RING_HWS_PGA, D_BDW_PLUS, NULL, hws_pga_write);
28698c2ecf20Sopenharmony_ci
28708c2ecf20Sopenharmony_ci	MMIO_DFH(HDC_CHICKEN0, D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
28718c2ecf20Sopenharmony_ci
28728c2ecf20Sopenharmony_ci	MMIO_D(CHICKEN_PIPESL_1(PIPE_A), D_BDW_PLUS);
28738c2ecf20Sopenharmony_ci	MMIO_D(CHICKEN_PIPESL_1(PIPE_B), D_BDW_PLUS);
28748c2ecf20Sopenharmony_ci	MMIO_D(CHICKEN_PIPESL_1(PIPE_C), D_BDW_PLUS);
28758c2ecf20Sopenharmony_ci
28768c2ecf20Sopenharmony_ci	MMIO_D(WM_MISC, D_BDW);
28778c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_SRD_CTL_EDP), D_BDW);
28788c2ecf20Sopenharmony_ci
28798c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6671c), D_BDW_PLUS);
28808c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x66c00), D_BDW_PLUS);
28818c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x66c04), D_BDW_PLUS);
28828c2ecf20Sopenharmony_ci
28838c2ecf20Sopenharmony_ci	MMIO_D(HSW_GTT_CACHE_EN, D_BDW_PLUS);
28848c2ecf20Sopenharmony_ci
28858c2ecf20Sopenharmony_ci	MMIO_D(GEN8_EU_DISABLE0, D_BDW_PLUS);
28868c2ecf20Sopenharmony_ci	MMIO_D(GEN8_EU_DISABLE1, D_BDW_PLUS);
28878c2ecf20Sopenharmony_ci	MMIO_D(GEN8_EU_DISABLE2, D_BDW_PLUS);
28888c2ecf20Sopenharmony_ci
28898c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xfdc), D_BDW_PLUS);
28908c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_ROW_CHICKEN, D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS,
28918c2ecf20Sopenharmony_ci		NULL, NULL);
28928c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_ROW_CHICKEN2, D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS,
28938c2ecf20Sopenharmony_ci		NULL, NULL);
28948c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_UCGCTL6, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
28958c2ecf20Sopenharmony_ci
28968c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xb1f0), D_BDW, F_CMD_ACCESS, NULL, NULL);
28978c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xb1c0), D_BDW, F_CMD_ACCESS, NULL, NULL);
28988c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_L3SQCREG4, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
28998c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xb100), D_BDW, F_CMD_ACCESS, NULL, NULL);
29008c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xb10c), D_BDW, F_CMD_ACCESS, NULL, NULL);
29018c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xb110), D_BDW);
29028c2ecf20Sopenharmony_ci
29038c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x24d0), 48, F_CMD_ACCESS, 0, 0, D_BDW_PLUS,
29048c2ecf20Sopenharmony_ci		NULL, force_nonpriv_write);
29058c2ecf20Sopenharmony_ci
29068c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x44484), D_BDW_PLUS);
29078c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x4448c), D_BDW_PLUS);
29088c2ecf20Sopenharmony_ci
29098c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x83a4), D_BDW, F_CMD_ACCESS, NULL, NULL);
29108c2ecf20Sopenharmony_ci	MMIO_D(GEN8_L3_LRA_1_GPGPU, D_BDW_PLUS);
29118c2ecf20Sopenharmony_ci
29128c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x8430), D_BDW, F_CMD_ACCESS, NULL, NULL);
29138c2ecf20Sopenharmony_ci
29148c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x110000), D_BDW_PLUS);
29158c2ecf20Sopenharmony_ci
29168c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x48400), D_BDW_PLUS);
29178c2ecf20Sopenharmony_ci
29188c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6e570), D_BDW_PLUS);
29198c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x65f10), D_BDW_PLUS);
29208c2ecf20Sopenharmony_ci
29218c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe194), D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
29228c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe188), D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
29238c2ecf20Sopenharmony_ci	MMIO_DFH(HALF_SLICE_CHICKEN2, D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
29248c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2580), D_BDW_PLUS, F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
29258c2ecf20Sopenharmony_ci
29268c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x2248), D_BDW, F_CMD_ACCESS, NULL, NULL);
29278c2ecf20Sopenharmony_ci
29288c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe220), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29298c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe230), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29308c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe240), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29318c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe260), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29328c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe270), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29338c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe280), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29348c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe2a0), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29358c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe2b0), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29368c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0xe2c0), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29378c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x21f0), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
29388c2ecf20Sopenharmony_ci	return 0;
29398c2ecf20Sopenharmony_ci}
29408c2ecf20Sopenharmony_ci
29418c2ecf20Sopenharmony_cistatic int init_skl_mmio_info(struct intel_gvt *gvt)
29428c2ecf20Sopenharmony_ci{
29438c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = gvt->gt->i915;
29448c2ecf20Sopenharmony_ci	int ret;
29458c2ecf20Sopenharmony_ci
29468c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_RENDER_GEN9, D_SKL_PLUS, NULL, mul_force_wake_write);
29478c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_ACK_RENDER_GEN9, D_SKL_PLUS, NULL, NULL);
29488c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_BLITTER_GEN9, D_SKL_PLUS, NULL, mul_force_wake_write);
29498c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_ACK_BLITTER_GEN9, D_SKL_PLUS, NULL, NULL);
29508c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_MEDIA_GEN9, D_SKL_PLUS, NULL, mul_force_wake_write);
29518c2ecf20Sopenharmony_ci	MMIO_DH(FORCEWAKE_ACK_MEDIA_GEN9, D_SKL_PLUS, NULL, NULL);
29528c2ecf20Sopenharmony_ci
29538c2ecf20Sopenharmony_ci	MMIO_F(DP_AUX_CH_CTL(AUX_CH_B), 6 * 4, 0, 0, 0, D_SKL_PLUS, NULL,
29548c2ecf20Sopenharmony_ci						dp_aux_ch_ctl_mmio_write);
29558c2ecf20Sopenharmony_ci	MMIO_F(DP_AUX_CH_CTL(AUX_CH_C), 6 * 4, 0, 0, 0, D_SKL_PLUS, NULL,
29568c2ecf20Sopenharmony_ci						dp_aux_ch_ctl_mmio_write);
29578c2ecf20Sopenharmony_ci	MMIO_F(DP_AUX_CH_CTL(AUX_CH_D), 6 * 4, 0, 0, 0, D_SKL_PLUS, NULL,
29588c2ecf20Sopenharmony_ci						dp_aux_ch_ctl_mmio_write);
29598c2ecf20Sopenharmony_ci
29608c2ecf20Sopenharmony_ci	MMIO_D(HSW_PWR_WELL_CTL1, D_SKL_PLUS);
29618c2ecf20Sopenharmony_ci	MMIO_DH(HSW_PWR_WELL_CTL2, D_SKL_PLUS, NULL, skl_power_well_ctl_write);
29628c2ecf20Sopenharmony_ci
29638c2ecf20Sopenharmony_ci	MMIO_DH(DBUF_CTL_S(0), D_SKL_PLUS, NULL, gen9_dbuf_ctl_mmio_write);
29648c2ecf20Sopenharmony_ci
29658c2ecf20Sopenharmony_ci	MMIO_D(GEN9_PG_ENABLE, D_SKL_PLUS);
29668c2ecf20Sopenharmony_ci	MMIO_D(GEN9_MEDIA_PG_IDLE_HYSTERESIS, D_SKL_PLUS);
29678c2ecf20Sopenharmony_ci	MMIO_D(GEN9_RENDER_PG_IDLE_HYSTERESIS, D_SKL_PLUS);
29688c2ecf20Sopenharmony_ci	MMIO_DFH(GEN9_GAMT_ECO_REG_RW_IA, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
29698c2ecf20Sopenharmony_ci	MMIO_DFH(MMCD_MISC_CTRL, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
29708c2ecf20Sopenharmony_ci	MMIO_DH(CHICKEN_PAR1_1, D_SKL_PLUS, NULL, NULL);
29718c2ecf20Sopenharmony_ci	MMIO_D(DC_STATE_EN, D_SKL_PLUS);
29728c2ecf20Sopenharmony_ci	MMIO_D(DC_STATE_DEBUG, D_SKL_PLUS);
29738c2ecf20Sopenharmony_ci	MMIO_D(CDCLK_CTL, D_SKL_PLUS);
29748c2ecf20Sopenharmony_ci	MMIO_DH(LCPLL1_CTL, D_SKL_PLUS, NULL, skl_lcpll_write);
29758c2ecf20Sopenharmony_ci	MMIO_DH(LCPLL2_CTL, D_SKL_PLUS, NULL, skl_lcpll_write);
29768c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL1_CFGCR1), D_SKL_PLUS);
29778c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL2_CFGCR1), D_SKL_PLUS);
29788c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL3_CFGCR1), D_SKL_PLUS);
29798c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL1_CFGCR2), D_SKL_PLUS);
29808c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL2_CFGCR2), D_SKL_PLUS);
29818c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_DPLL3_CFGCR2), D_SKL_PLUS);
29828c2ecf20Sopenharmony_ci	MMIO_D(DPLL_CTRL1, D_SKL_PLUS);
29838c2ecf20Sopenharmony_ci	MMIO_D(DPLL_CTRL2, D_SKL_PLUS);
29848c2ecf20Sopenharmony_ci	MMIO_DH(DPLL_STATUS, D_SKL_PLUS, dpll_status_read, NULL);
29858c2ecf20Sopenharmony_ci
29868c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_A, 0), D_SKL_PLUS, NULL, pf_write);
29878c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_A, 1), D_SKL_PLUS, NULL, pf_write);
29888c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_B, 0), D_SKL_PLUS, NULL, pf_write);
29898c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_B, 1), D_SKL_PLUS, NULL, pf_write);
29908c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_C, 0), D_SKL_PLUS, NULL, pf_write);
29918c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_POS(PIPE_C, 1), D_SKL_PLUS, NULL, pf_write);
29928c2ecf20Sopenharmony_ci
29938c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_A, 0), D_SKL_PLUS, NULL, pf_write);
29948c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_A, 1), D_SKL_PLUS, NULL, pf_write);
29958c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_B, 0), D_SKL_PLUS, NULL, pf_write);
29968c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_B, 1), D_SKL_PLUS, NULL, pf_write);
29978c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_C, 0), D_SKL_PLUS, NULL, pf_write);
29988c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_WIN_SZ(PIPE_C, 1), D_SKL_PLUS, NULL, pf_write);
29998c2ecf20Sopenharmony_ci
30008c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_A, 0), D_SKL_PLUS, NULL, pf_write);
30018c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_A, 1), D_SKL_PLUS, NULL, pf_write);
30028c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_B, 0), D_SKL_PLUS, NULL, pf_write);
30038c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_B, 1), D_SKL_PLUS, NULL, pf_write);
30048c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_C, 0), D_SKL_PLUS, NULL, pf_write);
30058c2ecf20Sopenharmony_ci	MMIO_DH(SKL_PS_CTRL(PIPE_C, 1), D_SKL_PLUS, NULL, pf_write);
30068c2ecf20Sopenharmony_ci
30078c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_A, 0), D_SKL_PLUS, NULL, NULL);
30088c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_A, 1), D_SKL_PLUS, NULL, NULL);
30098c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_A, 2), D_SKL_PLUS, NULL, NULL);
30108c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_A, 3), D_SKL_PLUS, NULL, NULL);
30118c2ecf20Sopenharmony_ci
30128c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_B, 0), D_SKL_PLUS, NULL, NULL);
30138c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_B, 1), D_SKL_PLUS, NULL, NULL);
30148c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_B, 2), D_SKL_PLUS, NULL, NULL);
30158c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_B, 3), D_SKL_PLUS, NULL, NULL);
30168c2ecf20Sopenharmony_ci
30178c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_C, 0), D_SKL_PLUS, NULL, NULL);
30188c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_C, 1), D_SKL_PLUS, NULL, NULL);
30198c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_C, 2), D_SKL_PLUS, NULL, NULL);
30208c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_BUF_CFG(PIPE_C, 3), D_SKL_PLUS, NULL, NULL);
30218c2ecf20Sopenharmony_ci
30228c2ecf20Sopenharmony_ci	MMIO_DH(CUR_BUF_CFG(PIPE_A), D_SKL_PLUS, NULL, NULL);
30238c2ecf20Sopenharmony_ci	MMIO_DH(CUR_BUF_CFG(PIPE_B), D_SKL_PLUS, NULL, NULL);
30248c2ecf20Sopenharmony_ci	MMIO_DH(CUR_BUF_CFG(PIPE_C), D_SKL_PLUS, NULL, NULL);
30258c2ecf20Sopenharmony_ci
30268c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_A, 0, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30278c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_A, 1, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30288c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_A, 2, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30298c2ecf20Sopenharmony_ci
30308c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_B, 0, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30318c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_B, 1, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30328c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_B, 2, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30338c2ecf20Sopenharmony_ci
30348c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_C, 0, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30358c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_C, 1, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30368c2ecf20Sopenharmony_ci	MMIO_F(PLANE_WM(PIPE_C, 2, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30378c2ecf20Sopenharmony_ci
30388c2ecf20Sopenharmony_ci	MMIO_F(CUR_WM(PIPE_A, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30398c2ecf20Sopenharmony_ci	MMIO_F(CUR_WM(PIPE_B, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30408c2ecf20Sopenharmony_ci	MMIO_F(CUR_WM(PIPE_C, 0), 4 * 8, 0, 0, 0, D_SKL_PLUS, NULL, NULL);
30418c2ecf20Sopenharmony_ci
30428c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_A, 0), D_SKL_PLUS, NULL, NULL);
30438c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_A, 1), D_SKL_PLUS, NULL, NULL);
30448c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_A, 2), D_SKL_PLUS, NULL, NULL);
30458c2ecf20Sopenharmony_ci
30468c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_B, 0), D_SKL_PLUS, NULL, NULL);
30478c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_B, 1), D_SKL_PLUS, NULL, NULL);
30488c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_B, 2), D_SKL_PLUS, NULL, NULL);
30498c2ecf20Sopenharmony_ci
30508c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_C, 0), D_SKL_PLUS, NULL, NULL);
30518c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_C, 1), D_SKL_PLUS, NULL, NULL);
30528c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_WM_TRANS(PIPE_C, 2), D_SKL_PLUS, NULL, NULL);
30538c2ecf20Sopenharmony_ci
30548c2ecf20Sopenharmony_ci	MMIO_DH(CUR_WM_TRANS(PIPE_A), D_SKL_PLUS, NULL, NULL);
30558c2ecf20Sopenharmony_ci	MMIO_DH(CUR_WM_TRANS(PIPE_B), D_SKL_PLUS, NULL, NULL);
30568c2ecf20Sopenharmony_ci	MMIO_DH(CUR_WM_TRANS(PIPE_C), D_SKL_PLUS, NULL, NULL);
30578c2ecf20Sopenharmony_ci
30588c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_A, 0), D_SKL_PLUS, NULL, NULL);
30598c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_A, 1), D_SKL_PLUS, NULL, NULL);
30608c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_A, 2), D_SKL_PLUS, NULL, NULL);
30618c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_A, 3), D_SKL_PLUS, NULL, NULL);
30628c2ecf20Sopenharmony_ci
30638c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_B, 0), D_SKL_PLUS, NULL, NULL);
30648c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_B, 1), D_SKL_PLUS, NULL, NULL);
30658c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_B, 2), D_SKL_PLUS, NULL, NULL);
30668c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_B, 3), D_SKL_PLUS, NULL, NULL);
30678c2ecf20Sopenharmony_ci
30688c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_C, 0), D_SKL_PLUS, NULL, NULL);
30698c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_C, 1), D_SKL_PLUS, NULL, NULL);
30708c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_C, 2), D_SKL_PLUS, NULL, NULL);
30718c2ecf20Sopenharmony_ci	MMIO_DH(PLANE_NV12_BUF_CFG(PIPE_C, 3), D_SKL_PLUS, NULL, NULL);
30728c2ecf20Sopenharmony_ci
30738c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_A, 1)), D_SKL_PLUS, NULL, NULL);
30748c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_A, 2)), D_SKL_PLUS, NULL, NULL);
30758c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_A, 3)), D_SKL_PLUS, NULL, NULL);
30768c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_A, 4)), D_SKL_PLUS, NULL, NULL);
30778c2ecf20Sopenharmony_ci
30788c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_B, 1)), D_SKL_PLUS, NULL, NULL);
30798c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_B, 2)), D_SKL_PLUS, NULL, NULL);
30808c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_B, 3)), D_SKL_PLUS, NULL, NULL);
30818c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_B, 4)), D_SKL_PLUS, NULL, NULL);
30828c2ecf20Sopenharmony_ci
30838c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_C, 1)), D_SKL_PLUS, NULL, NULL);
30848c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_C, 2)), D_SKL_PLUS, NULL, NULL);
30858c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_C, 3)), D_SKL_PLUS, NULL, NULL);
30868c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C0(PIPE_C, 4)), D_SKL_PLUS, NULL, NULL);
30878c2ecf20Sopenharmony_ci
30888c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_A, 1)), D_SKL_PLUS, NULL, NULL);
30898c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_A, 2)), D_SKL_PLUS, NULL, NULL);
30908c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_A, 3)), D_SKL_PLUS, NULL, NULL);
30918c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_A, 4)), D_SKL_PLUS, NULL, NULL);
30928c2ecf20Sopenharmony_ci
30938c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_B, 1)), D_SKL_PLUS, NULL, NULL);
30948c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_B, 2)), D_SKL_PLUS, NULL, NULL);
30958c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_B, 3)), D_SKL_PLUS, NULL, NULL);
30968c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_B, 4)), D_SKL_PLUS, NULL, NULL);
30978c2ecf20Sopenharmony_ci
30988c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_C, 1)), D_SKL_PLUS, NULL, NULL);
30998c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_C, 2)), D_SKL_PLUS, NULL, NULL);
31008c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_C, 3)), D_SKL_PLUS, NULL, NULL);
31018c2ecf20Sopenharmony_ci	MMIO_DH(_MMIO(_REG_701C4(PIPE_C, 4)), D_SKL_PLUS, NULL, NULL);
31028c2ecf20Sopenharmony_ci
31038c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_CTL_3_A), D_SKL_PLUS);
31048c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_CTL_3_B), D_SKL_PLUS);
31058c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x72380), D_SKL_PLUS);
31068c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x7239c), D_SKL_PLUS);
31078c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_SURF_3_A), D_SKL_PLUS);
31088c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_SURF_3_B), D_SKL_PLUS);
31098c2ecf20Sopenharmony_ci
31108c2ecf20Sopenharmony_ci	MMIO_D(CSR_SSP_BASE, D_SKL_PLUS);
31118c2ecf20Sopenharmony_ci	MMIO_D(CSR_HTP_SKL, D_SKL_PLUS);
31128c2ecf20Sopenharmony_ci	MMIO_D(CSR_LAST_WRITE, D_SKL_PLUS);
31138c2ecf20Sopenharmony_ci
31148c2ecf20Sopenharmony_ci	MMIO_DFH(BDW_SCRATCH1, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31158c2ecf20Sopenharmony_ci
31168c2ecf20Sopenharmony_ci	MMIO_D(SKL_DFSM, D_SKL_PLUS);
31178c2ecf20Sopenharmony_ci	MMIO_D(DISPIO_CR_TX_BMU_CR0, D_SKL_PLUS);
31188c2ecf20Sopenharmony_ci
31198c2ecf20Sopenharmony_ci	MMIO_F(GEN9_GFX_MOCS(0), 0x7f8, F_CMD_ACCESS, 0, 0, D_SKL_PLUS,
31208c2ecf20Sopenharmony_ci		NULL, NULL);
31218c2ecf20Sopenharmony_ci	MMIO_F(GEN7_L3CNTLREG2, 0x80, F_CMD_ACCESS, 0, 0, D_SKL_PLUS,
31228c2ecf20Sopenharmony_ci		NULL, NULL);
31238c2ecf20Sopenharmony_ci
31248c2ecf20Sopenharmony_ci	MMIO_D(RPM_CONFIG0, D_SKL_PLUS);
31258c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xd08), D_SKL_PLUS);
31268c2ecf20Sopenharmony_ci	MMIO_D(RC6_LOCATION, D_SKL_PLUS);
31278c2ecf20Sopenharmony_ci	MMIO_DFH(GEN7_FF_SLICE_CS_CHICKEN1, D_SKL_PLUS,
31288c2ecf20Sopenharmony_ci		 F_MODE_MASK | F_CMD_ACCESS, NULL, NULL);
31298c2ecf20Sopenharmony_ci	MMIO_DFH(GEN9_CS_DEBUG_MODE1, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
31308c2ecf20Sopenharmony_ci		NULL, NULL);
31318c2ecf20Sopenharmony_ci
31328c2ecf20Sopenharmony_ci	/* TRTT */
31338c2ecf20Sopenharmony_ci	MMIO_DFH(TRVATTL3PTRDW(0), D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31348c2ecf20Sopenharmony_ci	MMIO_DFH(TRVATTL3PTRDW(1), D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31358c2ecf20Sopenharmony_ci	MMIO_DFH(TRVATTL3PTRDW(2), D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31368c2ecf20Sopenharmony_ci	MMIO_DFH(TRVATTL3PTRDW(3), D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31378c2ecf20Sopenharmony_ci	MMIO_DFH(TRVADR, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31388c2ecf20Sopenharmony_ci	MMIO_DFH(TRTTE, D_SKL_PLUS, F_CMD_ACCESS | F_PM_SAVE,
31398c2ecf20Sopenharmony_ci		 NULL, gen9_trtte_write);
31408c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x4dfc), D_SKL_PLUS, F_PM_SAVE,
31418c2ecf20Sopenharmony_ci		 NULL, gen9_trtt_chicken_write);
31428c2ecf20Sopenharmony_ci
31438c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x46430), D_SKL_PLUS);
31448c2ecf20Sopenharmony_ci
31458c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x46520), D_SKL_PLUS);
31468c2ecf20Sopenharmony_ci
31478c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0xc403c), D_SKL_PLUS);
31488c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_GARBCNTL, D_SKL_PLUS, F_CMD_ACCESS, NULL, NULL);
31498c2ecf20Sopenharmony_ci	MMIO_DH(DMA_CTRL, D_SKL_PLUS, NULL, dma_ctrl_write);
31508c2ecf20Sopenharmony_ci
31518c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x65900), D_SKL_PLUS);
31528c2ecf20Sopenharmony_ci	MMIO_D(GEN6_STOLEN_RESERVED, D_SKL_PLUS);
31538c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x4068), D_SKL_PLUS);
31548c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x67054), D_SKL_PLUS);
31558c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6e560), D_SKL_PLUS);
31568c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x6e554), D_SKL_PLUS);
31578c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x2b20), D_SKL_PLUS);
31588c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x65f00), D_SKL_PLUS);
31598c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x65f08), D_SKL_PLUS);
31608c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x320f0), D_SKL_PLUS);
31618c2ecf20Sopenharmony_ci
31628c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x70034), D_SKL_PLUS);
31638c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x71034), D_SKL_PLUS);
31648c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x72034), D_SKL_PLUS);
31658c2ecf20Sopenharmony_ci
31668c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYVAL_1(PIPE_A)), D_SKL_PLUS);
31678c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYVAL_1(PIPE_B)), D_SKL_PLUS);
31688c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYVAL_1(PIPE_C)), D_SKL_PLUS);
31698c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMAX_1(PIPE_A)), D_SKL_PLUS);
31708c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMAX_1(PIPE_B)), D_SKL_PLUS);
31718c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMAX_1(PIPE_C)), D_SKL_PLUS);
31728c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMSK_1(PIPE_A)), D_SKL_PLUS);
31738c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMSK_1(PIPE_B)), D_SKL_PLUS);
31748c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(_PLANE_KEYMSK_1(PIPE_C)), D_SKL_PLUS);
31758c2ecf20Sopenharmony_ci
31768c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x44500), D_SKL_PLUS);
31778c2ecf20Sopenharmony_ci#define CSFE_CHICKEN1_REG(base) _MMIO((base) + 0xD4)
31788c2ecf20Sopenharmony_ci	MMIO_RING_DFH(CSFE_CHICKEN1_REG, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
31798c2ecf20Sopenharmony_ci		      NULL, csfe_chicken1_mmio_write);
31808c2ecf20Sopenharmony_ci#undef CSFE_CHICKEN1_REG
31818c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_HDC_CHICKEN1, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
31828c2ecf20Sopenharmony_ci		 NULL, NULL);
31838c2ecf20Sopenharmony_ci	MMIO_DFH(GEN9_WM_CHICKEN3, D_SKL_PLUS, F_MODE_MASK | F_CMD_ACCESS,
31848c2ecf20Sopenharmony_ci		 NULL, NULL);
31858c2ecf20Sopenharmony_ci
31868c2ecf20Sopenharmony_ci	MMIO_DFH(GAMT_CHKN_BIT_REG, D_KBL | D_CFL, F_CMD_ACCESS, NULL, NULL);
31878c2ecf20Sopenharmony_ci	MMIO_D(GEN9_CTX_PREEMPT_REG, D_SKL_PLUS & ~D_BXT);
31888c2ecf20Sopenharmony_ci
31898c2ecf20Sopenharmony_ci	return 0;
31908c2ecf20Sopenharmony_ci}
31918c2ecf20Sopenharmony_ci
31928c2ecf20Sopenharmony_cistatic int init_bxt_mmio_info(struct intel_gvt *gvt)
31938c2ecf20Sopenharmony_ci{
31948c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = gvt->gt->i915;
31958c2ecf20Sopenharmony_ci	int ret;
31968c2ecf20Sopenharmony_ci
31978c2ecf20Sopenharmony_ci	MMIO_F(_MMIO(0x80000), 0x3000, 0, 0, 0, D_BXT, NULL, NULL);
31988c2ecf20Sopenharmony_ci
31998c2ecf20Sopenharmony_ci	MMIO_D(GEN7_SAMPLER_INSTDONE, D_BXT);
32008c2ecf20Sopenharmony_ci	MMIO_D(GEN7_ROW_INSTDONE, D_BXT);
32018c2ecf20Sopenharmony_ci	MMIO_D(GEN8_FAULT_TLB_DATA0, D_BXT);
32028c2ecf20Sopenharmony_ci	MMIO_D(GEN8_FAULT_TLB_DATA1, D_BXT);
32038c2ecf20Sopenharmony_ci	MMIO_D(ERROR_GEN6, D_BXT);
32048c2ecf20Sopenharmony_ci	MMIO_D(DONE_REG, D_BXT);
32058c2ecf20Sopenharmony_ci	MMIO_D(EIR, D_BXT);
32068c2ecf20Sopenharmony_ci	MMIO_D(PGTBL_ER, D_BXT);
32078c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x4194), D_BXT);
32088c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x4294), D_BXT);
32098c2ecf20Sopenharmony_ci	MMIO_D(_MMIO(0x4494), D_BXT);
32108c2ecf20Sopenharmony_ci
32118c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_PSMI_CTL, D_BXT);
32128c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_DMA_FADD, D_BXT);
32138c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_DMA_FADD_UDW, D_BXT);
32148c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_IPEHR, D_BXT);
32158c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_INSTPS, D_BXT);
32168c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_BBADDR_UDW, D_BXT);
32178c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_BBSTATE, D_BXT);
32188c2ecf20Sopenharmony_ci	MMIO_RING_D(RING_IPEIR, D_BXT);
32198c2ecf20Sopenharmony_ci
32208c2ecf20Sopenharmony_ci	MMIO_F(SOFT_SCRATCH(0), 16 * 4, 0, 0, 0, D_BXT, NULL, NULL);
32218c2ecf20Sopenharmony_ci
32228c2ecf20Sopenharmony_ci	MMIO_DH(BXT_P_CR_GT_DISP_PWRON, D_BXT, NULL, bxt_gt_disp_pwron_write);
32238c2ecf20Sopenharmony_ci	MMIO_D(BXT_RP_STATE_CAP, D_BXT);
32248c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PHY_CTL_FAMILY(DPIO_PHY0), D_BXT,
32258c2ecf20Sopenharmony_ci		NULL, bxt_phy_ctl_family_write);
32268c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PHY_CTL_FAMILY(DPIO_PHY1), D_BXT,
32278c2ecf20Sopenharmony_ci		NULL, bxt_phy_ctl_family_write);
32288c2ecf20Sopenharmony_ci	MMIO_D(BXT_PHY_CTL(PORT_A), D_BXT);
32298c2ecf20Sopenharmony_ci	MMIO_D(BXT_PHY_CTL(PORT_B), D_BXT);
32308c2ecf20Sopenharmony_ci	MMIO_D(BXT_PHY_CTL(PORT_C), D_BXT);
32318c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PLL_ENABLE(PORT_A), D_BXT,
32328c2ecf20Sopenharmony_ci		NULL, bxt_port_pll_enable_write);
32338c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PLL_ENABLE(PORT_B), D_BXT,
32348c2ecf20Sopenharmony_ci		NULL, bxt_port_pll_enable_write);
32358c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PLL_ENABLE(PORT_C), D_BXT, NULL,
32368c2ecf20Sopenharmony_ci		bxt_port_pll_enable_write);
32378c2ecf20Sopenharmony_ci
32388c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW0(DPIO_PHY0), D_BXT);
32398c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW9(DPIO_PHY0), D_BXT);
32408c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW10(DPIO_PHY0), D_BXT);
32418c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW28(DPIO_PHY0), D_BXT);
32428c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW30(DPIO_PHY0), D_BXT);
32438c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL2CM_DW6(DPIO_PHY0), D_BXT);
32448c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW3(DPIO_PHY0), D_BXT);
32458c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW6(DPIO_PHY0), D_BXT);
32468c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW8(DPIO_PHY0), D_BXT);
32478c2ecf20Sopenharmony_ci
32488c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW0(DPIO_PHY1), D_BXT);
32498c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW9(DPIO_PHY1), D_BXT);
32508c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW10(DPIO_PHY1), D_BXT);
32518c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW28(DPIO_PHY1), D_BXT);
32528c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL1CM_DW30(DPIO_PHY1), D_BXT);
32538c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_CL2CM_DW6(DPIO_PHY1), D_BXT);
32548c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW3(DPIO_PHY1), D_BXT);
32558c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW6(DPIO_PHY1), D_BXT);
32568c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_REF_DW8(DPIO_PHY1), D_BXT);
32578c2ecf20Sopenharmony_ci
32588c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_0(DPIO_PHY0, DPIO_CH0), D_BXT);
32598c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_4(DPIO_PHY0, DPIO_CH0), D_BXT);
32608c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_LN01(DPIO_PHY0, DPIO_CH0), D_BXT);
32618c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_GRP(DPIO_PHY0, DPIO_CH0), D_BXT);
32628c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN01(DPIO_PHY0, DPIO_CH0), D_BXT);
32638c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN23(DPIO_PHY0, DPIO_CH0), D_BXT);
32648c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PCS_DW12_GRP(DPIO_PHY0, DPIO_CH0), D_BXT,
32658c2ecf20Sopenharmony_ci		NULL, bxt_pcs_dw12_grp_write);
32668c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_LN0(DPIO_PHY0, DPIO_CH0), D_BXT);
32678c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_GRP(DPIO_PHY0, DPIO_CH0), D_BXT);
32688c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_TX_DW3_LN0(DPIO_PHY0, DPIO_CH0), D_BXT,
32698c2ecf20Sopenharmony_ci		bxt_port_tx_dw3_read, NULL);
32708c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW3_GRP(DPIO_PHY0, DPIO_CH0), D_BXT);
32718c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_LN0(DPIO_PHY0, DPIO_CH0), D_BXT);
32728c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_GRP(DPIO_PHY0, DPIO_CH0), D_BXT);
32738c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH0, 0), D_BXT);
32748c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH0, 1), D_BXT);
32758c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH0, 2), D_BXT);
32768c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH0, 3), D_BXT);
32778c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 0), D_BXT);
32788c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 1), D_BXT);
32798c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 2), D_BXT);
32808c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 3), D_BXT);
32818c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 6), D_BXT);
32828c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 8), D_BXT);
32838c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 9), D_BXT);
32848c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH0, 10), D_BXT);
32858c2ecf20Sopenharmony_ci
32868c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_0(DPIO_PHY0, DPIO_CH1), D_BXT);
32878c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_4(DPIO_PHY0, DPIO_CH1), D_BXT);
32888c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_LN01(DPIO_PHY0, DPIO_CH1), D_BXT);
32898c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_GRP(DPIO_PHY0, DPIO_CH1), D_BXT);
32908c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN01(DPIO_PHY0, DPIO_CH1), D_BXT);
32918c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN23(DPIO_PHY0, DPIO_CH1), D_BXT);
32928c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PCS_DW12_GRP(DPIO_PHY0, DPIO_CH1), D_BXT,
32938c2ecf20Sopenharmony_ci		NULL, bxt_pcs_dw12_grp_write);
32948c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_LN0(DPIO_PHY0, DPIO_CH1), D_BXT);
32958c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_GRP(DPIO_PHY0, DPIO_CH1), D_BXT);
32968c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_TX_DW3_LN0(DPIO_PHY0, DPIO_CH1), D_BXT,
32978c2ecf20Sopenharmony_ci		bxt_port_tx_dw3_read, NULL);
32988c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW3_GRP(DPIO_PHY0, DPIO_CH1), D_BXT);
32998c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_LN0(DPIO_PHY0, DPIO_CH1), D_BXT);
33008c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_GRP(DPIO_PHY0, DPIO_CH1), D_BXT);
33018c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH1, 0), D_BXT);
33028c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH1, 1), D_BXT);
33038c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH1, 2), D_BXT);
33048c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY0, DPIO_CH1, 3), D_BXT);
33058c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 0), D_BXT);
33068c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 1), D_BXT);
33078c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 2), D_BXT);
33088c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 3), D_BXT);
33098c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 6), D_BXT);
33108c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 8), D_BXT);
33118c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 9), D_BXT);
33128c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY0, DPIO_CH1, 10), D_BXT);
33138c2ecf20Sopenharmony_ci
33148c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_0(DPIO_PHY1, DPIO_CH0), D_BXT);
33158c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL_EBB_4(DPIO_PHY1, DPIO_CH0), D_BXT);
33168c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_LN01(DPIO_PHY1, DPIO_CH0), D_BXT);
33178c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW10_GRP(DPIO_PHY1, DPIO_CH0), D_BXT);
33188c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN01(DPIO_PHY1, DPIO_CH0), D_BXT);
33198c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PCS_DW12_LN23(DPIO_PHY1, DPIO_CH0), D_BXT);
33208c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_PCS_DW12_GRP(DPIO_PHY1, DPIO_CH0), D_BXT,
33218c2ecf20Sopenharmony_ci		NULL, bxt_pcs_dw12_grp_write);
33228c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_LN0(DPIO_PHY1, DPIO_CH0), D_BXT);
33238c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW2_GRP(DPIO_PHY1, DPIO_CH0), D_BXT);
33248c2ecf20Sopenharmony_ci	MMIO_DH(BXT_PORT_TX_DW3_LN0(DPIO_PHY1, DPIO_CH0), D_BXT,
33258c2ecf20Sopenharmony_ci		bxt_port_tx_dw3_read, NULL);
33268c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW3_GRP(DPIO_PHY1, DPIO_CH0), D_BXT);
33278c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_LN0(DPIO_PHY1, DPIO_CH0), D_BXT);
33288c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW4_GRP(DPIO_PHY1, DPIO_CH0), D_BXT);
33298c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY1, DPIO_CH0, 0), D_BXT);
33308c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY1, DPIO_CH0, 1), D_BXT);
33318c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY1, DPIO_CH0, 2), D_BXT);
33328c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_TX_DW14_LN(DPIO_PHY1, DPIO_CH0, 3), D_BXT);
33338c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 0), D_BXT);
33348c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 1), D_BXT);
33358c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 2), D_BXT);
33368c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 3), D_BXT);
33378c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 6), D_BXT);
33388c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 8), D_BXT);
33398c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 9), D_BXT);
33408c2ecf20Sopenharmony_ci	MMIO_D(BXT_PORT_PLL(DPIO_PHY1, DPIO_CH0, 10), D_BXT);
33418c2ecf20Sopenharmony_ci
33428c2ecf20Sopenharmony_ci	MMIO_D(BXT_DE_PLL_CTL, D_BXT);
33438c2ecf20Sopenharmony_ci	MMIO_DH(BXT_DE_PLL_ENABLE, D_BXT, NULL, bxt_de_pll_enable_write);
33448c2ecf20Sopenharmony_ci	MMIO_D(BXT_DSI_PLL_CTL, D_BXT);
33458c2ecf20Sopenharmony_ci	MMIO_D(BXT_DSI_PLL_ENABLE, D_BXT);
33468c2ecf20Sopenharmony_ci
33478c2ecf20Sopenharmony_ci	MMIO_D(GEN9_CLKGATE_DIS_0, D_BXT);
33488c2ecf20Sopenharmony_ci	MMIO_D(GEN9_CLKGATE_DIS_4, D_BXT);
33498c2ecf20Sopenharmony_ci
33508c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_GCP(TRANSCODER_A), D_BXT);
33518c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_GCP(TRANSCODER_B), D_BXT);
33528c2ecf20Sopenharmony_ci	MMIO_D(HSW_TVIDEO_DIP_GCP(TRANSCODER_C), D_BXT);
33538c2ecf20Sopenharmony_ci
33548c2ecf20Sopenharmony_ci	MMIO_D(RC6_CTX_BASE, D_BXT);
33558c2ecf20Sopenharmony_ci
33568c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PUSHBUS_CONTROL, D_BXT);
33578c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PUSHBUS_ENABLE, D_BXT);
33588c2ecf20Sopenharmony_ci	MMIO_D(GEN8_PUSHBUS_SHIFT, D_BXT);
33598c2ecf20Sopenharmony_ci	MMIO_D(GEN6_GFXPAUSE, D_BXT);
33608c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_L3SQCREG1, D_BXT, F_CMD_ACCESS, NULL, NULL);
33618c2ecf20Sopenharmony_ci	MMIO_DFH(GEN8_L3CNTLREG, D_BXT, F_CMD_ACCESS, NULL, NULL);
33628c2ecf20Sopenharmony_ci	MMIO_DFH(_MMIO(0x20D8), D_BXT, F_CMD_ACCESS, NULL, NULL);
33638c2ecf20Sopenharmony_ci	MMIO_F(GEN8_RING_CS_GPR(RENDER_RING_BASE, 0), 0x40, F_CMD_ACCESS,
33648c2ecf20Sopenharmony_ci	       0, 0, D_BXT, NULL, NULL);
33658c2ecf20Sopenharmony_ci	MMIO_F(GEN8_RING_CS_GPR(GEN6_BSD_RING_BASE, 0), 0x40, F_CMD_ACCESS,
33668c2ecf20Sopenharmony_ci	       0, 0, D_BXT, NULL, NULL);
33678c2ecf20Sopenharmony_ci	MMIO_F(GEN8_RING_CS_GPR(BLT_RING_BASE, 0), 0x40, F_CMD_ACCESS,
33688c2ecf20Sopenharmony_ci	       0, 0, D_BXT, NULL, NULL);
33698c2ecf20Sopenharmony_ci	MMIO_F(GEN8_RING_CS_GPR(VEBOX_RING_BASE, 0), 0x40, F_CMD_ACCESS,
33708c2ecf20Sopenharmony_ci	       0, 0, D_BXT, NULL, NULL);
33718c2ecf20Sopenharmony_ci
33728c2ecf20Sopenharmony_ci	MMIO_DFH(GEN9_CTX_PREEMPT_REG, D_BXT, F_CMD_ACCESS, NULL, NULL);
33738c2ecf20Sopenharmony_ci
33748c2ecf20Sopenharmony_ci	MMIO_DH(GEN8_PRIVATE_PAT_LO, D_BXT, NULL, bxt_ppat_low_write);
33758c2ecf20Sopenharmony_ci
33768c2ecf20Sopenharmony_ci	return 0;
33778c2ecf20Sopenharmony_ci}
33788c2ecf20Sopenharmony_ci
33798c2ecf20Sopenharmony_cistatic struct gvt_mmio_block *find_mmio_block(struct intel_gvt *gvt,
33808c2ecf20Sopenharmony_ci					      unsigned int offset)
33818c2ecf20Sopenharmony_ci{
33828c2ecf20Sopenharmony_ci	unsigned long device = intel_gvt_get_device_type(gvt);
33838c2ecf20Sopenharmony_ci	struct gvt_mmio_block *block = gvt->mmio.mmio_block;
33848c2ecf20Sopenharmony_ci	int num = gvt->mmio.num_mmio_block;
33858c2ecf20Sopenharmony_ci	int i;
33868c2ecf20Sopenharmony_ci
33878c2ecf20Sopenharmony_ci	for (i = 0; i < num; i++, block++) {
33888c2ecf20Sopenharmony_ci		if (!(device & block->device))
33898c2ecf20Sopenharmony_ci			continue;
33908c2ecf20Sopenharmony_ci		if (offset >= i915_mmio_reg_offset(block->offset) &&
33918c2ecf20Sopenharmony_ci		    offset < i915_mmio_reg_offset(block->offset) + block->size)
33928c2ecf20Sopenharmony_ci			return block;
33938c2ecf20Sopenharmony_ci	}
33948c2ecf20Sopenharmony_ci	return NULL;
33958c2ecf20Sopenharmony_ci}
33968c2ecf20Sopenharmony_ci
33978c2ecf20Sopenharmony_ci/**
33988c2ecf20Sopenharmony_ci * intel_gvt_clean_mmio_info - clean up MMIO information table for GVT device
33998c2ecf20Sopenharmony_ci * @gvt: GVT device
34008c2ecf20Sopenharmony_ci *
34018c2ecf20Sopenharmony_ci * This function is called at the driver unloading stage, to clean up the MMIO
34028c2ecf20Sopenharmony_ci * information table of GVT device
34038c2ecf20Sopenharmony_ci *
34048c2ecf20Sopenharmony_ci */
34058c2ecf20Sopenharmony_civoid intel_gvt_clean_mmio_info(struct intel_gvt *gvt)
34068c2ecf20Sopenharmony_ci{
34078c2ecf20Sopenharmony_ci	struct hlist_node *tmp;
34088c2ecf20Sopenharmony_ci	struct intel_gvt_mmio_info *e;
34098c2ecf20Sopenharmony_ci	int i;
34108c2ecf20Sopenharmony_ci
34118c2ecf20Sopenharmony_ci	hash_for_each_safe(gvt->mmio.mmio_info_table, i, tmp, e, node)
34128c2ecf20Sopenharmony_ci		kfree(e);
34138c2ecf20Sopenharmony_ci
34148c2ecf20Sopenharmony_ci	vfree(gvt->mmio.mmio_attribute);
34158c2ecf20Sopenharmony_ci	gvt->mmio.mmio_attribute = NULL;
34168c2ecf20Sopenharmony_ci}
34178c2ecf20Sopenharmony_ci
34188c2ecf20Sopenharmony_ci/* Special MMIO blocks. registers in MMIO block ranges should not be command
34198c2ecf20Sopenharmony_ci * accessible (should have no F_CMD_ACCESS flag).
34208c2ecf20Sopenharmony_ci * otherwise, need to update cmd_reg_handler in cmd_parser.c
34218c2ecf20Sopenharmony_ci */
34228c2ecf20Sopenharmony_cistatic struct gvt_mmio_block mmio_blocks[] = {
34238c2ecf20Sopenharmony_ci	{D_SKL_PLUS, _MMIO(CSR_MMIO_START_RANGE), 0x3000, NULL, NULL},
34248c2ecf20Sopenharmony_ci	{D_ALL, _MMIO(MCHBAR_MIRROR_BASE_SNB), 0x40000, NULL, NULL},
34258c2ecf20Sopenharmony_ci	{D_ALL, _MMIO(VGT_PVINFO_PAGE), VGT_PVINFO_SIZE,
34268c2ecf20Sopenharmony_ci		pvinfo_mmio_read, pvinfo_mmio_write},
34278c2ecf20Sopenharmony_ci	{D_ALL, LGC_PALETTE(PIPE_A, 0), 1024, NULL, NULL},
34288c2ecf20Sopenharmony_ci	{D_ALL, LGC_PALETTE(PIPE_B, 0), 1024, NULL, NULL},
34298c2ecf20Sopenharmony_ci	{D_ALL, LGC_PALETTE(PIPE_C, 0), 1024, NULL, NULL},
34308c2ecf20Sopenharmony_ci};
34318c2ecf20Sopenharmony_ci
34328c2ecf20Sopenharmony_ci/**
34338c2ecf20Sopenharmony_ci * intel_gvt_setup_mmio_info - setup MMIO information table for GVT device
34348c2ecf20Sopenharmony_ci * @gvt: GVT device
34358c2ecf20Sopenharmony_ci *
34368c2ecf20Sopenharmony_ci * This function is called at the initialization stage, to setup the MMIO
34378c2ecf20Sopenharmony_ci * information table for GVT device
34388c2ecf20Sopenharmony_ci *
34398c2ecf20Sopenharmony_ci * Returns:
34408c2ecf20Sopenharmony_ci * zero on success, negative if failed.
34418c2ecf20Sopenharmony_ci */
34428c2ecf20Sopenharmony_ciint intel_gvt_setup_mmio_info(struct intel_gvt *gvt)
34438c2ecf20Sopenharmony_ci{
34448c2ecf20Sopenharmony_ci	struct intel_gvt_device_info *info = &gvt->device_info;
34458c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = gvt->gt->i915;
34468c2ecf20Sopenharmony_ci	int size = info->mmio_size / 4 * sizeof(*gvt->mmio.mmio_attribute);
34478c2ecf20Sopenharmony_ci	int ret;
34488c2ecf20Sopenharmony_ci
34498c2ecf20Sopenharmony_ci	gvt->mmio.mmio_attribute = vzalloc(size);
34508c2ecf20Sopenharmony_ci	if (!gvt->mmio.mmio_attribute)
34518c2ecf20Sopenharmony_ci		return -ENOMEM;
34528c2ecf20Sopenharmony_ci
34538c2ecf20Sopenharmony_ci	ret = init_generic_mmio_info(gvt);
34548c2ecf20Sopenharmony_ci	if (ret)
34558c2ecf20Sopenharmony_ci		goto err;
34568c2ecf20Sopenharmony_ci
34578c2ecf20Sopenharmony_ci	if (IS_BROADWELL(i915)) {
34588c2ecf20Sopenharmony_ci		ret = init_bdw_mmio_info(gvt);
34598c2ecf20Sopenharmony_ci		if (ret)
34608c2ecf20Sopenharmony_ci			goto err;
34618c2ecf20Sopenharmony_ci	} else if (IS_SKYLAKE(i915) ||
34628c2ecf20Sopenharmony_ci		   IS_KABYLAKE(i915) ||
34638c2ecf20Sopenharmony_ci		   IS_COFFEELAKE(i915) ||
34648c2ecf20Sopenharmony_ci		   IS_COMETLAKE(i915)) {
34658c2ecf20Sopenharmony_ci		ret = init_bdw_mmio_info(gvt);
34668c2ecf20Sopenharmony_ci		if (ret)
34678c2ecf20Sopenharmony_ci			goto err;
34688c2ecf20Sopenharmony_ci		ret = init_skl_mmio_info(gvt);
34698c2ecf20Sopenharmony_ci		if (ret)
34708c2ecf20Sopenharmony_ci			goto err;
34718c2ecf20Sopenharmony_ci	} else if (IS_BROXTON(i915)) {
34728c2ecf20Sopenharmony_ci		ret = init_bdw_mmio_info(gvt);
34738c2ecf20Sopenharmony_ci		if (ret)
34748c2ecf20Sopenharmony_ci			goto err;
34758c2ecf20Sopenharmony_ci		ret = init_skl_mmio_info(gvt);
34768c2ecf20Sopenharmony_ci		if (ret)
34778c2ecf20Sopenharmony_ci			goto err;
34788c2ecf20Sopenharmony_ci		ret = init_bxt_mmio_info(gvt);
34798c2ecf20Sopenharmony_ci		if (ret)
34808c2ecf20Sopenharmony_ci			goto err;
34818c2ecf20Sopenharmony_ci	}
34828c2ecf20Sopenharmony_ci
34838c2ecf20Sopenharmony_ci	gvt->mmio.mmio_block = mmio_blocks;
34848c2ecf20Sopenharmony_ci	gvt->mmio.num_mmio_block = ARRAY_SIZE(mmio_blocks);
34858c2ecf20Sopenharmony_ci
34868c2ecf20Sopenharmony_ci	return 0;
34878c2ecf20Sopenharmony_cierr:
34888c2ecf20Sopenharmony_ci	intel_gvt_clean_mmio_info(gvt);
34898c2ecf20Sopenharmony_ci	return ret;
34908c2ecf20Sopenharmony_ci}
34918c2ecf20Sopenharmony_ci
34928c2ecf20Sopenharmony_ci/**
34938c2ecf20Sopenharmony_ci * intel_gvt_for_each_tracked_mmio - iterate each tracked mmio
34948c2ecf20Sopenharmony_ci * @gvt: a GVT device
34958c2ecf20Sopenharmony_ci * @handler: the handler
34968c2ecf20Sopenharmony_ci * @data: private data given to handler
34978c2ecf20Sopenharmony_ci *
34988c2ecf20Sopenharmony_ci * Returns:
34998c2ecf20Sopenharmony_ci * Zero on success, negative error code if failed.
35008c2ecf20Sopenharmony_ci */
35018c2ecf20Sopenharmony_ciint intel_gvt_for_each_tracked_mmio(struct intel_gvt *gvt,
35028c2ecf20Sopenharmony_ci	int (*handler)(struct intel_gvt *gvt, u32 offset, void *data),
35038c2ecf20Sopenharmony_ci	void *data)
35048c2ecf20Sopenharmony_ci{
35058c2ecf20Sopenharmony_ci	struct gvt_mmio_block *block = gvt->mmio.mmio_block;
35068c2ecf20Sopenharmony_ci	struct intel_gvt_mmio_info *e;
35078c2ecf20Sopenharmony_ci	int i, j, ret;
35088c2ecf20Sopenharmony_ci
35098c2ecf20Sopenharmony_ci	hash_for_each(gvt->mmio.mmio_info_table, i, e, node) {
35108c2ecf20Sopenharmony_ci		ret = handler(gvt, e->offset, data);
35118c2ecf20Sopenharmony_ci		if (ret)
35128c2ecf20Sopenharmony_ci			return ret;
35138c2ecf20Sopenharmony_ci	}
35148c2ecf20Sopenharmony_ci
35158c2ecf20Sopenharmony_ci	for (i = 0; i < gvt->mmio.num_mmio_block; i++, block++) {
35168c2ecf20Sopenharmony_ci		/* pvinfo data doesn't come from hw mmio */
35178c2ecf20Sopenharmony_ci		if (i915_mmio_reg_offset(block->offset) == VGT_PVINFO_PAGE)
35188c2ecf20Sopenharmony_ci			continue;
35198c2ecf20Sopenharmony_ci
35208c2ecf20Sopenharmony_ci		for (j = 0; j < block->size; j += 4) {
35218c2ecf20Sopenharmony_ci			ret = handler(gvt,
35228c2ecf20Sopenharmony_ci				      i915_mmio_reg_offset(block->offset) + j,
35238c2ecf20Sopenharmony_ci				      data);
35248c2ecf20Sopenharmony_ci			if (ret)
35258c2ecf20Sopenharmony_ci				return ret;
35268c2ecf20Sopenharmony_ci		}
35278c2ecf20Sopenharmony_ci	}
35288c2ecf20Sopenharmony_ci	return 0;
35298c2ecf20Sopenharmony_ci}
35308c2ecf20Sopenharmony_ci
35318c2ecf20Sopenharmony_ci/**
35328c2ecf20Sopenharmony_ci * intel_vgpu_default_mmio_read - default MMIO read handler
35338c2ecf20Sopenharmony_ci * @vgpu: a vGPU
35348c2ecf20Sopenharmony_ci * @offset: access offset
35358c2ecf20Sopenharmony_ci * @p_data: data return buffer
35368c2ecf20Sopenharmony_ci * @bytes: access data length
35378c2ecf20Sopenharmony_ci *
35388c2ecf20Sopenharmony_ci * Returns:
35398c2ecf20Sopenharmony_ci * Zero on success, negative error code if failed.
35408c2ecf20Sopenharmony_ci */
35418c2ecf20Sopenharmony_ciint intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
35428c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
35438c2ecf20Sopenharmony_ci{
35448c2ecf20Sopenharmony_ci	read_vreg(vgpu, offset, p_data, bytes);
35458c2ecf20Sopenharmony_ci	return 0;
35468c2ecf20Sopenharmony_ci}
35478c2ecf20Sopenharmony_ci
35488c2ecf20Sopenharmony_ci/**
35498c2ecf20Sopenharmony_ci * intel_t_default_mmio_write - default MMIO write handler
35508c2ecf20Sopenharmony_ci * @vgpu: a vGPU
35518c2ecf20Sopenharmony_ci * @offset: access offset
35528c2ecf20Sopenharmony_ci * @p_data: write data buffer
35538c2ecf20Sopenharmony_ci * @bytes: access data length
35548c2ecf20Sopenharmony_ci *
35558c2ecf20Sopenharmony_ci * Returns:
35568c2ecf20Sopenharmony_ci * Zero on success, negative error code if failed.
35578c2ecf20Sopenharmony_ci */
35588c2ecf20Sopenharmony_ciint intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
35598c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
35608c2ecf20Sopenharmony_ci{
35618c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
35628c2ecf20Sopenharmony_ci	return 0;
35638c2ecf20Sopenharmony_ci}
35648c2ecf20Sopenharmony_ci
35658c2ecf20Sopenharmony_ci/**
35668c2ecf20Sopenharmony_ci * intel_vgpu_mask_mmio_write - write mask register
35678c2ecf20Sopenharmony_ci * @vgpu: a vGPU
35688c2ecf20Sopenharmony_ci * @offset: access offset
35698c2ecf20Sopenharmony_ci * @p_data: write data buffer
35708c2ecf20Sopenharmony_ci * @bytes: access data length
35718c2ecf20Sopenharmony_ci *
35728c2ecf20Sopenharmony_ci * Returns:
35738c2ecf20Sopenharmony_ci * Zero on success, negative error code if failed.
35748c2ecf20Sopenharmony_ci */
35758c2ecf20Sopenharmony_ciint intel_vgpu_mask_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
35768c2ecf20Sopenharmony_ci		void *p_data, unsigned int bytes)
35778c2ecf20Sopenharmony_ci{
35788c2ecf20Sopenharmony_ci	u32 mask, old_vreg;
35798c2ecf20Sopenharmony_ci
35808c2ecf20Sopenharmony_ci	old_vreg = vgpu_vreg(vgpu, offset);
35818c2ecf20Sopenharmony_ci	write_vreg(vgpu, offset, p_data, bytes);
35828c2ecf20Sopenharmony_ci	mask = vgpu_vreg(vgpu, offset) >> 16;
35838c2ecf20Sopenharmony_ci	vgpu_vreg(vgpu, offset) = (old_vreg & ~mask) |
35848c2ecf20Sopenharmony_ci				(vgpu_vreg(vgpu, offset) & mask);
35858c2ecf20Sopenharmony_ci
35868c2ecf20Sopenharmony_ci	return 0;
35878c2ecf20Sopenharmony_ci}
35888c2ecf20Sopenharmony_ci
35898c2ecf20Sopenharmony_ci/**
35908c2ecf20Sopenharmony_ci * intel_gvt_in_force_nonpriv_whitelist - if a mmio is in whitelist to be
35918c2ecf20Sopenharmony_ci * force-nopriv register
35928c2ecf20Sopenharmony_ci *
35938c2ecf20Sopenharmony_ci * @gvt: a GVT device
35948c2ecf20Sopenharmony_ci * @offset: register offset
35958c2ecf20Sopenharmony_ci *
35968c2ecf20Sopenharmony_ci * Returns:
35978c2ecf20Sopenharmony_ci * True if the register is in force-nonpriv whitelist;
35988c2ecf20Sopenharmony_ci * False if outside;
35998c2ecf20Sopenharmony_ci */
36008c2ecf20Sopenharmony_cibool intel_gvt_in_force_nonpriv_whitelist(struct intel_gvt *gvt,
36018c2ecf20Sopenharmony_ci					  unsigned int offset)
36028c2ecf20Sopenharmony_ci{
36038c2ecf20Sopenharmony_ci	return in_whitelist(offset);
36048c2ecf20Sopenharmony_ci}
36058c2ecf20Sopenharmony_ci
36068c2ecf20Sopenharmony_ci/**
36078c2ecf20Sopenharmony_ci * intel_vgpu_mmio_reg_rw - emulate tracked mmio registers
36088c2ecf20Sopenharmony_ci * @vgpu: a vGPU
36098c2ecf20Sopenharmony_ci * @offset: register offset
36108c2ecf20Sopenharmony_ci * @pdata: data buffer
36118c2ecf20Sopenharmony_ci * @bytes: data length
36128c2ecf20Sopenharmony_ci * @is_read: read or write
36138c2ecf20Sopenharmony_ci *
36148c2ecf20Sopenharmony_ci * Returns:
36158c2ecf20Sopenharmony_ci * Zero on success, negative error code if failed.
36168c2ecf20Sopenharmony_ci */
36178c2ecf20Sopenharmony_ciint intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,
36188c2ecf20Sopenharmony_ci			   void *pdata, unsigned int bytes, bool is_read)
36198c2ecf20Sopenharmony_ci{
36208c2ecf20Sopenharmony_ci	struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
36218c2ecf20Sopenharmony_ci	struct intel_gvt *gvt = vgpu->gvt;
36228c2ecf20Sopenharmony_ci	struct intel_gvt_mmio_info *mmio_info;
36238c2ecf20Sopenharmony_ci	struct gvt_mmio_block *mmio_block;
36248c2ecf20Sopenharmony_ci	gvt_mmio_func func;
36258c2ecf20Sopenharmony_ci	int ret;
36268c2ecf20Sopenharmony_ci
36278c2ecf20Sopenharmony_ci	if (drm_WARN_ON(&i915->drm, bytes > 8))
36288c2ecf20Sopenharmony_ci		return -EINVAL;
36298c2ecf20Sopenharmony_ci
36308c2ecf20Sopenharmony_ci	/*
36318c2ecf20Sopenharmony_ci	 * Handle special MMIO blocks.
36328c2ecf20Sopenharmony_ci	 */
36338c2ecf20Sopenharmony_ci	mmio_block = find_mmio_block(gvt, offset);
36348c2ecf20Sopenharmony_ci	if (mmio_block) {
36358c2ecf20Sopenharmony_ci		func = is_read ? mmio_block->read : mmio_block->write;
36368c2ecf20Sopenharmony_ci		if (func)
36378c2ecf20Sopenharmony_ci			return func(vgpu, offset, pdata, bytes);
36388c2ecf20Sopenharmony_ci		goto default_rw;
36398c2ecf20Sopenharmony_ci	}
36408c2ecf20Sopenharmony_ci
36418c2ecf20Sopenharmony_ci	/*
36428c2ecf20Sopenharmony_ci	 * Normal tracked MMIOs.
36438c2ecf20Sopenharmony_ci	 */
36448c2ecf20Sopenharmony_ci	mmio_info = find_mmio_info(gvt, offset);
36458c2ecf20Sopenharmony_ci	if (!mmio_info) {
36468c2ecf20Sopenharmony_ci		gvt_dbg_mmio("untracked MMIO %08x len %d\n", offset, bytes);
36478c2ecf20Sopenharmony_ci		goto default_rw;
36488c2ecf20Sopenharmony_ci	}
36498c2ecf20Sopenharmony_ci
36508c2ecf20Sopenharmony_ci	if (is_read)
36518c2ecf20Sopenharmony_ci		return mmio_info->read(vgpu, offset, pdata, bytes);
36528c2ecf20Sopenharmony_ci	else {
36538c2ecf20Sopenharmony_ci		u64 ro_mask = mmio_info->ro_mask;
36548c2ecf20Sopenharmony_ci		u32 old_vreg = 0;
36558c2ecf20Sopenharmony_ci		u64 data = 0;
36568c2ecf20Sopenharmony_ci
36578c2ecf20Sopenharmony_ci		if (intel_gvt_mmio_has_mode_mask(gvt, mmio_info->offset)) {
36588c2ecf20Sopenharmony_ci			old_vreg = vgpu_vreg(vgpu, offset);
36598c2ecf20Sopenharmony_ci		}
36608c2ecf20Sopenharmony_ci
36618c2ecf20Sopenharmony_ci		if (likely(!ro_mask))
36628c2ecf20Sopenharmony_ci			ret = mmio_info->write(vgpu, offset, pdata, bytes);
36638c2ecf20Sopenharmony_ci		else if (!~ro_mask) {
36648c2ecf20Sopenharmony_ci			gvt_vgpu_err("try to write RO reg %x\n", offset);
36658c2ecf20Sopenharmony_ci			return 0;
36668c2ecf20Sopenharmony_ci		} else {
36678c2ecf20Sopenharmony_ci			/* keep the RO bits in the virtual register */
36688c2ecf20Sopenharmony_ci			memcpy(&data, pdata, bytes);
36698c2ecf20Sopenharmony_ci			data &= ~ro_mask;
36708c2ecf20Sopenharmony_ci			data |= vgpu_vreg(vgpu, offset) & ro_mask;
36718c2ecf20Sopenharmony_ci			ret = mmio_info->write(vgpu, offset, &data, bytes);
36728c2ecf20Sopenharmony_ci		}
36738c2ecf20Sopenharmony_ci
36748c2ecf20Sopenharmony_ci		/* higher 16bits of mode ctl regs are mask bits for change */
36758c2ecf20Sopenharmony_ci		if (intel_gvt_mmio_has_mode_mask(gvt, mmio_info->offset)) {
36768c2ecf20Sopenharmony_ci			u32 mask = vgpu_vreg(vgpu, offset) >> 16;
36778c2ecf20Sopenharmony_ci
36788c2ecf20Sopenharmony_ci			vgpu_vreg(vgpu, offset) = (old_vreg & ~mask)
36798c2ecf20Sopenharmony_ci					| (vgpu_vreg(vgpu, offset) & mask);
36808c2ecf20Sopenharmony_ci		}
36818c2ecf20Sopenharmony_ci	}
36828c2ecf20Sopenharmony_ci
36838c2ecf20Sopenharmony_ci	return ret;
36848c2ecf20Sopenharmony_ci
36858c2ecf20Sopenharmony_cidefault_rw:
36868c2ecf20Sopenharmony_ci	return is_read ?
36878c2ecf20Sopenharmony_ci		intel_vgpu_default_mmio_read(vgpu, offset, pdata, bytes) :
36888c2ecf20Sopenharmony_ci		intel_vgpu_default_mmio_write(vgpu, offset, pdata, bytes);
36898c2ecf20Sopenharmony_ci}
36908c2ecf20Sopenharmony_ci
36918c2ecf20Sopenharmony_civoid intel_gvt_restore_fence(struct intel_gvt *gvt)
36928c2ecf20Sopenharmony_ci{
36938c2ecf20Sopenharmony_ci	struct intel_vgpu *vgpu;
36948c2ecf20Sopenharmony_ci	int i, id;
36958c2ecf20Sopenharmony_ci
36968c2ecf20Sopenharmony_ci	idr_for_each_entry(&(gvt)->vgpu_idr, vgpu, id) {
36978c2ecf20Sopenharmony_ci		mmio_hw_access_pre(gvt->gt);
36988c2ecf20Sopenharmony_ci		for (i = 0; i < vgpu_fence_sz(vgpu); i++)
36998c2ecf20Sopenharmony_ci			intel_vgpu_write_fence(vgpu, i, vgpu_vreg64(vgpu, fence_num_to_offset(i)));
37008c2ecf20Sopenharmony_ci		mmio_hw_access_post(gvt->gt);
37018c2ecf20Sopenharmony_ci	}
37028c2ecf20Sopenharmony_ci}
37038c2ecf20Sopenharmony_ci
37048c2ecf20Sopenharmony_cistatic inline int mmio_pm_restore_handler(struct intel_gvt *gvt,
37058c2ecf20Sopenharmony_ci					  u32 offset, void *data)
37068c2ecf20Sopenharmony_ci{
37078c2ecf20Sopenharmony_ci	struct intel_vgpu *vgpu = data;
37088c2ecf20Sopenharmony_ci	struct drm_i915_private *dev_priv = gvt->gt->i915;
37098c2ecf20Sopenharmony_ci
37108c2ecf20Sopenharmony_ci	if (gvt->mmio.mmio_attribute[offset >> 2] & F_PM_SAVE)
37118c2ecf20Sopenharmony_ci		I915_WRITE(_MMIO(offset), vgpu_vreg(vgpu, offset));
37128c2ecf20Sopenharmony_ci
37138c2ecf20Sopenharmony_ci	return 0;
37148c2ecf20Sopenharmony_ci}
37158c2ecf20Sopenharmony_ci
37168c2ecf20Sopenharmony_civoid intel_gvt_restore_mmio(struct intel_gvt *gvt)
37178c2ecf20Sopenharmony_ci{
37188c2ecf20Sopenharmony_ci	struct intel_vgpu *vgpu;
37198c2ecf20Sopenharmony_ci	int id;
37208c2ecf20Sopenharmony_ci
37218c2ecf20Sopenharmony_ci	idr_for_each_entry(&(gvt)->vgpu_idr, vgpu, id) {
37228c2ecf20Sopenharmony_ci		mmio_hw_access_pre(gvt->gt);
37238c2ecf20Sopenharmony_ci		intel_gvt_for_each_tracked_mmio(gvt, mmio_pm_restore_handler, vgpu);
37248c2ecf20Sopenharmony_ci		mmio_hw_access_post(gvt->gt);
37258c2ecf20Sopenharmony_ci	}
37268c2ecf20Sopenharmony_ci}
3727