forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c
....@@ -27,25 +27,23 @@
2727 #include "nbio/nbio_7_0_default.h"
2828 #include "nbio/nbio_7_0_offset.h"
2929 #include "nbio/nbio_7_0_sh_mask.h"
30
+#include "nbio/nbio_7_0_smn.h"
3031 #include "vega10_enum.h"
32
+#include <uapi/linux/kfd_ioctl.h>
3133
3234 #define smnNBIF_MGCG_CTRL_LCLK 0x1013a05c
3335
34
-#define smnCPM_CONTROL 0x11180460
35
-#define smnPCIE_CNTL2 0x11180070
36
-
37
-/* vega20 */
38
-#define mmRCC_DEV0_EPF0_STRAP0_VG20 0x0011
39
-#define mmRCC_DEV0_EPF0_STRAP0_VG20_BASE_IDX 2
36
+static void nbio_v7_0_remap_hdp_registers(struct amdgpu_device *adev)
37
+{
38
+ WREG32_SOC15(NBIO, 0, mmREMAP_HDP_MEM_FLUSH_CNTL,
39
+ adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL);
40
+ WREG32_SOC15(NBIO, 0, mmREMAP_HDP_REG_FLUSH_CNTL,
41
+ adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL);
42
+}
4043
4144 static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev)
4245 {
4346 u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
44
-
45
- if (adev->asic_type == CHIP_VEGA20)
46
- tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0_VG20);
47
- else
48
- tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
4947
5048 tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
5149 tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
....@@ -66,10 +64,9 @@
6664 struct amdgpu_ring *ring)
6765 {
6866 if (!ring || !ring->funcs->emit_wreg)
69
- WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0);
67
+ WREG32_NO_KIQ((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
7068 else
71
- amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
72
- NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL), 0);
69
+ amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
7370 }
7471
7572 static u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev)
....@@ -78,22 +75,38 @@
7875 }
7976
8077 static void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance,
81
- bool use_doorbell, int doorbell_index)
78
+ bool use_doorbell, int doorbell_index, int doorbell_size)
8279 {
8380 u32 reg = instance == 0 ? SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE) :
8481 SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE);
8582
8683 u32 doorbell_range = RREG32(reg);
87
- u32 range = 2;
88
-
89
- if (adev->asic_type == CHIP_VEGA20)
90
- range = 8;
9184
9285 if (use_doorbell) {
9386 doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index);
94
- doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, range);
87
+ doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, doorbell_size);
9588 } else
9689 doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0);
90
+
91
+ WREG32(reg, doorbell_range);
92
+}
93
+
94
+static void nbio_v7_0_vcn_doorbell_range(struct amdgpu_device *adev, bool use_doorbell,
95
+ int doorbell_index, int instance)
96
+{
97
+ u32 reg = SOC15_REG_OFFSET(NBIO, 0, mmBIF_MMSCH0_DOORBELL_RANGE);
98
+
99
+ u32 doorbell_range = RREG32(reg);
100
+
101
+ if (use_doorbell) {
102
+ doorbell_range = REG_SET_FIELD(doorbell_range,
103
+ BIF_MMSCH0_DOORBELL_RANGE, OFFSET,
104
+ doorbell_index);
105
+ doorbell_range = REG_SET_FIELD(doorbell_range,
106
+ BIF_MMSCH0_DOORBELL_RANGE, SIZE, 8);
107
+ } else
108
+ doorbell_range = REG_SET_FIELD(doorbell_range,
109
+ BIF_MMSCH0_DOORBELL_RANGE, SIZE, 0);
97110
98111 WREG32(reg, doorbell_range);
99112 }
....@@ -145,9 +158,6 @@
145158 bool enable)
146159 {
147160 uint32_t def, data;
148
-
149
- if (adev->asic_type == CHIP_VEGA20)
150
- return;
151161
152162 /* NBIF_MGCG_CTRL_LCLK */
153163 def = data = RREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK);
....@@ -270,19 +280,12 @@
270280 .ref_and_mask_sdma1 = GPU_HDP_FLUSH_DONE__SDMA1_MASK,
271281 };
272282
273
-static void nbio_v7_0_detect_hw_virt(struct amdgpu_device *adev)
274
-{
275
- if (is_virtual_machine()) /* passthrough mode exclus sriov mod */
276
- adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
277
-}
278
-
279283 static void nbio_v7_0_init_registers(struct amdgpu_device *adev)
280284 {
281285
282286 }
283287
284288 const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {
285
- .hdp_flush_reg = &nbio_v7_0_hdp_flush_reg,
286289 .get_hdp_flush_req_offset = nbio_v7_0_get_hdp_flush_req_offset,
287290 .get_hdp_flush_done_offset = nbio_v7_0_get_hdp_flush_done_offset,
288291 .get_pcie_index_offset = nbio_v7_0_get_pcie_index_offset,
....@@ -292,6 +295,7 @@
292295 .hdp_flush = nbio_v7_0_hdp_flush,
293296 .get_memsize = nbio_v7_0_get_memsize,
294297 .sdma_doorbell_range = nbio_v7_0_sdma_doorbell_range,
298
+ .vcn_doorbell_range = nbio_v7_0_vcn_doorbell_range,
295299 .enable_doorbell_aperture = nbio_v7_0_enable_doorbell_aperture,
296300 .enable_doorbell_selfring_aperture = nbio_v7_0_enable_doorbell_selfring_aperture,
297301 .ih_doorbell_range = nbio_v7_0_ih_doorbell_range,
....@@ -300,5 +304,5 @@
300304 .get_clockgating_state = nbio_v7_0_get_clockgating_state,
301305 .ih_control = nbio_v7_0_ih_control,
302306 .init_registers = nbio_v7_0_init_registers,
303
- .detect_hw_virt = nbio_v7_0_detect_hw_virt,
307
+ .remap_hdp_registers = nbio_v7_0_remap_hdp_registers,
304308 };