18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2019 Advanced Micro Devices, Inc. 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 shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#ifndef __AMDGPU_NBIO_H__ 248c2ecf20Sopenharmony_ci#define __AMDGPU_NBIO_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * amdgpu nbio functions 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_cistruct nbio_hdp_flush_reg { 308c2ecf20Sopenharmony_ci u32 ref_and_mask_cp0; 318c2ecf20Sopenharmony_ci u32 ref_and_mask_cp1; 328c2ecf20Sopenharmony_ci u32 ref_and_mask_cp2; 338c2ecf20Sopenharmony_ci u32 ref_and_mask_cp3; 348c2ecf20Sopenharmony_ci u32 ref_and_mask_cp4; 358c2ecf20Sopenharmony_ci u32 ref_and_mask_cp5; 368c2ecf20Sopenharmony_ci u32 ref_and_mask_cp6; 378c2ecf20Sopenharmony_ci u32 ref_and_mask_cp7; 388c2ecf20Sopenharmony_ci u32 ref_and_mask_cp8; 398c2ecf20Sopenharmony_ci u32 ref_and_mask_cp9; 408c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma0; 418c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma1; 428c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma2; 438c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma3; 448c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma4; 458c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma5; 468c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma6; 478c2ecf20Sopenharmony_ci u32 ref_and_mask_sdma7; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct amdgpu_nbio_funcs { 518c2ecf20Sopenharmony_ci const struct nbio_hdp_flush_reg *hdp_flush_reg; 528c2ecf20Sopenharmony_ci u32 (*get_hdp_flush_req_offset)(struct amdgpu_device *adev); 538c2ecf20Sopenharmony_ci u32 (*get_hdp_flush_done_offset)(struct amdgpu_device *adev); 548c2ecf20Sopenharmony_ci u32 (*get_pcie_index_offset)(struct amdgpu_device *adev); 558c2ecf20Sopenharmony_ci u32 (*get_pcie_data_offset)(struct amdgpu_device *adev); 568c2ecf20Sopenharmony_ci u32 (*get_rev_id)(struct amdgpu_device *adev); 578c2ecf20Sopenharmony_ci void (*mc_access_enable)(struct amdgpu_device *adev, bool enable); 588c2ecf20Sopenharmony_ci void (*hdp_flush)(struct amdgpu_device *adev, struct amdgpu_ring *ring); 598c2ecf20Sopenharmony_ci u32 (*get_memsize)(struct amdgpu_device *adev); 608c2ecf20Sopenharmony_ci void (*sdma_doorbell_range)(struct amdgpu_device *adev, int instance, 618c2ecf20Sopenharmony_ci bool use_doorbell, int doorbell_index, int doorbell_size); 628c2ecf20Sopenharmony_ci void (*vcn_doorbell_range)(struct amdgpu_device *adev, bool use_doorbell, 638c2ecf20Sopenharmony_ci int doorbell_index, int instance); 648c2ecf20Sopenharmony_ci void (*enable_doorbell_aperture)(struct amdgpu_device *adev, 658c2ecf20Sopenharmony_ci bool enable); 668c2ecf20Sopenharmony_ci void (*enable_doorbell_selfring_aperture)(struct amdgpu_device *adev, 678c2ecf20Sopenharmony_ci bool enable); 688c2ecf20Sopenharmony_ci void (*ih_doorbell_range)(struct amdgpu_device *adev, 698c2ecf20Sopenharmony_ci bool use_doorbell, int doorbell_index); 708c2ecf20Sopenharmony_ci void (*enable_doorbell_interrupt)(struct amdgpu_device *adev, 718c2ecf20Sopenharmony_ci bool enable); 728c2ecf20Sopenharmony_ci void (*update_medium_grain_clock_gating)(struct amdgpu_device *adev, 738c2ecf20Sopenharmony_ci bool enable); 748c2ecf20Sopenharmony_ci void (*update_medium_grain_light_sleep)(struct amdgpu_device *adev, 758c2ecf20Sopenharmony_ci bool enable); 768c2ecf20Sopenharmony_ci void (*get_clockgating_state)(struct amdgpu_device *adev, 778c2ecf20Sopenharmony_ci u32 *flags); 788c2ecf20Sopenharmony_ci void (*ih_control)(struct amdgpu_device *adev); 798c2ecf20Sopenharmony_ci void (*init_registers)(struct amdgpu_device *adev); 808c2ecf20Sopenharmony_ci void (*remap_hdp_registers)(struct amdgpu_device *adev); 818c2ecf20Sopenharmony_ci void (*handle_ras_controller_intr_no_bifring)(struct amdgpu_device *adev); 828c2ecf20Sopenharmony_ci void (*handle_ras_err_event_athub_intr_no_bifring)(struct amdgpu_device *adev); 838c2ecf20Sopenharmony_ci int (*init_ras_controller_interrupt)(struct amdgpu_device *adev); 848c2ecf20Sopenharmony_ci int (*init_ras_err_event_athub_interrupt)(struct amdgpu_device *adev); 858c2ecf20Sopenharmony_ci void (*query_ras_error_count)(struct amdgpu_device *adev, 868c2ecf20Sopenharmony_ci void *ras_error_status); 878c2ecf20Sopenharmony_ci int (*ras_late_init)(struct amdgpu_device *adev); 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistruct amdgpu_nbio { 918c2ecf20Sopenharmony_ci const struct nbio_hdp_flush_reg *hdp_flush_reg; 928c2ecf20Sopenharmony_ci struct amdgpu_irq_src ras_controller_irq; 938c2ecf20Sopenharmony_ci struct amdgpu_irq_src ras_err_event_athub_irq; 948c2ecf20Sopenharmony_ci struct ras_common_if *ras_if; 958c2ecf20Sopenharmony_ci const struct amdgpu_nbio_funcs *funcs; 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciint amdgpu_nbio_ras_late_init(struct amdgpu_device *adev); 998c2ecf20Sopenharmony_civoid amdgpu_nbio_ras_fini(struct amdgpu_device *adev); 1008c2ecf20Sopenharmony_ci#endif 101