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 * Ke Yu 258c2ecf20Sopenharmony_ci * Kevin Tian <kevin.tian@intel.com> 268c2ecf20Sopenharmony_ci * Dexuan Cui 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Contributors: 298c2ecf20Sopenharmony_ci * Tina Zhang <tina.zhang@intel.com> 308c2ecf20Sopenharmony_ci * Min He <min.he@intel.com> 318c2ecf20Sopenharmony_ci * Niu Bing <bing.niu@intel.com> 328c2ecf20Sopenharmony_ci * Zhi Wang <zhi.a.wang@intel.com> 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#ifndef _GVT_MMIO_H_ 378c2ecf20Sopenharmony_ci#define _GVT_MMIO_H_ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#include <linux/types.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct intel_gvt; 428c2ecf20Sopenharmony_cistruct intel_vgpu; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define D_BDW (1 << 0) 458c2ecf20Sopenharmony_ci#define D_SKL (1 << 1) 468c2ecf20Sopenharmony_ci#define D_KBL (1 << 2) 478c2ecf20Sopenharmony_ci#define D_BXT (1 << 3) 488c2ecf20Sopenharmony_ci#define D_CFL (1 << 4) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define D_GEN9PLUS (D_SKL | D_KBL | D_BXT | D_CFL) 518c2ecf20Sopenharmony_ci#define D_GEN8PLUS (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define D_SKL_PLUS (D_SKL | D_KBL | D_BXT | D_CFL) 548c2ecf20Sopenharmony_ci#define D_BDW_PLUS (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define D_PRE_SKL (D_BDW) 578c2ecf20Sopenharmony_ci#define D_ALL (D_BDW | D_SKL | D_KBL | D_BXT | D_CFL) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_citypedef int (*gvt_mmio_func)(struct intel_vgpu *, unsigned int, void *, 608c2ecf20Sopenharmony_ci unsigned int); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct intel_gvt_mmio_info { 638c2ecf20Sopenharmony_ci u32 offset; 648c2ecf20Sopenharmony_ci u64 ro_mask; 658c2ecf20Sopenharmony_ci u32 device; 668c2ecf20Sopenharmony_ci gvt_mmio_func read; 678c2ecf20Sopenharmony_ci gvt_mmio_func write; 688c2ecf20Sopenharmony_ci u32 addr_range; 698c2ecf20Sopenharmony_ci struct hlist_node node; 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciconst struct intel_engine_cs * 738c2ecf20Sopenharmony_ciintel_gvt_render_mmio_to_engine(struct intel_gvt *gvt, unsigned int reg); 748c2ecf20Sopenharmony_ciunsigned long intel_gvt_get_device_type(struct intel_gvt *gvt); 758c2ecf20Sopenharmony_cibool intel_gvt_match_device(struct intel_gvt *gvt, unsigned long device); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciint intel_gvt_setup_mmio_info(struct intel_gvt *gvt); 788c2ecf20Sopenharmony_civoid intel_gvt_clean_mmio_info(struct intel_gvt *gvt); 798c2ecf20Sopenharmony_ciint intel_gvt_for_each_tracked_mmio(struct intel_gvt *gvt, 808c2ecf20Sopenharmony_ci int (*handler)(struct intel_gvt *gvt, u32 offset, void *data), 818c2ecf20Sopenharmony_ci void *data); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciint intel_vgpu_init_mmio(struct intel_vgpu *vgpu); 848c2ecf20Sopenharmony_civoid intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr); 858c2ecf20Sopenharmony_civoid intel_vgpu_clean_mmio(struct intel_vgpu *vgpu); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciint intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciint intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa, 908c2ecf20Sopenharmony_ci void *p_data, unsigned int bytes); 918c2ecf20Sopenharmony_ciint intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, u64 pa, 928c2ecf20Sopenharmony_ci void *p_data, unsigned int bytes); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciint intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset, 958c2ecf20Sopenharmony_ci void *p_data, unsigned int bytes); 968c2ecf20Sopenharmony_ciint intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, 978c2ecf20Sopenharmony_ci void *p_data, unsigned int bytes); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cibool intel_gvt_in_force_nonpriv_whitelist(struct intel_gvt *gvt, 1008c2ecf20Sopenharmony_ci unsigned int offset); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ciint intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset, 1038c2ecf20Sopenharmony_ci void *pdata, unsigned int bytes, bool is_read); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciint intel_vgpu_mask_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, 1068c2ecf20Sopenharmony_ci void *p_data, unsigned int bytes); 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_civoid intel_gvt_restore_fence(struct intel_gvt *gvt); 1098c2ecf20Sopenharmony_civoid intel_gvt_restore_mmio(struct intel_gvt *gvt); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#endif 112