18e3153baSKen Wang /* 28e3153baSKen Wang * Copyright 2016 Advanced Micro Devices, Inc. 38e3153baSKen Wang * 48e3153baSKen Wang * Permission is hereby granted, free of charge, to any person obtaining a 58e3153baSKen Wang * copy of this software and associated documentation files (the "Software"), 68e3153baSKen Wang * to deal in the Software without restriction, including without limitation 78e3153baSKen Wang * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88e3153baSKen Wang * and/or sell copies of the Software, and to permit persons to whom the 98e3153baSKen Wang * Software is furnished to do so, subject to the following conditions: 108e3153baSKen Wang * 118e3153baSKen Wang * The above copyright notice and this permission notice shall be included in 128e3153baSKen Wang * all copies or substantial portions of the Software. 138e3153baSKen Wang * 148e3153baSKen Wang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158e3153baSKen Wang * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168e3153baSKen Wang * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178e3153baSKen Wang * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188e3153baSKen Wang * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198e3153baSKen Wang * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208e3153baSKen Wang * OTHER DEALINGS IN THE SOFTWARE. 218e3153baSKen Wang * 228e3153baSKen Wang */ 238e3153baSKen Wang 248e3153baSKen Wang #ifndef __SOC15_H__ 258e3153baSKen Wang #define __SOC15_H__ 268e3153baSKen Wang 278e3153baSKen Wang #include "nbio_v6_1.h" 28aecbe64fSChunming Zhou #include "nbio_v7_0.h" 29fe3c9489SFeifei Xu #include "nbio_v7_4.h" 308e3153baSKen Wang 31994470b2SAlex Deucher extern const struct amdgpu_ip_block_version vega10_common_ip_block; 32994470b2SAlex Deucher 334ed8a037Schangzhu #define SOC15_FLUSH_GPU_TLB_NUM_WREG 6 344ed8a037Schangzhu #define SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT 3 359096d6e5SChristian König 36946a4d5bSShaoyun Liu struct soc15_reg_golden { 37946a4d5bSShaoyun Liu u32 hwip; 38946a4d5bSShaoyun Liu u32 instance; 39946a4d5bSShaoyun Liu u32 segment; 40946a4d5bSShaoyun Liu u32 reg; 41946a4d5bSShaoyun Liu u32 and_mask; 42946a4d5bSShaoyun Liu u32 or_mask; 43946a4d5bSShaoyun Liu }; 44946a4d5bSShaoyun Liu 452e0cc4d4SMonk Liu struct soc15_reg_rlcg { 462e0cc4d4SMonk Liu u32 hwip; 472e0cc4d4SMonk Liu u32 instance; 482e0cc4d4SMonk Liu u32 segment; 492e0cc4d4SMonk Liu u32 reg; 502e0cc4d4SMonk Liu }; 512e0cc4d4SMonk Liu 5222616eb5SDennis Li struct soc15_reg { 5322616eb5SDennis Li uint32_t hwip; 5422616eb5SDennis Li uint32_t inst; 5522616eb5SDennis Li uint32_t seg; 5622616eb5SDennis Li uint32_t reg_offset; 5722616eb5SDennis Li }; 5822616eb5SDennis Li 595326ad54SJames Zhu struct soc15_reg_entry { 605326ad54SJames Zhu uint32_t hwip; 615326ad54SJames Zhu uint32_t inst; 625326ad54SJames Zhu uint32_t seg; 635326ad54SJames Zhu uint32_t reg_offset; 645326ad54SJames Zhu uint32_t reg_value; 65052af915SJames Zhu uint32_t se_num; 66052af915SJames Zhu uint32_t instance; 675326ad54SJames Zhu }; 685326ad54SJames Zhu 6944f1bb1fSHawking Zhang struct soc15_allowed_register_entry { 7044f1bb1fSHawking Zhang uint32_t hwip; 7144f1bb1fSHawking Zhang uint32_t inst; 7244f1bb1fSHawking Zhang uint32_t seg; 7344f1bb1fSHawking Zhang uint32_t reg_offset; 7444f1bb1fSHawking Zhang bool grbm_indexed; 7544f1bb1fSHawking Zhang }; 7644f1bb1fSHawking Zhang 7746f71969SDennis Li struct soc15_ras_field_entry { 7846f71969SDennis Li const char *name; 7946f71969SDennis Li uint32_t hwip; 8046f71969SDennis Li uint32_t inst; 8146f71969SDennis Li uint32_t seg; 8246f71969SDennis Li uint32_t reg_offset; 8346f71969SDennis Li uint32_t sec_count_mask; 8446f71969SDennis Li uint32_t sec_count_shift; 8546f71969SDennis Li uint32_t ded_count_mask; 8646f71969SDennis Li uint32_t ded_count_shift; 8746f71969SDennis Li }; 8846f71969SDennis Li 89946a4d5bSShaoyun Liu #define SOC15_REG_ENTRY(ip, inst, reg) ip##_HWIP, inst, reg##_BASE_IDX, reg 90946a4d5bSShaoyun Liu 915326ad54SJames Zhu #define SOC15_REG_ENTRY_OFFSET(entry) (adev->reg_offset[entry.hwip][entry.inst][entry.seg] + entry.reg_offset) 925326ad54SJames Zhu 93946a4d5bSShaoyun Liu #define SOC15_REG_GOLDEN_VALUE(ip, inst, reg, and_mask, or_mask) \ 94946a4d5bSShaoyun Liu { ip##_HWIP, inst, reg##_BASE_IDX, reg, and_mask, or_mask } 95946a4d5bSShaoyun Liu 9613ba0344SDennis Li #define SOC15_REG_FIELD(reg, field) reg##__##field##_MASK, reg##__##field##__SHIFT 9713ba0344SDennis Li 9822616eb5SDennis Li #define SOC15_REG_FIELD_VAL(val, mask, shift) (((val) & mask) >> shift) 9922616eb5SDennis Li 1004abc2567SDennis Li #define SOC15_RAS_REG_FIELD_VAL(val, entry, field) SOC15_REG_FIELD_VAL((val), (entry).field##_count_mask, (entry).field##_count_shift) 10122616eb5SDennis Li 1028e3153baSKen Wang void soc15_grbm_select(struct amdgpu_device *adev, 1035aa998baSLe Ma u32 me, u32 pipe, u32 queue, u32 vmid, int xcc_id); 104c1299461SWenhui Sheng void soc15_set_virt_ops(struct amdgpu_device *adev); 1058e3153baSKen Wang 106946a4d5bSShaoyun Liu void soc15_program_register_sequence(struct amdgpu_device *adev, 107946a4d5bSShaoyun Liu const struct soc15_reg_golden *registers, 108946a4d5bSShaoyun Liu const u32 array_size); 109946a4d5bSShaoyun Liu 1104522824cSShaoyun Liu int vega10_reg_base_init(struct amdgpu_device *adev); 1118ee273e5SFeifei Xu int vega20_reg_base_init(struct amdgpu_device *adev); 112e78705ecSLe Ma int arct_reg_base_init(struct amdgpu_device *adev); 11342b72608SLe Ma int aldebaran_reg_base_init(struct amdgpu_device *adev); 114cab7d478SLijo Lazar void aqua_vanjaram_ip_map_init(struct amdgpu_device *adev); 1152fa480d3SLe Ma u64 aqua_vanjaram_encode_ext_smn_addressing(int ext_id); 116*e56c9ef6SLijo Lazar int aqua_vanjaram_init_soc_config(struct amdgpu_device *adev); 1174522824cSShaoyun Liu 118062f3807SOak Zeng void vega10_doorbell_index_init(struct amdgpu_device *adev); 119c93aa775SOak Zeng void vega20_doorbell_index_init(struct amdgpu_device *adev); 1201dfcdc30SLe Ma void aqua_vanjaram_doorbell_index_init(struct amdgpu_device *adev); 1218e3153baSKen Wang #endif 122