1 1.1 riastrad /* $NetBSD: amdgpu_nbio.h,v 1.2 2021/12/18 23:44:58 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2019 Advanced Micro Devices, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad * 24 1.1 riastrad */ 25 1.1 riastrad #ifndef __AMDGPU_NBIO_H__ 26 1.1 riastrad #define __AMDGPU_NBIO_H__ 27 1.1 riastrad 28 1.1 riastrad /* 29 1.1 riastrad * amdgpu nbio functions 30 1.1 riastrad */ 31 1.1 riastrad struct nbio_hdp_flush_reg { 32 1.1 riastrad u32 ref_and_mask_cp0; 33 1.1 riastrad u32 ref_and_mask_cp1; 34 1.1 riastrad u32 ref_and_mask_cp2; 35 1.1 riastrad u32 ref_and_mask_cp3; 36 1.1 riastrad u32 ref_and_mask_cp4; 37 1.1 riastrad u32 ref_and_mask_cp5; 38 1.1 riastrad u32 ref_and_mask_cp6; 39 1.1 riastrad u32 ref_and_mask_cp7; 40 1.1 riastrad u32 ref_and_mask_cp8; 41 1.1 riastrad u32 ref_and_mask_cp9; 42 1.1 riastrad u32 ref_and_mask_sdma0; 43 1.1 riastrad u32 ref_and_mask_sdma1; 44 1.1 riastrad u32 ref_and_mask_sdma2; 45 1.1 riastrad u32 ref_and_mask_sdma3; 46 1.1 riastrad u32 ref_and_mask_sdma4; 47 1.1 riastrad u32 ref_and_mask_sdma5; 48 1.1 riastrad u32 ref_and_mask_sdma6; 49 1.1 riastrad u32 ref_and_mask_sdma7; 50 1.1 riastrad }; 51 1.1 riastrad 52 1.1 riastrad struct amdgpu_nbio_funcs { 53 1.1 riastrad const struct nbio_hdp_flush_reg *hdp_flush_reg; 54 1.1 riastrad u32 (*get_hdp_flush_req_offset)(struct amdgpu_device *adev); 55 1.1 riastrad u32 (*get_hdp_flush_done_offset)(struct amdgpu_device *adev); 56 1.1 riastrad u32 (*get_pcie_index_offset)(struct amdgpu_device *adev); 57 1.1 riastrad u32 (*get_pcie_data_offset)(struct amdgpu_device *adev); 58 1.1 riastrad u32 (*get_rev_id)(struct amdgpu_device *adev); 59 1.1 riastrad void (*mc_access_enable)(struct amdgpu_device *adev, bool enable); 60 1.1 riastrad void (*hdp_flush)(struct amdgpu_device *adev, struct amdgpu_ring *ring); 61 1.1 riastrad u32 (*get_memsize)(struct amdgpu_device *adev); 62 1.1 riastrad void (*sdma_doorbell_range)(struct amdgpu_device *adev, int instance, 63 1.1 riastrad bool use_doorbell, int doorbell_index, int doorbell_size); 64 1.1 riastrad void (*vcn_doorbell_range)(struct amdgpu_device *adev, bool use_doorbell, 65 1.1 riastrad int doorbell_index, int instance); 66 1.1 riastrad void (*enable_doorbell_aperture)(struct amdgpu_device *adev, 67 1.1 riastrad bool enable); 68 1.1 riastrad void (*enable_doorbell_selfring_aperture)(struct amdgpu_device *adev, 69 1.1 riastrad bool enable); 70 1.1 riastrad void (*ih_doorbell_range)(struct amdgpu_device *adev, 71 1.1 riastrad bool use_doorbell, int doorbell_index); 72 1.1 riastrad void (*enable_doorbell_interrupt)(struct amdgpu_device *adev, 73 1.1 riastrad bool enable); 74 1.1 riastrad void (*update_medium_grain_clock_gating)(struct amdgpu_device *adev, 75 1.1 riastrad bool enable); 76 1.1 riastrad void (*update_medium_grain_light_sleep)(struct amdgpu_device *adev, 77 1.1 riastrad bool enable); 78 1.1 riastrad void (*get_clockgating_state)(struct amdgpu_device *adev, 79 1.1 riastrad u32 *flags); 80 1.1 riastrad void (*ih_control)(struct amdgpu_device *adev); 81 1.1 riastrad void (*init_registers)(struct amdgpu_device *adev); 82 1.1 riastrad void (*detect_hw_virt)(struct amdgpu_device *adev); 83 1.1 riastrad void (*remap_hdp_registers)(struct amdgpu_device *adev); 84 1.1 riastrad void (*handle_ras_controller_intr_no_bifring)(struct amdgpu_device *adev); 85 1.1 riastrad void (*handle_ras_err_event_athub_intr_no_bifring)(struct amdgpu_device *adev); 86 1.1 riastrad int (*init_ras_controller_interrupt)(struct amdgpu_device *adev); 87 1.1 riastrad int (*init_ras_err_event_athub_interrupt)(struct amdgpu_device *adev); 88 1.1 riastrad void (*query_ras_error_count)(struct amdgpu_device *adev, 89 1.1 riastrad void *ras_error_status); 90 1.1 riastrad int (*ras_late_init)(struct amdgpu_device *adev); 91 1.1 riastrad }; 92 1.1 riastrad 93 1.1 riastrad struct amdgpu_nbio { 94 1.1 riastrad const struct nbio_hdp_flush_reg *hdp_flush_reg; 95 1.1 riastrad struct amdgpu_irq_src ras_controller_irq; 96 1.1 riastrad struct amdgpu_irq_src ras_err_event_athub_irq; 97 1.1 riastrad struct ras_common_if *ras_if; 98 1.1 riastrad const struct amdgpu_nbio_funcs *funcs; 99 1.1 riastrad }; 100 1.1 riastrad 101 1.1 riastrad int amdgpu_nbio_ras_late_init(struct amdgpu_device *adev); 102 1.1 riastrad void amdgpu_nbio_ras_fini(struct amdgpu_device *adev); 103 1.1 riastrad #endif 104