Merge remote-tracking branch 'torvalds/master' into perf/core
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / pm / powerplay / hwmgr / smu10_hwmgr.c
1 /*
2  * Copyright 2015 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 #include "pp_debug.h"
24 #include <linux/types.h>
25 #include <linux/kernel.h>
26 #include <linux/slab.h>
27 #include "atom-types.h"
28 #include "atombios.h"
29 #include "processpptables.h"
30 #include "cgs_common.h"
31 #include "smumgr.h"
32 #include "hwmgr.h"
33 #include "hardwaremanager.h"
34 #include "rv_ppsmc.h"
35 #include "smu10_hwmgr.h"
36 #include "power_state.h"
37 #include "soc15_common.h"
38 #include "smu10.h"
39 #include "asic_reg/pwr/pwr_10_0_offset.h"
40 #include "asic_reg/pwr/pwr_10_0_sh_mask.h"
41
42 #define SMU10_MAX_DEEPSLEEP_DIVIDER_ID     5
43 #define SMU10_MINIMUM_ENGINE_CLOCK         800   /* 8Mhz, the low boundary of engine clock allowed on this chip */
44 #define SCLK_MIN_DIV_INTV_SHIFT         12
45 #define SMU10_DISPCLK_BYPASS_THRESHOLD     10000 /* 100Mhz */
46 #define SMC_RAM_END                     0x40000
47
48 static const unsigned long SMU10_Magic = (unsigned long) PHM_Rv_Magic;
49
50
51 static int smu10_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
52                 struct pp_display_clock_request *clock_req)
53 {
54         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
55         enum amd_pp_clock_type clk_type = clock_req->clock_type;
56         uint32_t clk_freq = clock_req->clock_freq_in_khz / 1000;
57         PPSMC_Msg        msg;
58
59         switch (clk_type) {
60         case amd_pp_dcf_clock:
61                 if (clk_freq == smu10_data->dcf_actual_hard_min_freq)
62                         return 0;
63                 msg =  PPSMC_MSG_SetHardMinDcefclkByFreq;
64                 smu10_data->dcf_actual_hard_min_freq = clk_freq;
65                 break;
66         case amd_pp_soc_clock:
67                  msg = PPSMC_MSG_SetHardMinSocclkByFreq;
68                 break;
69         case amd_pp_f_clock:
70                 if (clk_freq == smu10_data->f_actual_hard_min_freq)
71                         return 0;
72                 smu10_data->f_actual_hard_min_freq = clk_freq;
73                 msg = PPSMC_MSG_SetHardMinFclkByFreq;
74                 break;
75         default:
76                 pr_info("[DisplayClockVoltageRequest]Invalid Clock Type!");
77                 return -EINVAL;
78         }
79         smum_send_msg_to_smc_with_parameter(hwmgr, msg, clk_freq, NULL);
80
81         return 0;
82 }
83
84 static struct smu10_power_state *cast_smu10_ps(struct pp_hw_power_state *hw_ps)
85 {
86         if (SMU10_Magic != hw_ps->magic)
87                 return NULL;
88
89         return (struct smu10_power_state *)hw_ps;
90 }
91
92 static const struct smu10_power_state *cast_const_smu10_ps(
93                                 const struct pp_hw_power_state *hw_ps)
94 {
95         if (SMU10_Magic != hw_ps->magic)
96                 return NULL;
97
98         return (struct smu10_power_state *)hw_ps;
99 }
100
101 static int smu10_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
102 {
103         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
104
105         smu10_data->dce_slow_sclk_threshold = 30000;
106         smu10_data->thermal_auto_throttling_treshold = 0;
107         smu10_data->is_nb_dpm_enabled = 1;
108         smu10_data->dpm_flags = 1;
109         smu10_data->need_min_deep_sleep_dcefclk = true;
110         smu10_data->num_active_display = 0;
111         smu10_data->deep_sleep_dcefclk = 0;
112
113         phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
114                                         PHM_PlatformCaps_SclkDeepSleep);
115
116         phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
117                                 PHM_PlatformCaps_SclkThrottleLowNotification);
118
119         phm_cap_set(hwmgr->platform_descriptor.platformCaps,
120                                 PHM_PlatformCaps_PowerPlaySupport);
121         return 0;
122 }
123
124 static int smu10_construct_max_power_limits_table(struct pp_hwmgr *hwmgr,
125                         struct phm_clock_and_voltage_limits *table)
126 {
127         return 0;
128 }
129
130 static int smu10_init_dynamic_state_adjustment_rule_settings(
131                                                         struct pp_hwmgr *hwmgr)
132 {
133         int count = 8;
134         struct phm_clock_voltage_dependency_table *table_clk_vlt;
135
136         table_clk_vlt = kzalloc(struct_size(table_clk_vlt, entries, count),
137                                 GFP_KERNEL);
138
139         if (NULL == table_clk_vlt) {
140                 pr_err("Can not allocate memory!\n");
141                 return -ENOMEM;
142         }
143
144         table_clk_vlt->count = count;
145         table_clk_vlt->entries[0].clk = PP_DAL_POWERLEVEL_0;
146         table_clk_vlt->entries[0].v = 0;
147         table_clk_vlt->entries[1].clk = PP_DAL_POWERLEVEL_1;
148         table_clk_vlt->entries[1].v = 1;
149         table_clk_vlt->entries[2].clk = PP_DAL_POWERLEVEL_2;
150         table_clk_vlt->entries[2].v = 2;
151         table_clk_vlt->entries[3].clk = PP_DAL_POWERLEVEL_3;
152         table_clk_vlt->entries[3].v = 3;
153         table_clk_vlt->entries[4].clk = PP_DAL_POWERLEVEL_4;
154         table_clk_vlt->entries[4].v = 4;
155         table_clk_vlt->entries[5].clk = PP_DAL_POWERLEVEL_5;
156         table_clk_vlt->entries[5].v = 5;
157         table_clk_vlt->entries[6].clk = PP_DAL_POWERLEVEL_6;
158         table_clk_vlt->entries[6].v = 6;
159         table_clk_vlt->entries[7].clk = PP_DAL_POWERLEVEL_7;
160         table_clk_vlt->entries[7].v = 7;
161         hwmgr->dyn_state.vddc_dep_on_dal_pwrl = table_clk_vlt;
162
163         return 0;
164 }
165
166 static int smu10_get_system_info_data(struct pp_hwmgr *hwmgr)
167 {
168         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)hwmgr->backend;
169
170         smu10_data->sys_info.htc_hyst_lmt = 5;
171         smu10_data->sys_info.htc_tmp_lmt = 203;
172
173         if (smu10_data->thermal_auto_throttling_treshold == 0)
174                  smu10_data->thermal_auto_throttling_treshold = 203;
175
176         smu10_construct_max_power_limits_table (hwmgr,
177                                     &hwmgr->dyn_state.max_clock_voltage_on_ac);
178
179         smu10_init_dynamic_state_adjustment_rule_settings(hwmgr);
180
181         return 0;
182 }
183
184 static int smu10_construct_boot_state(struct pp_hwmgr *hwmgr)
185 {
186         return 0;
187 }
188
189 static int smu10_set_clock_limit(struct pp_hwmgr *hwmgr, const void *input)
190 {
191         struct PP_Clocks clocks = {0};
192         struct pp_display_clock_request clock_req;
193
194         clocks.dcefClock = hwmgr->display_config->min_dcef_set_clk;
195         clock_req.clock_type = amd_pp_dcf_clock;
196         clock_req.clock_freq_in_khz = clocks.dcefClock * 10;
197
198         PP_ASSERT_WITH_CODE(!smu10_display_clock_voltage_request(hwmgr, &clock_req),
199                                 "Attempt to set DCF Clock Failed!", return -EINVAL);
200
201         return 0;
202 }
203
204 static int smu10_set_min_deep_sleep_dcefclk(struct pp_hwmgr *hwmgr, uint32_t clock)
205 {
206         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
207
208         if (clock && smu10_data->deep_sleep_dcefclk != clock) {
209                 smu10_data->deep_sleep_dcefclk = clock;
210                 smum_send_msg_to_smc_with_parameter(hwmgr,
211                                         PPSMC_MSG_SetMinDeepSleepDcefclk,
212                                         smu10_data->deep_sleep_dcefclk,
213                                         NULL);
214         }
215         return 0;
216 }
217
218 static int smu10_set_hard_min_dcefclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t clock)
219 {
220         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
221
222         if (clock && smu10_data->dcf_actual_hard_min_freq != clock) {
223                 smu10_data->dcf_actual_hard_min_freq = clock;
224                 smum_send_msg_to_smc_with_parameter(hwmgr,
225                                         PPSMC_MSG_SetHardMinDcefclkByFreq,
226                                         smu10_data->dcf_actual_hard_min_freq,
227                                         NULL);
228         }
229         return 0;
230 }
231
232 static int smu10_set_hard_min_fclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t clock)
233 {
234         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
235
236         if (clock && smu10_data->f_actual_hard_min_freq != clock) {
237                 smu10_data->f_actual_hard_min_freq = clock;
238                 smum_send_msg_to_smc_with_parameter(hwmgr,
239                                         PPSMC_MSG_SetHardMinFclkByFreq,
240                                         smu10_data->f_actual_hard_min_freq,
241                                         NULL);
242         }
243         return 0;
244 }
245
246 static int smu10_set_hard_min_gfxclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t clock)
247 {
248         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
249
250         if (clock && smu10_data->gfx_actual_soft_min_freq != clock) {
251                 smu10_data->gfx_actual_soft_min_freq = clock;
252                 smum_send_msg_to_smc_with_parameter(hwmgr,
253                                         PPSMC_MSG_SetHardMinGfxClk,
254                                         clock,
255                                         NULL);
256         }
257         return 0;
258 }
259
260 static int smu10_set_soft_max_gfxclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t clock)
261 {
262         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
263
264         if (clock && smu10_data->gfx_max_freq_limit != (clock * 100))  {
265                 smu10_data->gfx_max_freq_limit = clock * 100;
266                 smum_send_msg_to_smc_with_parameter(hwmgr,
267                                         PPSMC_MSG_SetSoftMaxGfxClk,
268                                         clock,
269                                         NULL);
270         }
271         return 0;
272 }
273
274 static int smu10_set_active_display_count(struct pp_hwmgr *hwmgr, uint32_t count)
275 {
276         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
277
278         if (smu10_data->num_active_display != count) {
279                 smu10_data->num_active_display = count;
280                 smum_send_msg_to_smc_with_parameter(hwmgr,
281                                 PPSMC_MSG_SetDisplayCount,
282                                 smu10_data->num_active_display,
283                                 NULL);
284         }
285
286         return 0;
287 }
288
289 static int smu10_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
290 {
291         return smu10_set_clock_limit(hwmgr, input);
292 }
293
294 static int smu10_init_power_gate_state(struct pp_hwmgr *hwmgr)
295 {
296         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
297         struct amdgpu_device *adev = hwmgr->adev;
298
299         smu10_data->vcn_power_gated = true;
300         smu10_data->isp_tileA_power_gated = true;
301         smu10_data->isp_tileB_power_gated = true;
302
303         if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)
304                 return smum_send_msg_to_smc_with_parameter(hwmgr,
305                                                            PPSMC_MSG_SetGfxCGPG,
306                                                            true,
307                                                            NULL);
308         else
309                 return 0;
310 }
311
312
313 static int smu10_setup_asic_task(struct pp_hwmgr *hwmgr)
314 {
315         return smu10_init_power_gate_state(hwmgr);
316 }
317
318 static int smu10_reset_cc6_data(struct pp_hwmgr *hwmgr)
319 {
320         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
321
322         smu10_data->separation_time = 0;
323         smu10_data->cc6_disable = false;
324         smu10_data->pstate_disable = false;
325         smu10_data->cc6_setting_changed = false;
326
327         return 0;
328 }
329
330 static int smu10_power_off_asic(struct pp_hwmgr *hwmgr)
331 {
332         return smu10_reset_cc6_data(hwmgr);
333 }
334
335 static bool smu10_is_gfx_on(struct pp_hwmgr *hwmgr)
336 {
337         uint32_t reg;
338         struct amdgpu_device *adev = hwmgr->adev;
339
340         reg = RREG32_SOC15(PWR, 0, mmPWR_MISC_CNTL_STATUS);
341         if ((reg & PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS_MASK) ==
342             (0x2 << PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS__SHIFT))
343                 return true;
344
345         return false;
346 }
347
348 static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
349 {
350         struct amdgpu_device *adev = hwmgr->adev;
351
352         if (adev->pm.pp_feature & PP_GFXOFF_MASK) {
353                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_DisableGfxOff, NULL);
354
355                 /* confirm gfx is back to "on" state */
356                 while (!smu10_is_gfx_on(hwmgr))
357                         msleep(1);
358         }
359
360         return 0;
361 }
362
363 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
364 {
365         return 0;
366 }
367
368 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
369 {
370         struct amdgpu_device *adev = hwmgr->adev;
371
372         if (adev->pm.pp_feature & PP_GFXOFF_MASK)
373                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_EnableGfxOff, NULL);
374
375         return 0;
376 }
377
378 static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
379 {
380         return 0;
381 }
382
383 static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
384 {
385         if (enable)
386                 return smu10_enable_gfx_off(hwmgr);
387         else
388                 return smu10_disable_gfx_off(hwmgr);
389 }
390
391 static int smu10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
392                                 struct pp_power_state  *prequest_ps,
393                         const struct pp_power_state *pcurrent_ps)
394 {
395         return 0;
396 }
397
398 /* temporary hardcoded clock voltage breakdown tables */
399 static const DpmClock_t VddDcfClk[]= {
400         { 300, 2600},
401         { 600, 3200},
402         { 600, 3600},
403 };
404
405 static const DpmClock_t VddSocClk[]= {
406         { 478, 2600},
407         { 722, 3200},
408         { 722, 3600},
409 };
410
411 static const DpmClock_t VddFClk[]= {
412         { 400, 2600},
413         {1200, 3200},
414         {1200, 3600},
415 };
416
417 static const DpmClock_t VddDispClk[]= {
418         { 435, 2600},
419         { 661, 3200},
420         {1086, 3600},
421 };
422
423 static const DpmClock_t VddDppClk[]= {
424         { 435, 2600},
425         { 661, 3200},
426         { 661, 3600},
427 };
428
429 static const DpmClock_t VddPhyClk[]= {
430         { 540, 2600},
431         { 810, 3200},
432         { 810, 3600},
433 };
434
435 static int smu10_get_clock_voltage_dependency_table(struct pp_hwmgr *hwmgr,
436                         struct smu10_voltage_dependency_table **pptable,
437                         uint32_t num_entry, const DpmClock_t *pclk_dependency_table)
438 {
439         uint32_t i;
440         struct smu10_voltage_dependency_table *ptable;
441
442         ptable = kzalloc(struct_size(ptable, entries, num_entry), GFP_KERNEL);
443         if (NULL == ptable)
444                 return -ENOMEM;
445
446         ptable->count = num_entry;
447
448         for (i = 0; i < ptable->count; i++) {
449                 ptable->entries[i].clk         = pclk_dependency_table->Freq * 100;
450                 ptable->entries[i].vol         = pclk_dependency_table->Vol;
451                 pclk_dependency_table++;
452         }
453
454         *pptable = ptable;
455
456         return 0;
457 }
458
459
460 static int smu10_populate_clock_table(struct pp_hwmgr *hwmgr)
461 {
462         uint32_t result;
463
464         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
465         DpmClocks_t  *table = &(smu10_data->clock_table);
466         struct smu10_clock_voltage_information *pinfo = &(smu10_data->clock_vol_info);
467
468         result = smum_smc_table_manager(hwmgr, (uint8_t *)table, SMU10_CLOCKTABLE, true);
469
470         PP_ASSERT_WITH_CODE((0 == result),
471                         "Attempt to copy clock table from smc failed",
472                         return result);
473
474         if (0 == result && table->DcefClocks[0].Freq != 0) {
475                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk,
476                                                 NUM_DCEFCLK_DPM_LEVELS,
477                                                 &smu10_data->clock_table.DcefClocks[0]);
478                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_socclk,
479                                                 NUM_SOCCLK_DPM_LEVELS,
480                                                 &smu10_data->clock_table.SocClocks[0]);
481                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_fclk,
482                                                 NUM_FCLK_DPM_LEVELS,
483                                                 &smu10_data->clock_table.FClocks[0]);
484                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_mclk,
485                                                 NUM_MEMCLK_DPM_LEVELS,
486                                                 &smu10_data->clock_table.MemClocks[0]);
487         } else {
488                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk,
489                                                 ARRAY_SIZE(VddDcfClk),
490                                                 &VddDcfClk[0]);
491                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_socclk,
492                                                 ARRAY_SIZE(VddSocClk),
493                                                 &VddSocClk[0]);
494                 smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_fclk,
495                                                 ARRAY_SIZE(VddFClk),
496                                                 &VddFClk[0]);
497         }
498         smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dispclk,
499                                         ARRAY_SIZE(VddDispClk),
500                                         &VddDispClk[0]);
501         smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dppclk,
502                                         ARRAY_SIZE(VddDppClk), &VddDppClk[0]);
503         smu10_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_phyclk,
504                                         ARRAY_SIZE(VddPhyClk), &VddPhyClk[0]);
505
506         smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &result);
507         smu10_data->gfx_min_freq_limit = result / 10 * 1000;
508
509         smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &result);
510         smu10_data->gfx_max_freq_limit = result / 10 * 1000;
511
512         return 0;
513 }
514
515 static int smu10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
516 {
517         int result = 0;
518         struct smu10_hwmgr *data;
519
520         data = kzalloc(sizeof(struct smu10_hwmgr), GFP_KERNEL);
521         if (data == NULL)
522                 return -ENOMEM;
523
524         hwmgr->backend = data;
525
526         result = smu10_initialize_dpm_defaults(hwmgr);
527         if (result != 0) {
528                 pr_err("smu10_initialize_dpm_defaults failed\n");
529                 return result;
530         }
531
532         smu10_populate_clock_table(hwmgr);
533
534         result = smu10_get_system_info_data(hwmgr);
535         if (result != 0) {
536                 pr_err("smu10_get_system_info_data failed\n");
537                 return result;
538         }
539
540         smu10_construct_boot_state(hwmgr);
541
542         hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =
543                                                 SMU10_MAX_HARDWARE_POWERLEVELS;
544
545         hwmgr->platform_descriptor.hardwarePerformanceLevels =
546                                                 SMU10_MAX_HARDWARE_POWERLEVELS;
547
548         hwmgr->platform_descriptor.vbiosInterruptId = 0;
549
550         hwmgr->platform_descriptor.clockStep.engineClock = 500;
551
552         hwmgr->platform_descriptor.clockStep.memoryClock = 500;
553
554         hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50;
555
556         hwmgr->pstate_sclk = SMU10_UMD_PSTATE_GFXCLK * 100;
557         hwmgr->pstate_mclk = SMU10_UMD_PSTATE_FCLK * 100;
558
559         /* enable the pp_od_clk_voltage sysfs file */
560         hwmgr->od_enabled = 1;
561         /* disabled fine grain tuning function by default */
562         data->fine_grain_enabled = 0;
563         return result;
564 }
565
566 static int smu10_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
567 {
568         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
569         struct smu10_clock_voltage_information *pinfo = &(smu10_data->clock_vol_info);
570
571         kfree(pinfo->vdd_dep_on_dcefclk);
572         pinfo->vdd_dep_on_dcefclk = NULL;
573         kfree(pinfo->vdd_dep_on_socclk);
574         pinfo->vdd_dep_on_socclk = NULL;
575         kfree(pinfo->vdd_dep_on_fclk);
576         pinfo->vdd_dep_on_fclk = NULL;
577         kfree(pinfo->vdd_dep_on_dispclk);
578         pinfo->vdd_dep_on_dispclk = NULL;
579         kfree(pinfo->vdd_dep_on_dppclk);
580         pinfo->vdd_dep_on_dppclk = NULL;
581         kfree(pinfo->vdd_dep_on_phyclk);
582         pinfo->vdd_dep_on_phyclk = NULL;
583
584         kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl);
585         hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL;
586
587         kfree(hwmgr->backend);
588         hwmgr->backend = NULL;
589
590         return 0;
591 }
592
593 static int smu10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,
594                                 enum amd_dpm_forced_level level)
595 {
596         struct smu10_hwmgr *data = hwmgr->backend;
597         uint32_t min_sclk = hwmgr->display_config->min_core_set_clock;
598         uint32_t min_mclk = hwmgr->display_config->min_mem_set_clock/100;
599         uint32_t index_fclk = data->clock_vol_info.vdd_dep_on_fclk->count - 1;
600         uint32_t index_socclk = data->clock_vol_info.vdd_dep_on_socclk->count - 1;
601         uint32_t fine_grain_min_freq = 0, fine_grain_max_freq = 0;
602
603         if (hwmgr->smu_version < 0x1E3700) {
604                 pr_info("smu firmware version too old, can not set dpm level\n");
605                 return 0;
606         }
607
608         if (min_sclk < data->gfx_min_freq_limit)
609                 min_sclk = data->gfx_min_freq_limit;
610
611         min_sclk /= 100; /* transfer 10KHz to MHz */
612         if (min_mclk < data->clock_table.FClocks[0].Freq)
613                 min_mclk = data->clock_table.FClocks[0].Freq;
614
615         switch (level) {
616         case AMD_DPM_FORCED_LEVEL_HIGH:
617         case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK:
618                 data->fine_grain_enabled = 0;
619
620                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
621                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
622
623                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
624                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
625
626                 smum_send_msg_to_smc_with_parameter(hwmgr,
627                                                 PPSMC_MSG_SetHardMinGfxClk,
628                                                 data->gfx_max_freq_limit/100,
629                                                 NULL);
630                 smum_send_msg_to_smc_with_parameter(hwmgr,
631                                                 PPSMC_MSG_SetHardMinFclkByFreq,
632                                                 SMU10_UMD_PSTATE_PEAK_FCLK,
633                                                 NULL);
634                 smum_send_msg_to_smc_with_parameter(hwmgr,
635                                                 PPSMC_MSG_SetHardMinSocclkByFreq,
636                                                 SMU10_UMD_PSTATE_PEAK_SOCCLK,
637                                                 NULL);
638                 smum_send_msg_to_smc_with_parameter(hwmgr,
639                                                 PPSMC_MSG_SetHardMinVcn,
640                                                 SMU10_UMD_PSTATE_VCE,
641                                                 NULL);
642
643                 smum_send_msg_to_smc_with_parameter(hwmgr,
644                                                 PPSMC_MSG_SetSoftMaxGfxClk,
645                                                 data->gfx_max_freq_limit/100,
646                                                 NULL);
647                 smum_send_msg_to_smc_with_parameter(hwmgr,
648                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
649                                                 SMU10_UMD_PSTATE_PEAK_FCLK,
650                                                 NULL);
651                 smum_send_msg_to_smc_with_parameter(hwmgr,
652                                                 PPSMC_MSG_SetSoftMaxSocclkByFreq,
653                                                 SMU10_UMD_PSTATE_PEAK_SOCCLK,
654                                                 NULL);
655                 smum_send_msg_to_smc_with_parameter(hwmgr,
656                                                 PPSMC_MSG_SetSoftMaxVcn,
657                                                 SMU10_UMD_PSTATE_VCE,
658                                                 NULL);
659                 break;
660         case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:
661                 data->fine_grain_enabled = 0;
662
663                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
664                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
665
666                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
667                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
668
669                 smum_send_msg_to_smc_with_parameter(hwmgr,
670                                                 PPSMC_MSG_SetHardMinGfxClk,
671                                                 min_sclk,
672                                                 NULL);
673                 smum_send_msg_to_smc_with_parameter(hwmgr,
674                                                 PPSMC_MSG_SetSoftMaxGfxClk,
675                                                 min_sclk,
676                                                 NULL);
677                 break;
678         case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK:
679                 data->fine_grain_enabled = 0;
680
681                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
682                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
683
684                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
685                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
686
687                 smum_send_msg_to_smc_with_parameter(hwmgr,
688                                                 PPSMC_MSG_SetHardMinFclkByFreq,
689                                                 min_mclk,
690                                                 NULL);
691                 smum_send_msg_to_smc_with_parameter(hwmgr,
692                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
693                                                 min_mclk,
694                                                 NULL);
695                 break;
696         case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:
697                 data->fine_grain_enabled = 0;
698
699                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
700                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
701
702                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
703                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
704
705                 smum_send_msg_to_smc_with_parameter(hwmgr,
706                                                 PPSMC_MSG_SetHardMinGfxClk,
707                                                 SMU10_UMD_PSTATE_GFXCLK,
708                                                 NULL);
709                 smum_send_msg_to_smc_with_parameter(hwmgr,
710                                                 PPSMC_MSG_SetHardMinFclkByFreq,
711                                                 SMU10_UMD_PSTATE_FCLK,
712                                                 NULL);
713                 smum_send_msg_to_smc_with_parameter(hwmgr,
714                                                 PPSMC_MSG_SetHardMinSocclkByFreq,
715                                                 SMU10_UMD_PSTATE_SOCCLK,
716                                                 NULL);
717                 smum_send_msg_to_smc_with_parameter(hwmgr,
718                                                 PPSMC_MSG_SetHardMinVcn,
719                                                 SMU10_UMD_PSTATE_PROFILE_VCE,
720                                                 NULL);
721
722                 smum_send_msg_to_smc_with_parameter(hwmgr,
723                                                 PPSMC_MSG_SetSoftMaxGfxClk,
724                                                 SMU10_UMD_PSTATE_GFXCLK,
725                                                 NULL);
726                 smum_send_msg_to_smc_with_parameter(hwmgr,
727                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
728                                                 SMU10_UMD_PSTATE_FCLK,
729                                                 NULL);
730                 smum_send_msg_to_smc_with_parameter(hwmgr,
731                                                 PPSMC_MSG_SetSoftMaxSocclkByFreq,
732                                                 SMU10_UMD_PSTATE_SOCCLK,
733                                                 NULL);
734                 smum_send_msg_to_smc_with_parameter(hwmgr,
735                                                 PPSMC_MSG_SetSoftMaxVcn,
736                                                 SMU10_UMD_PSTATE_PROFILE_VCE,
737                                                 NULL);
738                 break;
739         case AMD_DPM_FORCED_LEVEL_AUTO:
740                 data->fine_grain_enabled = 0;
741
742                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
743                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
744
745                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
746                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
747
748                 smum_send_msg_to_smc_with_parameter(hwmgr,
749                                                 PPSMC_MSG_SetHardMinGfxClk,
750                                                 min_sclk,
751                                                 NULL);
752                 smum_send_msg_to_smc_with_parameter(hwmgr,
753                                                 PPSMC_MSG_SetHardMinFclkByFreq,
754                                                 hwmgr->display_config->num_display > 3 ?
755                                                 data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk :
756                                                 min_mclk,
757                                                 NULL);
758
759                 smum_send_msg_to_smc_with_parameter(hwmgr,
760                                                 PPSMC_MSG_SetHardMinSocclkByFreq,
761                                                 data->clock_vol_info.vdd_dep_on_socclk->entries[0].clk,
762                                                 NULL);
763                 smum_send_msg_to_smc_with_parameter(hwmgr,
764                                                 PPSMC_MSG_SetHardMinVcn,
765                                                 SMU10_UMD_PSTATE_MIN_VCE,
766                                                 NULL);
767
768                 smum_send_msg_to_smc_with_parameter(hwmgr,
769                                                 PPSMC_MSG_SetSoftMaxGfxClk,
770                                                 data->gfx_max_freq_limit/100,
771                                                 NULL);
772                 smum_send_msg_to_smc_with_parameter(hwmgr,
773                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
774                                                 data->clock_vol_info.vdd_dep_on_fclk->entries[index_fclk].clk,
775                                                 NULL);
776                 smum_send_msg_to_smc_with_parameter(hwmgr,
777                                                 PPSMC_MSG_SetSoftMaxSocclkByFreq,
778                                                 data->clock_vol_info.vdd_dep_on_socclk->entries[index_socclk].clk,
779                                                 NULL);
780                 smum_send_msg_to_smc_with_parameter(hwmgr,
781                                                 PPSMC_MSG_SetSoftMaxVcn,
782                                                 SMU10_UMD_PSTATE_VCE,
783                                                 NULL);
784                 break;
785         case AMD_DPM_FORCED_LEVEL_LOW:
786                 data->fine_grain_enabled = 0;
787
788                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &fine_grain_min_freq);
789                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &fine_grain_max_freq);
790
791                 data->gfx_actual_soft_min_freq = fine_grain_min_freq;
792                 data->gfx_actual_soft_max_freq = fine_grain_max_freq;
793
794                 smum_send_msg_to_smc_with_parameter(hwmgr,
795                                                 PPSMC_MSG_SetHardMinGfxClk,
796                                                 data->gfx_min_freq_limit/100,
797                                                 NULL);
798                 smum_send_msg_to_smc_with_parameter(hwmgr,
799                                                 PPSMC_MSG_SetSoftMaxGfxClk,
800                                                 data->gfx_min_freq_limit/100,
801                                                 NULL);
802                 smum_send_msg_to_smc_with_parameter(hwmgr,
803                                                 PPSMC_MSG_SetHardMinFclkByFreq,
804                                                 min_mclk,
805                                                 NULL);
806                 smum_send_msg_to_smc_with_parameter(hwmgr,
807                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
808                                                 min_mclk,
809                                                 NULL);
810                 break;
811         case AMD_DPM_FORCED_LEVEL_MANUAL:
812                 data->fine_grain_enabled = 1;
813                 break;
814         case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT:
815         default:
816                 break;
817         }
818         return 0;
819 }
820
821 static uint32_t smu10_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low)
822 {
823         struct smu10_hwmgr *data;
824
825         if (hwmgr == NULL)
826                 return -EINVAL;
827
828         data = (struct smu10_hwmgr *)(hwmgr->backend);
829
830         if (low)
831                 return data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk;
832         else
833                 return data->clock_vol_info.vdd_dep_on_fclk->entries[
834                         data->clock_vol_info.vdd_dep_on_fclk->count - 1].clk;
835 }
836
837 static uint32_t smu10_dpm_get_sclk(struct pp_hwmgr *hwmgr, bool low)
838 {
839         struct smu10_hwmgr *data;
840
841         if (hwmgr == NULL)
842                 return -EINVAL;
843
844         data = (struct smu10_hwmgr *)(hwmgr->backend);
845
846         if (low)
847                 return data->gfx_min_freq_limit;
848         else
849                 return data->gfx_max_freq_limit;
850 }
851
852 static int smu10_dpm_patch_boot_state(struct pp_hwmgr *hwmgr,
853                                         struct pp_hw_power_state *hw_ps)
854 {
855         return 0;
856 }
857
858 static int smu10_dpm_get_pp_table_entry_callback(
859                                                      struct pp_hwmgr *hwmgr,
860                                            struct pp_hw_power_state *hw_ps,
861                                                           unsigned int index,
862                                                      const void *clock_info)
863 {
864         struct smu10_power_state *smu10_ps = cast_smu10_ps(hw_ps);
865
866         smu10_ps->levels[index].engine_clock = 0;
867
868         smu10_ps->levels[index].vddc_index = 0;
869         smu10_ps->level = index + 1;
870
871         if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SclkDeepSleep)) {
872                 smu10_ps->levels[index].ds_divider_index = 5;
873                 smu10_ps->levels[index].ss_divider_index = 5;
874         }
875
876         return 0;
877 }
878
879 static int smu10_dpm_get_num_of_pp_table_entries(struct pp_hwmgr *hwmgr)
880 {
881         int result;
882         unsigned long ret = 0;
883
884         result = pp_tables_get_num_of_entries(hwmgr, &ret);
885
886         return result ? 0 : ret;
887 }
888
889 static int smu10_dpm_get_pp_table_entry(struct pp_hwmgr *hwmgr,
890                     unsigned long entry, struct pp_power_state *ps)
891 {
892         int result;
893         struct smu10_power_state *smu10_ps;
894
895         ps->hardware.magic = SMU10_Magic;
896
897         smu10_ps = cast_smu10_ps(&(ps->hardware));
898
899         result = pp_tables_get_entry(hwmgr, entry, ps,
900                         smu10_dpm_get_pp_table_entry_callback);
901
902         smu10_ps->uvd_clocks.vclk = ps->uvd_clocks.VCLK;
903         smu10_ps->uvd_clocks.dclk = ps->uvd_clocks.DCLK;
904
905         return result;
906 }
907
908 static int smu10_get_power_state_size(struct pp_hwmgr *hwmgr)
909 {
910         return sizeof(struct smu10_power_state);
911 }
912
913 static int smu10_set_cpu_power_state(struct pp_hwmgr *hwmgr)
914 {
915         return 0;
916 }
917
918
919 static int smu10_store_cc6_data(struct pp_hwmgr *hwmgr, uint32_t separation_time,
920                         bool cc6_disable, bool pstate_disable, bool pstate_switch_disable)
921 {
922         struct smu10_hwmgr *data = (struct smu10_hwmgr *)(hwmgr->backend);
923
924         if (separation_time != data->separation_time ||
925                         cc6_disable != data->cc6_disable ||
926                         pstate_disable != data->pstate_disable) {
927                 data->separation_time = separation_time;
928                 data->cc6_disable = cc6_disable;
929                 data->pstate_disable = pstate_disable;
930                 data->cc6_setting_changed = true;
931         }
932         return 0;
933 }
934
935 static int smu10_get_dal_power_level(struct pp_hwmgr *hwmgr,
936                 struct amd_pp_simple_clock_info *info)
937 {
938         return -EINVAL;
939 }
940
941 static int smu10_force_clock_level(struct pp_hwmgr *hwmgr,
942                 enum pp_clock_type type, uint32_t mask)
943 {
944         struct smu10_hwmgr *data = hwmgr->backend;
945         struct smu10_voltage_dependency_table *mclk_table =
946                                         data->clock_vol_info.vdd_dep_on_fclk;
947         uint32_t low, high;
948
949         low = mask ? (ffs(mask) - 1) : 0;
950         high = mask ? (fls(mask) - 1) : 0;
951
952         switch (type) {
953         case PP_SCLK:
954                 if (low > 2 || high > 2) {
955                         pr_info("Currently sclk only support 3 levels on RV\n");
956                         return -EINVAL;
957                 }
958
959                 smum_send_msg_to_smc_with_parameter(hwmgr,
960                                                 PPSMC_MSG_SetHardMinGfxClk,
961                                                 low == 2 ? data->gfx_max_freq_limit/100 :
962                                                 low == 1 ? SMU10_UMD_PSTATE_GFXCLK :
963                                                 data->gfx_min_freq_limit/100,
964                                                 NULL);
965
966                 smum_send_msg_to_smc_with_parameter(hwmgr,
967                                                 PPSMC_MSG_SetSoftMaxGfxClk,
968                                                 high == 0 ? data->gfx_min_freq_limit/100 :
969                                                 high == 1 ? SMU10_UMD_PSTATE_GFXCLK :
970                                                 data->gfx_max_freq_limit/100,
971                                                 NULL);
972                 break;
973
974         case PP_MCLK:
975                 if (low > mclk_table->count - 1 || high > mclk_table->count - 1)
976                         return -EINVAL;
977
978                 smum_send_msg_to_smc_with_parameter(hwmgr,
979                                                 PPSMC_MSG_SetHardMinFclkByFreq,
980                                                 mclk_table->entries[low].clk/100,
981                                                 NULL);
982
983                 smum_send_msg_to_smc_with_parameter(hwmgr,
984                                                 PPSMC_MSG_SetSoftMaxFclkByFreq,
985                                                 mclk_table->entries[high].clk/100,
986                                                 NULL);
987                 break;
988
989         case PP_PCIE:
990         default:
991                 break;
992         }
993         return 0;
994 }
995
996 static int smu10_print_clock_levels(struct pp_hwmgr *hwmgr,
997                 enum pp_clock_type type, char *buf)
998 {
999         struct smu10_hwmgr *data = (struct smu10_hwmgr *)(hwmgr->backend);
1000         struct smu10_voltage_dependency_table *mclk_table =
1001                         data->clock_vol_info.vdd_dep_on_fclk;
1002         uint32_t i, now, size = 0;
1003         uint32_t min_freq, max_freq = 0;
1004         uint32_t ret = 0;
1005
1006         switch (type) {
1007         case PP_SCLK:
1008                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &now);
1009
1010         /* driver only know min/max gfx_clk, Add level 1 for all other gfx clks */
1011                 if (now == data->gfx_max_freq_limit/100)
1012                         i = 2;
1013                 else if (now == data->gfx_min_freq_limit/100)
1014                         i = 0;
1015                 else
1016                         i = 1;
1017
1018                 size += sprintf(buf + size, "0: %uMhz %s\n",
1019                                         data->gfx_min_freq_limit/100,
1020                                         i == 0 ? "*" : "");
1021                 size += sprintf(buf + size, "1: %uMhz %s\n",
1022                                         i == 1 ? now : SMU10_UMD_PSTATE_GFXCLK,
1023                                         i == 1 ? "*" : "");
1024                 size += sprintf(buf + size, "2: %uMhz %s\n",
1025                                         data->gfx_max_freq_limit/100,
1026                                         i == 2 ? "*" : "");
1027                 break;
1028         case PP_MCLK:
1029                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &now);
1030
1031                 for (i = 0; i < mclk_table->count; i++)
1032                         size += sprintf(buf + size, "%d: %uMhz %s\n",
1033                                         i,
1034                                         mclk_table->entries[i].clk / 100,
1035                                         ((mclk_table->entries[i].clk / 100)
1036                                          == now) ? "*" : "");
1037                 break;
1038         case OD_SCLK:
1039                 if (hwmgr->od_enabled) {
1040                         ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);
1041                         if (ret)
1042                                 return ret;
1043                         ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);
1044                         if (ret)
1045                                 return ret;
1046
1047                         size = sprintf(buf, "%s:\n", "OD_SCLK");
1048                         size += sprintf(buf + size, "0: %10uMhz\n",
1049                         (data->gfx_actual_soft_min_freq > 0) ? data->gfx_actual_soft_min_freq : min_freq);
1050                         size += sprintf(buf + size, "1: %10uMhz\n",
1051                         (data->gfx_actual_soft_max_freq > 0) ? data->gfx_actual_soft_max_freq : max_freq);
1052                 }
1053                 break;
1054         case OD_RANGE:
1055                 if (hwmgr->od_enabled) {
1056                         ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);
1057                         if (ret)
1058                                 return ret;
1059                         ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);
1060                         if (ret)
1061                                 return ret;
1062
1063                         size = sprintf(buf, "%s:\n", "OD_RANGE");
1064                         size += sprintf(buf + size, "SCLK: %7uMHz %10uMHz\n",
1065                                 min_freq, max_freq);
1066                 }
1067                 break;
1068         default:
1069                 break;
1070         }
1071
1072         return size;
1073 }
1074
1075 static int smu10_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state,
1076                                 PHM_PerformanceLevelDesignation designation, uint32_t index,
1077                                 PHM_PerformanceLevel *level)
1078 {
1079         struct smu10_hwmgr *data;
1080
1081         if (level == NULL || hwmgr == NULL || state == NULL)
1082                 return -EINVAL;
1083
1084         data = (struct smu10_hwmgr *)(hwmgr->backend);
1085
1086         if (index == 0) {
1087                 level->memory_clock = data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk;
1088                 level->coreClock = data->gfx_min_freq_limit;
1089         } else {
1090                 level->memory_clock = data->clock_vol_info.vdd_dep_on_fclk->entries[
1091                         data->clock_vol_info.vdd_dep_on_fclk->count - 1].clk;
1092                 level->coreClock = data->gfx_max_freq_limit;
1093         }
1094
1095         level->nonLocalMemoryFreq = 0;
1096         level->nonLocalMemoryWidth = 0;
1097
1098         return 0;
1099 }
1100
1101 static int smu10_get_current_shallow_sleep_clocks(struct pp_hwmgr *hwmgr,
1102         const struct pp_hw_power_state *state, struct pp_clock_info *clock_info)
1103 {
1104         const struct smu10_power_state *ps = cast_const_smu10_ps(state);
1105
1106         clock_info->min_eng_clk = ps->levels[0].engine_clock / (1 << (ps->levels[0].ss_divider_index));
1107         clock_info->max_eng_clk = ps->levels[ps->level - 1].engine_clock / (1 << (ps->levels[ps->level - 1].ss_divider_index));
1108
1109         return 0;
1110 }
1111
1112 #define MEM_FREQ_LOW_LATENCY        25000
1113 #define MEM_FREQ_HIGH_LATENCY       80000
1114 #define MEM_LATENCY_HIGH            245
1115 #define MEM_LATENCY_LOW             35
1116 #define MEM_LATENCY_ERR             0xFFFF
1117
1118
1119 static uint32_t smu10_get_mem_latency(struct pp_hwmgr *hwmgr,
1120                 uint32_t clock)
1121 {
1122         if (clock >= MEM_FREQ_LOW_LATENCY &&
1123                         clock < MEM_FREQ_HIGH_LATENCY)
1124                 return MEM_LATENCY_HIGH;
1125         else if (clock >= MEM_FREQ_HIGH_LATENCY)
1126                 return MEM_LATENCY_LOW;
1127         else
1128                 return MEM_LATENCY_ERR;
1129 }
1130
1131 static int smu10_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr,
1132                 enum amd_pp_clock_type type,
1133                 struct pp_clock_levels_with_latency *clocks)
1134 {
1135         uint32_t i;
1136         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
1137         struct smu10_clock_voltage_information *pinfo = &(smu10_data->clock_vol_info);
1138         struct smu10_voltage_dependency_table *pclk_vol_table;
1139         bool latency_required = false;
1140
1141         if (pinfo == NULL)
1142                 return -EINVAL;
1143
1144         switch (type) {
1145         case amd_pp_mem_clock:
1146                 pclk_vol_table = pinfo->vdd_dep_on_mclk;
1147                 latency_required = true;
1148                 break;
1149         case amd_pp_f_clock:
1150                 pclk_vol_table = pinfo->vdd_dep_on_fclk;
1151                 latency_required = true;
1152                 break;
1153         case amd_pp_dcf_clock:
1154                 pclk_vol_table = pinfo->vdd_dep_on_dcefclk;
1155                 break;
1156         case amd_pp_disp_clock:
1157                 pclk_vol_table = pinfo->vdd_dep_on_dispclk;
1158                 break;
1159         case amd_pp_phy_clock:
1160                 pclk_vol_table = pinfo->vdd_dep_on_phyclk;
1161                 break;
1162         case amd_pp_dpp_clock:
1163                 pclk_vol_table = pinfo->vdd_dep_on_dppclk;
1164                 break;
1165         default:
1166                 return -EINVAL;
1167         }
1168
1169         if (pclk_vol_table == NULL || pclk_vol_table->count == 0)
1170                 return -EINVAL;
1171
1172         clocks->num_levels = 0;
1173         for (i = 0; i < pclk_vol_table->count; i++) {
1174                 if (pclk_vol_table->entries[i].clk) {
1175                         clocks->data[clocks->num_levels].clocks_in_khz =
1176                                 pclk_vol_table->entries[i].clk * 10;
1177                         clocks->data[clocks->num_levels].latency_in_us = latency_required ?
1178                                 smu10_get_mem_latency(hwmgr,
1179                                                       pclk_vol_table->entries[i].clk) :
1180                                 0;
1181                         clocks->num_levels++;
1182                 }
1183         }
1184
1185         return 0;
1186 }
1187
1188 static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
1189                 enum amd_pp_clock_type type,
1190                 struct pp_clock_levels_with_voltage *clocks)
1191 {
1192         uint32_t i;
1193         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
1194         struct smu10_clock_voltage_information *pinfo = &(smu10_data->clock_vol_info);
1195         struct smu10_voltage_dependency_table *pclk_vol_table = NULL;
1196
1197         if (pinfo == NULL)
1198                 return -EINVAL;
1199
1200         switch (type) {
1201         case amd_pp_mem_clock:
1202                 pclk_vol_table = pinfo->vdd_dep_on_mclk;
1203                 break;
1204         case amd_pp_f_clock:
1205                 pclk_vol_table = pinfo->vdd_dep_on_fclk;
1206                 break;
1207         case amd_pp_dcf_clock:
1208                 pclk_vol_table = pinfo->vdd_dep_on_dcefclk;
1209                 break;
1210         case amd_pp_soc_clock:
1211                 pclk_vol_table = pinfo->vdd_dep_on_socclk;
1212                 break;
1213         case amd_pp_disp_clock:
1214                 pclk_vol_table = pinfo->vdd_dep_on_dispclk;
1215                 break;
1216         case amd_pp_phy_clock:
1217                 pclk_vol_table = pinfo->vdd_dep_on_phyclk;
1218                 break;
1219         default:
1220                 return -EINVAL;
1221         }
1222
1223         if (pclk_vol_table == NULL || pclk_vol_table->count == 0)
1224                 return -EINVAL;
1225
1226         clocks->num_levels = 0;
1227         for (i = 0; i < pclk_vol_table->count; i++) {
1228                 if (pclk_vol_table->entries[i].clk) {
1229                         clocks->data[clocks->num_levels].clocks_in_khz = pclk_vol_table->entries[i].clk  * 10;
1230                         clocks->data[clocks->num_levels].voltage_in_mv = pclk_vol_table->entries[i].vol;
1231                         clocks->num_levels++;
1232                 }
1233         }
1234
1235         return 0;
1236 }
1237
1238
1239
1240 static int smu10_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks)
1241 {
1242         clocks->engine_max_clock = 80000; /* driver can't get engine clock, temp hard code to 800MHz */
1243         return 0;
1244 }
1245
1246 static int smu10_thermal_get_temperature(struct pp_hwmgr *hwmgr)
1247 {
1248         struct amdgpu_device *adev = hwmgr->adev;
1249         uint32_t reg_value = RREG32_SOC15(THM, 0, mmTHM_TCON_CUR_TMP);
1250         int cur_temp =
1251                 (reg_value & THM_TCON_CUR_TMP__CUR_TEMP_MASK) >> THM_TCON_CUR_TMP__CUR_TEMP__SHIFT;
1252
1253         if (cur_temp & THM_TCON_CUR_TMP__CUR_TEMP_RANGE_SEL_MASK)
1254                 cur_temp = ((cur_temp / 8) - 49) * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
1255         else
1256                 cur_temp = (cur_temp / 8) * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
1257
1258         return cur_temp;
1259 }
1260
1261 static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx,
1262                           void *value, int *size)
1263 {
1264         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
1265         struct amdgpu_device *adev = hwmgr->adev;
1266         uint32_t sclk, mclk, activity_percent;
1267         bool has_gfx_busy;
1268         int ret = 0;
1269
1270         /* GetGfxBusy support was added on RV SMU FW 30.85.00 and PCO 4.30.59 */
1271         if ((adev->apu_flags & AMD_APU_IS_PICASSO) &&
1272             (hwmgr->smu_version >= 0x41e3b))
1273                 has_gfx_busy = true;
1274         else if ((adev->apu_flags & AMD_APU_IS_RAVEN) &&
1275                  (hwmgr->smu_version >= 0x1e5500))
1276                 has_gfx_busy = true;
1277         else
1278                 has_gfx_busy = false;
1279
1280         switch (idx) {
1281         case AMDGPU_PP_SENSOR_GFX_SCLK:
1282                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &sclk);
1283                         /* in units of 10KHZ */
1284                 *((uint32_t *)value) = sclk * 100;
1285                 *size = 4;
1286                 break;
1287         case AMDGPU_PP_SENSOR_GFX_MCLK:
1288                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetFclkFrequency, &mclk);
1289                         /* in units of 10KHZ */
1290                 *((uint32_t *)value) = mclk * 100;
1291                 *size = 4;
1292                 break;
1293         case AMDGPU_PP_SENSOR_GPU_TEMP:
1294                 *((uint32_t *)value) = smu10_thermal_get_temperature(hwmgr);
1295                 break;
1296         case AMDGPU_PP_SENSOR_VCN_POWER_STATE:
1297                 *(uint32_t *)value =  smu10_data->vcn_power_gated ? 0 : 1;
1298                 *size = 4;
1299                 break;
1300         case AMDGPU_PP_SENSOR_GPU_LOAD:
1301                 if (!has_gfx_busy)
1302                         ret = -EOPNOTSUPP;
1303                 else {
1304                         ret = smum_send_msg_to_smc(hwmgr,
1305                                                    PPSMC_MSG_GetGfxBusy,
1306                                                    &activity_percent);
1307                         if (!ret)
1308                                 *((uint32_t *)value) = min(activity_percent, (u32)100);
1309                         else
1310                                 ret = -EIO;
1311                 }
1312                 break;
1313         default:
1314                 ret = -EOPNOTSUPP;
1315                 break;
1316         }
1317
1318         return ret;
1319 }
1320
1321 static int smu10_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr,
1322                 void *clock_ranges)
1323 {
1324         struct smu10_hwmgr *data = hwmgr->backend;
1325         struct dm_pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges = clock_ranges;
1326         Watermarks_t *table = &(data->water_marks_table);
1327         struct amdgpu_device *adev = hwmgr->adev;
1328         int i;
1329
1330         smu_set_watermarks_for_clocks_ranges(table,wm_with_clock_ranges);
1331
1332         if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
1333                 for (i = 0; i < NUM_WM_RANGES; i++)
1334                         table->WatermarkRow[WM_DCFCLK][i].WmType = (uint8_t)0;
1335
1336                 for (i = 0; i < NUM_WM_RANGES; i++)
1337                         table->WatermarkRow[WM_SOCCLK][i].WmType = (uint8_t)0;
1338         }
1339
1340         smum_smc_table_manager(hwmgr, (uint8_t *)table, (uint16_t)SMU10_WMTABLE, false);
1341         data->water_marks_exist = true;
1342         return 0;
1343 }
1344
1345 static int smu10_smus_notify_pwe(struct pp_hwmgr *hwmgr)
1346 {
1347
1348         return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_SetRccPfcPmeRestoreRegister, NULL);
1349 }
1350
1351 static int smu10_powergate_mmhub(struct pp_hwmgr *hwmgr)
1352 {
1353         return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerGateMmHub, NULL);
1354 }
1355
1356 static int smu10_powergate_sdma(struct pp_hwmgr *hwmgr, bool gate)
1357 {
1358         if (gate)
1359                 return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerDownSdma, NULL);
1360         else
1361                 return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerUpSdma, NULL);
1362 }
1363
1364 static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate)
1365 {
1366         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
1367
1368         if (bgate) {
1369                 amdgpu_device_ip_set_powergating_state(hwmgr->adev,
1370                                                 AMD_IP_BLOCK_TYPE_VCN,
1371                                                 AMD_PG_STATE_GATE);
1372                 smum_send_msg_to_smc_with_parameter(hwmgr,
1373                                         PPSMC_MSG_PowerDownVcn, 0, NULL);
1374                 smu10_data->vcn_power_gated = true;
1375         } else {
1376                 smum_send_msg_to_smc_with_parameter(hwmgr,
1377                                                 PPSMC_MSG_PowerUpVcn, 0, NULL);
1378                 amdgpu_device_ip_set_powergating_state(hwmgr->adev,
1379                                                 AMD_IP_BLOCK_TYPE_VCN,
1380                                                 AMD_PG_STATE_UNGATE);
1381                 smu10_data->vcn_power_gated = false;
1382         }
1383 }
1384
1385 static int conv_power_profile_to_pplib_workload(int power_profile)
1386 {
1387         int pplib_workload = 0;
1388
1389         switch (power_profile) {
1390         case PP_SMC_POWER_PROFILE_FULLSCREEN3D:
1391                 pplib_workload = WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT;
1392                 break;
1393         case PP_SMC_POWER_PROFILE_VIDEO:
1394                 pplib_workload = WORKLOAD_PPLIB_VIDEO_BIT;
1395                 break;
1396         case PP_SMC_POWER_PROFILE_VR:
1397                 pplib_workload = WORKLOAD_PPLIB_VR_BIT;
1398                 break;
1399         case PP_SMC_POWER_PROFILE_COMPUTE:
1400                 pplib_workload = WORKLOAD_PPLIB_COMPUTE_BIT;
1401                 break;
1402         case PP_SMC_POWER_PROFILE_CUSTOM:
1403                 pplib_workload = WORKLOAD_PPLIB_CUSTOM_BIT;
1404                 break;
1405         }
1406
1407         return pplib_workload;
1408 }
1409
1410 static int smu10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
1411 {
1412         uint32_t i, size = 0;
1413         static const uint8_t
1414                 profile_mode_setting[6][4] = {{70, 60, 0, 0,},
1415                                                 {70, 60, 1, 3,},
1416                                                 {90, 60, 0, 0,},
1417                                                 {70, 60, 0, 0,},
1418                                                 {70, 90, 0, 0,},
1419                                                 {30, 60, 0, 6,},
1420                                                 };
1421         static const char *profile_name[6] = {
1422                                         "BOOTUP_DEFAULT",
1423                                         "3D_FULL_SCREEN",
1424                                         "POWER_SAVING",
1425                                         "VIDEO",
1426                                         "VR",
1427                                         "COMPUTE"};
1428         static const char *title[6] = {"NUM",
1429                         "MODE_NAME",
1430                         "BUSY_SET_POINT",
1431                         "FPS",
1432                         "USE_RLC_BUSY",
1433                         "MIN_ACTIVE_LEVEL"};
1434
1435         if (!buf)
1436                 return -EINVAL;
1437
1438         size += sprintf(buf + size, "%s %16s %s %s %s %s\n",title[0],
1439                         title[1], title[2], title[3], title[4], title[5]);
1440
1441         for (i = 0; i <= PP_SMC_POWER_PROFILE_COMPUTE; i++)
1442                 size += sprintf(buf + size, "%3d %14s%s: %14d %3d %10d %14d\n",
1443                         i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " ",
1444                         profile_mode_setting[i][0], profile_mode_setting[i][1],
1445                         profile_mode_setting[i][2], profile_mode_setting[i][3]);
1446
1447         return size;
1448 }
1449
1450 static bool smu10_is_raven1_refresh(struct pp_hwmgr *hwmgr)
1451 {
1452         struct amdgpu_device *adev = hwmgr->adev;
1453         if ((adev->apu_flags & AMD_APU_IS_RAVEN) &&
1454             (hwmgr->smu_version >= 0x41e2b))
1455                 return true;
1456         else
1457                 return false;
1458 }
1459
1460 static int smu10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint32_t size)
1461 {
1462         int workload_type = 0;
1463         int result = 0;
1464
1465         if (input[size] > PP_SMC_POWER_PROFILE_COMPUTE) {
1466                 pr_err("Invalid power profile mode %ld\n", input[size]);
1467                 return -EINVAL;
1468         }
1469         if (hwmgr->power_profile_mode == input[size])
1470                 return 0;
1471
1472         /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
1473         workload_type =
1474                 conv_power_profile_to_pplib_workload(input[size]);
1475         if (workload_type &&
1476             smu10_is_raven1_refresh(hwmgr) &&
1477             !hwmgr->gfxoff_state_changed_by_workload) {
1478                 smu10_gfx_off_control(hwmgr, false);
1479                 hwmgr->gfxoff_state_changed_by_workload = true;
1480         }
1481         result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ActiveProcessNotify,
1482                                                 1 << workload_type,
1483                                                 NULL);
1484         if (!result)
1485                 hwmgr->power_profile_mode = input[size];
1486         if (workload_type && hwmgr->gfxoff_state_changed_by_workload) {
1487                 smu10_gfx_off_control(hwmgr, true);
1488                 hwmgr->gfxoff_state_changed_by_workload = false;
1489         }
1490
1491         return 0;
1492 }
1493
1494 static int smu10_asic_reset(struct pp_hwmgr *hwmgr, enum SMU_ASIC_RESET_MODE mode)
1495 {
1496         return smum_send_msg_to_smc_with_parameter(hwmgr,
1497                                                    PPSMC_MSG_DeviceDriverReset,
1498                                                    mode,
1499                                                    NULL);
1500 }
1501
1502 static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr,
1503                                         enum PP_OD_DPM_TABLE_COMMAND type,
1504                                         long *input, uint32_t size)
1505 {
1506         uint32_t min_freq, max_freq = 0;
1507         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
1508         int ret = 0;
1509
1510         if (!hwmgr->od_enabled) {
1511                 pr_err("Fine grain not support\n");
1512                 return -EINVAL;
1513         }
1514
1515         if (!smu10_data->fine_grain_enabled) {
1516                 pr_err("pp_od_clk_voltage is not accessible if power_dpm_force_performance_level is not in manual mode!\n");
1517                 return -EINVAL;
1518         }
1519
1520         if (type == PP_OD_EDIT_SCLK_VDDC_TABLE) {
1521                 if (size != 2) {
1522                         pr_err("Input parameter number not correct\n");
1523                         return -EINVAL;
1524                 }
1525
1526                 if (input[0] == 0) {
1527                         smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);
1528                         if (input[1] < min_freq) {
1529                                 pr_err("Fine grain setting minimum sclk (%ld) MHz is less than the minimum allowed (%d) MHz\n",
1530                                         input[1], min_freq);
1531                                 return -EINVAL;
1532                         }
1533                         smu10_data->gfx_actual_soft_min_freq = input[1];
1534                 } else if (input[0] == 1) {
1535                         smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);
1536                         if (input[1] > max_freq) {
1537                                 pr_err("Fine grain setting maximum sclk (%ld) MHz is greater than the maximum allowed (%d) MHz\n",
1538                                         input[1], max_freq);
1539                                 return -EINVAL;
1540                         }
1541                         smu10_data->gfx_actual_soft_max_freq = input[1];
1542                 } else {
1543                         return -EINVAL;
1544                 }
1545         } else if (type == PP_OD_RESTORE_DEFAULT_TABLE) {
1546                 if (size != 0) {
1547                         pr_err("Input parameter number not correct\n");
1548                         return -EINVAL;
1549                 }
1550                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);
1551                 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);
1552
1553                 smu10_data->gfx_actual_soft_min_freq = min_freq;
1554                 smu10_data->gfx_actual_soft_max_freq = max_freq;
1555         } else if (type == PP_OD_COMMIT_DPM_TABLE) {
1556                 if (size != 0) {
1557                         pr_err("Input parameter number not correct\n");
1558                         return -EINVAL;
1559                 }
1560
1561                 if (smu10_data->gfx_actual_soft_min_freq > smu10_data->gfx_actual_soft_max_freq) {
1562                         pr_err("The setting minimun sclk (%d) MHz is greater than the setting maximum sclk (%d) MHz\n",
1563                                         smu10_data->gfx_actual_soft_min_freq, smu10_data->gfx_actual_soft_max_freq);
1564                         return -EINVAL;
1565                 }
1566
1567                 ret = smum_send_msg_to_smc_with_parameter(hwmgr,
1568                                         PPSMC_MSG_SetHardMinGfxClk,
1569                                         smu10_data->gfx_actual_soft_min_freq,
1570                                         NULL);
1571                 if (ret)
1572                         return ret;
1573
1574                 ret = smum_send_msg_to_smc_with_parameter(hwmgr,
1575                                         PPSMC_MSG_SetSoftMaxGfxClk,
1576                                         smu10_data->gfx_actual_soft_max_freq,
1577                                         NULL);
1578                 if (ret)
1579                         return ret;
1580         } else {
1581                 return -EINVAL;
1582         }
1583
1584         return 0;
1585 }
1586
1587 static int smu10_gfx_state_change(struct pp_hwmgr *hwmgr, uint32_t state)
1588 {
1589         smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_GpuChangeState, state, NULL);
1590
1591         return 0;
1592 }
1593
1594 static const struct pp_hwmgr_func smu10_hwmgr_funcs = {
1595         .backend_init = smu10_hwmgr_backend_init,
1596         .backend_fini = smu10_hwmgr_backend_fini,
1597         .apply_state_adjust_rules = smu10_apply_state_adjust_rules,
1598         .force_dpm_level = smu10_dpm_force_dpm_level,
1599         .get_power_state_size = smu10_get_power_state_size,
1600         .powerdown_uvd = NULL,
1601         .powergate_uvd = smu10_powergate_vcn,
1602         .powergate_vce = NULL,
1603         .get_mclk = smu10_dpm_get_mclk,
1604         .get_sclk = smu10_dpm_get_sclk,
1605         .patch_boot_state = smu10_dpm_patch_boot_state,
1606         .get_pp_table_entry = smu10_dpm_get_pp_table_entry,
1607         .get_num_of_pp_table_entries = smu10_dpm_get_num_of_pp_table_entries,
1608         .set_cpu_power_state = smu10_set_cpu_power_state,
1609         .store_cc6_data = smu10_store_cc6_data,
1610         .force_clock_level = smu10_force_clock_level,
1611         .print_clock_levels = smu10_print_clock_levels,
1612         .get_dal_power_level = smu10_get_dal_power_level,
1613         .get_performance_level = smu10_get_performance_level,
1614         .get_current_shallow_sleep_clocks = smu10_get_current_shallow_sleep_clocks,
1615         .get_clock_by_type_with_latency = smu10_get_clock_by_type_with_latency,
1616         .get_clock_by_type_with_voltage = smu10_get_clock_by_type_with_voltage,
1617         .set_watermarks_for_clocks_ranges = smu10_set_watermarks_for_clocks_ranges,
1618         .get_max_high_clocks = smu10_get_max_high_clocks,
1619         .read_sensor = smu10_read_sensor,
1620         .set_active_display_count = smu10_set_active_display_count,
1621         .set_min_deep_sleep_dcefclk = smu10_set_min_deep_sleep_dcefclk,
1622         .dynamic_state_management_enable = smu10_enable_dpm_tasks,
1623         .power_off_asic = smu10_power_off_asic,
1624         .asic_setup = smu10_setup_asic_task,
1625         .power_state_set = smu10_set_power_state_tasks,
1626         .dynamic_state_management_disable = smu10_disable_dpm_tasks,
1627         .powergate_mmhub = smu10_powergate_mmhub,
1628         .smus_notify_pwe = smu10_smus_notify_pwe,
1629         .display_clock_voltage_request = smu10_display_clock_voltage_request,
1630         .powergate_gfx = smu10_gfx_off_control,
1631         .powergate_sdma = smu10_powergate_sdma,
1632         .set_hard_min_dcefclk_by_freq = smu10_set_hard_min_dcefclk_by_freq,
1633         .set_hard_min_fclk_by_freq = smu10_set_hard_min_fclk_by_freq,
1634         .set_hard_min_gfxclk_by_freq = smu10_set_hard_min_gfxclk_by_freq,
1635         .set_soft_max_gfxclk_by_freq = smu10_set_soft_max_gfxclk_by_freq,
1636         .get_power_profile_mode = smu10_get_power_profile_mode,
1637         .set_power_profile_mode = smu10_set_power_profile_mode,
1638         .asic_reset = smu10_asic_reset,
1639         .set_fine_grain_clk_vol = smu10_set_fine_grain_clk_vol,
1640         .gfx_state_change = smu10_gfx_state_change,
1641 };
1642
1643 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)
1644 {
1645         hwmgr->hwmgr_func = &smu10_hwmgr_funcs;
1646         hwmgr->pptable_func = &pptable_funcs;
1647         return 0;
1648 }