1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "amdgpu.h"
25#include "athub_v2_1.h"
26
27#include "athub/athub_2_1_0_offset.h"
28#include "athub/athub_2_1_0_sh_mask.h"
29
30#include "soc15_common.h"
31
32static void
33athub_v2_1_update_medium_grain_clock_gating(struct amdgpu_device *adev,
34 bool enable)
35{
36 uint32_t def, data;
37
38 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
39
40 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG))
41 data |= ATHUB_MISC_CNTL__CG_ENABLE_MASK;
42 else
43 data &= ~ATHUB_MISC_CNTL__CG_ENABLE_MASK;
44
45 if (def != data)
46 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
47}
48
49static void
50athub_v2_1_update_medium_grain_light_sleep(struct amdgpu_device *adev,
51 bool enable)
52{
53 uint32_t def, data;
54
55 def = data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
56
57 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS) &&
58 (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
59 data |= ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
60 else
61 data &= ~ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK;
62
63 if(def != data)
64 WREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL, data);
65}
66
67int athub_v2_1_set_clockgating(struct amdgpu_device *adev,
68 enum amd_clockgating_state state)
69{
70 if (amdgpu_sriov_vf(adev))
71 return 0;
72
73 switch (adev->ip_versions[ATHUB_HWIP][0]) {
74 case IP_VERSION(2, 1, 0):
75 case IP_VERSION(2, 1, 1):
76 case IP_VERSION(2, 1, 2):
77 athub_v2_1_update_medium_grain_clock_gating(adev, state == AMD_CG_STATE_GATE);
78 athub_v2_1_update_medium_grain_light_sleep(adev, state == AMD_CG_STATE_GATE);
79 break;
80 default:
81 break;
82 }
83
84 return 0;
85}
86
87void athub_v2_1_get_clockgating(struct amdgpu_device *adev, u32 *flags)
88{
89 int data;
90
91
92 data = RREG32_SOC15(ATHUB, 0, mmATHUB_MISC_CNTL);
93 if (data & ATHUB_MISC_CNTL__CG_ENABLE_MASK)
94 *flags |= AMD_CG_SUPPORT_ATHUB_MGCG;
95
96
97 if (data & ATHUB_MISC_CNTL__CG_MEM_LS_ENABLE_MASK)
98 *flags |= AMD_CG_SUPPORT_ATHUB_LS;
99}
100