This source file includes following definitions.
- rn_vbios_smu_send_msg_with_param
- rn_vbios_smu_get_smu_version
- rn_vbios_smu_set_dispclk
- rn_vbios_smu_set_dprefclk
- rn_vbios_smu_set_hard_min_dcfclk
- rn_vbios_smu_set_min_deep_sleep_dcfclk
- rn_vbios_smu_set_phyclk
- rn_vbios_smu_set_dppclk
- rn_vbios_smu_set_display_count
- rn_vbios_smu_enable_48mhz_tmdp_refclk_pwrdwn
- rn_vbios_smu_enable_pme_wa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include "core_types.h"
27 #include "clk_mgr_internal.h"
28 #include "reg_helper.h"
29
30 #include "renoir_ip_offset.h"
31
32 #include "mp/mp_12_0_0_offset.h"
33 #include "mp/mp_12_0_0_sh_mask.h"
34
35 #define REG(reg_name) \
36 (MP0_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
37
38 #define FN(reg_name, field) \
39 FD(reg_name##__##field)
40
41 #define VBIOSSMC_MSG_TestMessage 0x1
42 #define VBIOSSMC_MSG_GetSmuVersion 0x2
43 #define VBIOSSMC_MSG_PowerUpGfx 0x3
44 #define VBIOSSMC_MSG_SetDispclkFreq 0x4
45 #define VBIOSSMC_MSG_SetDprefclkFreq 0x5
46 #define VBIOSSMC_MSG_PowerDownGfx 0x6
47 #define VBIOSSMC_MSG_SetDppclkFreq 0x7
48 #define VBIOSSMC_MSG_SetHardMinDcfclkByFreq 0x8
49 #define VBIOSSMC_MSG_SetMinDeepSleepDcfclk 0x9
50 #define VBIOSSMC_MSG_SetPhyclkVoltageByFreq 0xA
51 #define VBIOSSMC_MSG_GetFclkFrequency 0xB
52 #define VBIOSSMC_MSG_SetDisplayCount 0xC
53 #define VBIOSSMC_MSG_EnableTmdp48MHzRefclkPwrDown 0xD
54 #define VBIOSSMC_MSG_UpdatePmeRestore 0xE
55
56 int rn_vbios_smu_send_msg_with_param(struct clk_mgr_internal *clk_mgr, unsigned int msg_id, unsigned int param)
57 {
58
59 REG_WRITE(MP1_SMN_C2PMSG_91, 0);
60
61
62 REG_WRITE(MP1_SMN_C2PMSG_83, param);
63
64
65 REG_WRITE(MP1_SMN_C2PMSG_67, msg_id);
66
67 REG_WAIT(MP1_SMN_C2PMSG_91, CONTENT, 1, 10, 200000);
68
69
70 return REG_READ(MP1_SMN_C2PMSG_83);
71 }
72
73 int rn_vbios_smu_get_smu_version(struct clk_mgr_internal *clk_mgr)
74 {
75 return rn_vbios_smu_send_msg_with_param(
76 clk_mgr,
77 VBIOSSMC_MSG_GetSmuVersion,
78 0);
79 }
80
81
82 int rn_vbios_smu_set_dispclk(struct clk_mgr_internal *clk_mgr, int requested_dispclk_khz)
83 {
84 int actual_dispclk_set_mhz = -1;
85 struct dc *core_dc = clk_mgr->base.ctx->dc;
86 struct dmcu *dmcu = core_dc->res_pool->dmcu;
87 uint32_t clk = requested_dispclk_khz / 1000;
88
89 if (clk <= 100)
90 clk = 101;
91
92
93 actual_dispclk_set_mhz = rn_vbios_smu_send_msg_with_param(
94 clk_mgr,
95 VBIOSSMC_MSG_SetDispclkFreq,
96 clk);
97
98 if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment)) {
99 if (dmcu && dmcu->funcs->is_dmcu_initialized(dmcu)) {
100 if (clk_mgr->dfs_bypass_disp_clk != actual_dispclk_set_mhz)
101 dmcu->funcs->set_psr_wait_loop(dmcu,
102 actual_dispclk_set_mhz / 7);
103 }
104 }
105
106 return actual_dispclk_set_mhz * 1000;
107 }
108
109 int rn_vbios_smu_set_dprefclk(struct clk_mgr_internal *clk_mgr)
110 {
111 int actual_dprefclk_set_mhz = -1;
112
113 actual_dprefclk_set_mhz = rn_vbios_smu_send_msg_with_param(
114 clk_mgr,
115 VBIOSSMC_MSG_SetDprefclkFreq,
116 clk_mgr->base.dprefclk_khz / 1000);
117
118
119
120 return actual_dprefclk_set_mhz * 1000;
121 }
122
123 int rn_vbios_smu_set_hard_min_dcfclk(struct clk_mgr_internal *clk_mgr, int requested_dcfclk_khz)
124 {
125 int actual_dcfclk_set_mhz = -1;
126
127 if (clk_mgr->smu_ver < 0xFFFFFFFF)
128 return actual_dcfclk_set_mhz;
129
130 actual_dcfclk_set_mhz = rn_vbios_smu_send_msg_with_param(
131 clk_mgr,
132 VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
133 requested_dcfclk_khz / 1000);
134
135 return actual_dcfclk_set_mhz * 1000;
136 }
137
138 int rn_vbios_smu_set_min_deep_sleep_dcfclk(struct clk_mgr_internal *clk_mgr, int requested_min_ds_dcfclk_khz)
139 {
140 int actual_min_ds_dcfclk_mhz = -1;
141
142 if (clk_mgr->smu_ver < 0xFFFFFFFF)
143 return actual_min_ds_dcfclk_mhz;
144
145 actual_min_ds_dcfclk_mhz = rn_vbios_smu_send_msg_with_param(
146 clk_mgr,
147 VBIOSSMC_MSG_SetMinDeepSleepDcfclk,
148 requested_min_ds_dcfclk_khz / 1000);
149
150 return actual_min_ds_dcfclk_mhz * 1000;
151 }
152
153 void rn_vbios_smu_set_phyclk(struct clk_mgr_internal *clk_mgr, int requested_phyclk_khz)
154 {
155 rn_vbios_smu_send_msg_with_param(
156 clk_mgr,
157 VBIOSSMC_MSG_SetPhyclkVoltageByFreq,
158 requested_phyclk_khz / 1000);
159 }
160
161 int rn_vbios_smu_set_dppclk(struct clk_mgr_internal *clk_mgr, int requested_dpp_khz)
162 {
163 int actual_dppclk_set_mhz = -1;
164
165 uint32_t clk = requested_dpp_khz / 1000;
166
167 if (clk <= 100)
168 clk = 101;
169
170 actual_dppclk_set_mhz = rn_vbios_smu_send_msg_with_param(
171 clk_mgr,
172 VBIOSSMC_MSG_SetDppclkFreq,
173 clk);
174
175 return actual_dppclk_set_mhz * 1000;
176 }
177
178 void rn_vbios_smu_set_display_count(struct clk_mgr_internal *clk_mgr, int display_count)
179 {
180 rn_vbios_smu_send_msg_with_param(
181 clk_mgr,
182 VBIOSSMC_MSG_SetDisplayCount,
183 display_count);
184 }
185
186 void rn_vbios_smu_enable_48mhz_tmdp_refclk_pwrdwn(struct clk_mgr_internal *clk_mgr)
187 {
188 rn_vbios_smu_send_msg_with_param(
189 clk_mgr,
190 VBIOSSMC_MSG_EnableTmdp48MHzRefclkPwrDown,
191 0);
192 }
193
194 void rn_vbios_smu_enable_pme_wa(struct clk_mgr_internal *clk_mgr)
195 {
196 rn_vbios_smu_send_msg_with_param(
197 clk_mgr,
198 VBIOSSMC_MSG_UpdatePmeRestore,
199 0);
200 }