This source file includes following definitions.
- trinity_notify_message_to_smu
- trinity_dpm_bapm_enable
- trinity_dpm_config
- trinity_dpm_force_state
- trinity_dpm_n_levels_disabled
- trinity_uvd_dpm_config
- trinity_dpm_no_forced_level
- trinity_dce_enable_voltage_adjustment
- trinity_gfx_dynamic_mgpg_config
- trinity_acquire_mutex
- trinity_release_mutex
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 "radeon.h"
25 #include "trinityd.h"
26 #include "trinity_dpm.h"
27 #include "ppsmc.h"
28
29 static int trinity_notify_message_to_smu(struct radeon_device *rdev, u32 id)
30 {
31 int i;
32 u32 v = 0;
33
34 WREG32(SMC_MESSAGE_0, id);
35 for (i = 0; i < rdev->usec_timeout; i++) {
36 if (RREG32(SMC_RESP_0) != 0)
37 break;
38 udelay(1);
39 }
40 v = RREG32(SMC_RESP_0);
41
42 if (v != 1) {
43 if (v == 0xFF) {
44 DRM_ERROR("SMC failed to handle the message!\n");
45 return -EINVAL;
46 } else if (v == 0xFE) {
47 DRM_ERROR("Unknown SMC message!\n");
48 return -EINVAL;
49 }
50 }
51
52 return 0;
53 }
54
55 int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable)
56 {
57 if (enable)
58 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM);
59 else
60 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM);
61 }
62
63 int trinity_dpm_config(struct radeon_device *rdev, bool enable)
64 {
65 if (enable)
66 WREG32_SMC(SMU_SCRATCH0, 1);
67 else
68 WREG32_SMC(SMU_SCRATCH0, 0);
69
70 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DPM_Config);
71 }
72
73 int trinity_dpm_force_state(struct radeon_device *rdev, u32 n)
74 {
75 WREG32_SMC(SMU_SCRATCH0, n);
76
77 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DPM_ForceState);
78 }
79
80 int trinity_dpm_n_levels_disabled(struct radeon_device *rdev, u32 n)
81 {
82 WREG32_SMC(SMU_SCRATCH0, n);
83
84 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DPM_N_LevelsDisabled);
85 }
86
87 int trinity_uvd_dpm_config(struct radeon_device *rdev)
88 {
89 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_UVD_DPM_Config);
90 }
91
92 int trinity_dpm_no_forced_level(struct radeon_device *rdev)
93 {
94 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_NoForcedLevel);
95 }
96
97 int trinity_dce_enable_voltage_adjustment(struct radeon_device *rdev,
98 bool enable)
99 {
100 if (enable)
101 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DCE_AllowVoltageAdjustment);
102 else
103 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DCE_RemoveVoltageAdjustment);
104 }
105
106 int trinity_gfx_dynamic_mgpg_config(struct radeon_device *rdev)
107 {
108 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_PG_SIMD_Config);
109 }
110
111 void trinity_acquire_mutex(struct radeon_device *rdev)
112 {
113 int i;
114
115 WREG32(SMC_INT_REQ, 1);
116 for (i = 0; i < rdev->usec_timeout; i++) {
117 if ((RREG32(SMC_INT_REQ) & 0xffff) == 1)
118 break;
119 udelay(1);
120 }
121 }
122
123 void trinity_release_mutex(struct radeon_device *rdev)
124 {
125 WREG32(SMC_INT_REQ, 0);
126 }