aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRex Zhu <Rex.Zhu@amd.com>2018-03-26 06:49:35 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-04-11 14:07:51 -0400
commitb3892e2bb519fe18225d0628f0dd255761f16502 (patch)
treef60d52f21141662d9cdc2e2d1736800c81c07ed4
parente8ee21d2a46d8d5cc85766fb49251c2c21871b30 (diff)
drm/amd/pp: Use atombios api directly in powerplay (v2)
In order to remove the cgs wrapper functions for atombios api. v2: squash in whitespace cleanup (Alex) Reviewed-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c145
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c90
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c4
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c16
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c2
12 files changed, 150 insertions, 124 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
index c6febbf0bf69..971fb5dfb620 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
@@ -23,7 +23,7 @@
23#include "pp_debug.h" 23#include "pp_debug.h"
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26 26#include "atom.h"
27#include "ppatomctrl.h" 27#include "ppatomctrl.h"
28#include "atombios.h" 28#include "atombios.h"
29#include "cgs_common.h" 29#include "cgs_common.h"
@@ -128,7 +128,6 @@ static int atomctrl_set_mc_reg_address_table(
128 return 0; 128 return 0;
129} 129}
130 130
131
132int atomctrl_initialize_mc_reg_table( 131int atomctrl_initialize_mc_reg_table(
133 struct pp_hwmgr *hwmgr, 132 struct pp_hwmgr *hwmgr,
134 uint8_t module_index, 133 uint8_t module_index,
@@ -141,7 +140,7 @@ int atomctrl_initialize_mc_reg_table(
141 u16 size; 140 u16 size;
142 141
143 vram_info = (ATOM_VRAM_INFO_HEADER_V2_1 *) 142 vram_info = (ATOM_VRAM_INFO_HEADER_V2_1 *)
144 cgs_atom_get_data_table(hwmgr->device, 143 smu_atom_get_data_table(hwmgr->adev,
145 GetIndexIntoMasterTable(DATA, VRAM_Info), &size, &frev, &crev); 144 GetIndexIntoMasterTable(DATA, VRAM_Info), &size, &frev, &crev);
146 145
147 if (module_index >= vram_info->ucNumOfVRAMModule) { 146 if (module_index >= vram_info->ucNumOfVRAMModule) {
@@ -174,6 +173,8 @@ int atomctrl_set_engine_dram_timings_rv770(
174 uint32_t engine_clock, 173 uint32_t engine_clock,
175 uint32_t memory_clock) 174 uint32_t memory_clock)
176{ 175{
176 struct amdgpu_device *adev = hwmgr->adev;
177
177 SET_ENGINE_CLOCK_PS_ALLOCATION engine_clock_parameters; 178 SET_ENGINE_CLOCK_PS_ALLOCATION engine_clock_parameters;
178 179
179 /* They are both in 10KHz Units. */ 180 /* They are both in 10KHz Units. */
@@ -184,9 +185,10 @@ int atomctrl_set_engine_dram_timings_rv770(
184 /* in 10 khz units.*/ 185 /* in 10 khz units.*/
185 engine_clock_parameters.sReserved.ulClock = 186 engine_clock_parameters.sReserved.ulClock =
186 cpu_to_le32(memory_clock & SET_CLOCK_FREQ_MASK); 187 cpu_to_le32(memory_clock & SET_CLOCK_FREQ_MASK);
187 return cgs_atom_exec_cmd_table(hwmgr->device, 188
189 return amdgpu_atom_execute_table(adev->mode_info.atom_context,
188 GetIndexIntoMasterTable(COMMAND, DynamicMemorySettings), 190 GetIndexIntoMasterTable(COMMAND, DynamicMemorySettings),
189 &engine_clock_parameters); 191 (uint32_t *)&engine_clock_parameters);
190} 192}
191 193
192/** 194/**
@@ -203,7 +205,7 @@ static ATOM_VOLTAGE_OBJECT_INFO *get_voltage_info_table(void *device)
203 union voltage_object_info *voltage_info; 205 union voltage_object_info *voltage_info;
204 206
205 voltage_info = (union voltage_object_info *) 207 voltage_info = (union voltage_object_info *)
206 cgs_atom_get_data_table(device, index, 208 smu_atom_get_data_table(device, index,
207 &size, &frev, &crev); 209 &size, &frev, &crev);
208 210
209 if (voltage_info != NULL) 211 if (voltage_info != NULL)
@@ -247,16 +249,16 @@ int atomctrl_get_memory_pll_dividers_si(
247 pp_atomctrl_memory_clock_param *mpll_param, 249 pp_atomctrl_memory_clock_param *mpll_param,
248 bool strobe_mode) 250 bool strobe_mode)
249{ 251{
252 struct amdgpu_device *adev = hwmgr->adev;
250 COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1 mpll_parameters; 253 COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1 mpll_parameters;
251 int result; 254 int result;
252 255
253 mpll_parameters.ulClock = cpu_to_le32(clock_value); 256 mpll_parameters.ulClock = cpu_to_le32(clock_value);
254 mpll_parameters.ucInputFlag = (uint8_t)((strobe_mode) ? 1 : 0); 257 mpll_parameters.ucInputFlag = (uint8_t)((strobe_mode) ? 1 : 0);
255 258
256 result = cgs_atom_exec_cmd_table 259 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
257 (hwmgr->device,
258 GetIndexIntoMasterTable(COMMAND, ComputeMemoryClockParam), 260 GetIndexIntoMasterTable(COMMAND, ComputeMemoryClockParam),
259 &mpll_parameters); 261 (uint32_t *)&mpll_parameters);
260 262
261 if (0 == result) { 263 if (0 == result) {
262 mpll_param->mpll_fb_divider.clk_frac = 264 mpll_param->mpll_fb_divider.clk_frac =
@@ -295,14 +297,15 @@ int atomctrl_get_memory_pll_dividers_si(
295int atomctrl_get_memory_pll_dividers_vi(struct pp_hwmgr *hwmgr, 297int atomctrl_get_memory_pll_dividers_vi(struct pp_hwmgr *hwmgr,
296 uint32_t clock_value, pp_atomctrl_memory_clock_param *mpll_param) 298 uint32_t clock_value, pp_atomctrl_memory_clock_param *mpll_param)
297{ 299{
300 struct amdgpu_device *adev = hwmgr->adev;
298 COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_2 mpll_parameters; 301 COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_2 mpll_parameters;
299 int result; 302 int result;
300 303
301 mpll_parameters.ulClock.ulClock = cpu_to_le32(clock_value); 304 mpll_parameters.ulClock.ulClock = cpu_to_le32(clock_value);
302 305
303 result = cgs_atom_exec_cmd_table(hwmgr->device, 306 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
304 GetIndexIntoMasterTable(COMMAND, ComputeMemoryClockParam), 307 GetIndexIntoMasterTable(COMMAND, ComputeMemoryClockParam),
305 &mpll_parameters); 308 (uint32_t *)&mpll_parameters);
306 309
307 if (!result) 310 if (!result)
308 mpll_param->mpll_post_divider = 311 mpll_param->mpll_post_divider =
@@ -315,15 +318,15 @@ int atomctrl_get_engine_pll_dividers_kong(struct pp_hwmgr *hwmgr,
315 uint32_t clock_value, 318 uint32_t clock_value,
316 pp_atomctrl_clock_dividers_kong *dividers) 319 pp_atomctrl_clock_dividers_kong *dividers)
317{ 320{
321 struct amdgpu_device *adev = hwmgr->adev;
318 COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V4 pll_parameters; 322 COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V4 pll_parameters;
319 int result; 323 int result;
320 324
321 pll_parameters.ulClock = cpu_to_le32(clock_value); 325 pll_parameters.ulClock = cpu_to_le32(clock_value);
322 326
323 result = cgs_atom_exec_cmd_table 327 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
324 (hwmgr->device,
325 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL), 328 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL),
326 &pll_parameters); 329 (uint32_t *)&pll_parameters);
327 330
328 if (0 == result) { 331 if (0 == result) {
329 dividers->pll_post_divider = pll_parameters.ucPostDiv; 332 dividers->pll_post_divider = pll_parameters.ucPostDiv;
@@ -338,16 +341,16 @@ int atomctrl_get_engine_pll_dividers_vi(
338 uint32_t clock_value, 341 uint32_t clock_value,
339 pp_atomctrl_clock_dividers_vi *dividers) 342 pp_atomctrl_clock_dividers_vi *dividers)
340{ 343{
344 struct amdgpu_device *adev = hwmgr->adev;
341 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6 pll_patameters; 345 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6 pll_patameters;
342 int result; 346 int result;
343 347
344 pll_patameters.ulClock.ulClock = cpu_to_le32(clock_value); 348 pll_patameters.ulClock.ulClock = cpu_to_le32(clock_value);
345 pll_patameters.ulClock.ucPostDiv = COMPUTE_GPUCLK_INPUT_FLAG_SCLK; 349 pll_patameters.ulClock.ucPostDiv = COMPUTE_GPUCLK_INPUT_FLAG_SCLK;
346 350
347 result = cgs_atom_exec_cmd_table 351 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
348 (hwmgr->device,
349 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL), 352 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL),
350 &pll_patameters); 353 (uint32_t *)&pll_patameters);
351 354
352 if (0 == result) { 355 if (0 == result) {
353 dividers->pll_post_divider = 356 dividers->pll_post_divider =
@@ -375,16 +378,16 @@ int atomctrl_get_engine_pll_dividers_ai(struct pp_hwmgr *hwmgr,
375 uint32_t clock_value, 378 uint32_t clock_value,
376 pp_atomctrl_clock_dividers_ai *dividers) 379 pp_atomctrl_clock_dividers_ai *dividers)
377{ 380{
381 struct amdgpu_device *adev = hwmgr->adev;
378 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_7 pll_patameters; 382 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_7 pll_patameters;
379 int result; 383 int result;
380 384
381 pll_patameters.ulClock.ulClock = cpu_to_le32(clock_value); 385 pll_patameters.ulClock.ulClock = cpu_to_le32(clock_value);
382 pll_patameters.ulClock.ucPostDiv = COMPUTE_GPUCLK_INPUT_FLAG_SCLK; 386 pll_patameters.ulClock.ucPostDiv = COMPUTE_GPUCLK_INPUT_FLAG_SCLK;
383 387
384 result = cgs_atom_exec_cmd_table 388 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
385 (hwmgr->device,
386 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL), 389 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL),
387 &pll_patameters); 390 (uint32_t *)&pll_patameters);
388 391
389 if (0 == result) { 392 if (0 == result) {
390 dividers->usSclk_fcw_frac = le16_to_cpu(pll_patameters.usSclk_fcw_frac); 393 dividers->usSclk_fcw_frac = le16_to_cpu(pll_patameters.usSclk_fcw_frac);
@@ -407,6 +410,7 @@ int atomctrl_get_dfs_pll_dividers_vi(
407 uint32_t clock_value, 410 uint32_t clock_value,
408 pp_atomctrl_clock_dividers_vi *dividers) 411 pp_atomctrl_clock_dividers_vi *dividers)
409{ 412{
413 struct amdgpu_device *adev = hwmgr->adev;
410 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6 pll_patameters; 414 COMPUTE_GPU_CLOCK_OUTPUT_PARAMETERS_V1_6 pll_patameters;
411 int result; 415 int result;
412 416
@@ -414,10 +418,9 @@ int atomctrl_get_dfs_pll_dividers_vi(
414 pll_patameters.ulClock.ucPostDiv = 418 pll_patameters.ulClock.ucPostDiv =
415 COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK; 419 COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK;
416 420
417 result = cgs_atom_exec_cmd_table 421 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
418 (hwmgr->device,
419 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL), 422 GetIndexIntoMasterTable(COMMAND, ComputeMemoryEnginePLL),
420 &pll_patameters); 423 (uint32_t *)&pll_patameters);
421 424
422 if (0 == result) { 425 if (0 == result) {
423 dividers->pll_post_divider = 426 dividers->pll_post_divider =
@@ -452,7 +455,7 @@ uint32_t atomctrl_get_reference_clock(struct pp_hwmgr *hwmgr)
452 uint32_t clock; 455 uint32_t clock;
453 456
454 fw_info = (ATOM_FIRMWARE_INFO *) 457 fw_info = (ATOM_FIRMWARE_INFO *)
455 cgs_atom_get_data_table(hwmgr->device, 458 smu_atom_get_data_table(hwmgr->adev,
456 GetIndexIntoMasterTable(DATA, FirmwareInfo), 459 GetIndexIntoMasterTable(DATA, FirmwareInfo),
457 &size, &frev, &crev); 460 &size, &frev, &crev);
458 461
@@ -476,7 +479,7 @@ bool atomctrl_is_voltage_controlled_by_gpio_v3(
476 uint8_t voltage_mode) 479 uint8_t voltage_mode)
477{ 480{
478 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info = 481 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info =
479 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->device); 482 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->adev);
480 bool ret; 483 bool ret;
481 484
482 PP_ASSERT_WITH_CODE((NULL != voltage_info), 485 PP_ASSERT_WITH_CODE((NULL != voltage_info),
@@ -495,7 +498,7 @@ int atomctrl_get_voltage_table_v3(
495 pp_atomctrl_voltage_table *voltage_table) 498 pp_atomctrl_voltage_table *voltage_table)
496{ 499{
497 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info = 500 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info =
498 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->device); 501 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->adev);
499 const ATOM_VOLTAGE_OBJECT_V3 *voltage_object; 502 const ATOM_VOLTAGE_OBJECT_V3 *voltage_object;
500 unsigned int i; 503 unsigned int i;
501 504
@@ -572,7 +575,7 @@ static ATOM_GPIO_PIN_LUT *get_gpio_lookup_table(void *device)
572 void *table_address; 575 void *table_address;
573 576
574 table_address = (ATOM_GPIO_PIN_LUT *) 577 table_address = (ATOM_GPIO_PIN_LUT *)
575 cgs_atom_get_data_table(device, 578 smu_atom_get_data_table(device,
576 GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT), 579 GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT),
577 &size, &frev, &crev); 580 &size, &frev, &crev);
578 581
@@ -592,7 +595,7 @@ bool atomctrl_get_pp_assign_pin(
592{ 595{
593 bool bRet = false; 596 bool bRet = false;
594 ATOM_GPIO_PIN_LUT *gpio_lookup_table = 597 ATOM_GPIO_PIN_LUT *gpio_lookup_table =
595 get_gpio_lookup_table(hwmgr->device); 598 get_gpio_lookup_table(hwmgr->adev);
596 599
597 PP_ASSERT_WITH_CODE((NULL != gpio_lookup_table), 600 PP_ASSERT_WITH_CODE((NULL != gpio_lookup_table),
598 "Could not find GPIO lookup Table in BIOS.", return false); 601 "Could not find GPIO lookup Table in BIOS.", return false);
@@ -613,7 +616,7 @@ int atomctrl_calculate_voltage_evv_on_sclk(
613 bool debug) 616 bool debug)
614{ 617{
615 ATOM_ASIC_PROFILING_INFO_V3_4 *getASICProfilingInfo; 618 ATOM_ASIC_PROFILING_INFO_V3_4 *getASICProfilingInfo;
616 619 struct amdgpu_device *adev = hwmgr->adev;
617 EFUSE_LINEAR_FUNC_PARAM sRO_fuse; 620 EFUSE_LINEAR_FUNC_PARAM sRO_fuse;
618 EFUSE_LINEAR_FUNC_PARAM sCACm_fuse; 621 EFUSE_LINEAR_FUNC_PARAM sCACm_fuse;
619 EFUSE_LINEAR_FUNC_PARAM sCACb_fuse; 622 EFUSE_LINEAR_FUNC_PARAM sCACb_fuse;
@@ -640,7 +643,7 @@ int atomctrl_calculate_voltage_evv_on_sclk(
640 int result; 643 int result;
641 644
642 getASICProfilingInfo = (ATOM_ASIC_PROFILING_INFO_V3_4 *) 645 getASICProfilingInfo = (ATOM_ASIC_PROFILING_INFO_V3_4 *)
643 cgs_atom_get_data_table(hwmgr->device, 646 smu_atom_get_data_table(hwmgr->adev,
644 GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo), 647 GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo),
645 NULL, NULL, NULL); 648 NULL, NULL, NULL);
646 649
@@ -706,9 +709,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
706 709
707 sOutput_FuseValues.sEfuse = sInput_FuseValues; 710 sOutput_FuseValues.sEfuse = sInput_FuseValues;
708 711
709 result = cgs_atom_exec_cmd_table(hwmgr->device, 712 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
710 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 713 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
711 &sOutput_FuseValues); 714 (uint32_t *)&sOutput_FuseValues);
712 715
713 if (result) 716 if (result)
714 return result; 717 return result;
@@ -727,9 +730,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
727 730
728 sOutput_FuseValues.sEfuse = sInput_FuseValues; 731 sOutput_FuseValues.sEfuse = sInput_FuseValues;
729 732
730 result = cgs_atom_exec_cmd_table(hwmgr->device, 733 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
731 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 734 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
732 &sOutput_FuseValues); 735 (uint32_t *)&sOutput_FuseValues);
733 736
734 if (result) 737 if (result)
735 return result; 738 return result;
@@ -747,9 +750,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
747 sInput_FuseValues.ucBitLength = sCACb_fuse.ucEfuseLength; 750 sInput_FuseValues.ucBitLength = sCACb_fuse.ucEfuseLength;
748 sOutput_FuseValues.sEfuse = sInput_FuseValues; 751 sOutput_FuseValues.sEfuse = sInput_FuseValues;
749 752
750 result = cgs_atom_exec_cmd_table(hwmgr->device, 753 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
751 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 754 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
752 &sOutput_FuseValues); 755 (uint32_t *)&sOutput_FuseValues);
753 756
754 if (result) 757 if (result)
755 return result; 758 return result;
@@ -768,9 +771,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
768 771
769 sOutput_FuseValues.sEfuse = sInput_FuseValues; 772 sOutput_FuseValues.sEfuse = sInput_FuseValues;
770 773
771 result = cgs_atom_exec_cmd_table(hwmgr->device, 774 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
772 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 775 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
773 &sOutput_FuseValues); 776 (uint32_t *)&sOutput_FuseValues);
774 777
775 if (result) 778 if (result)
776 return result; 779 return result;
@@ -790,9 +793,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
790 793
791 sOutput_FuseValues.sEfuse = sInput_FuseValues; 794 sOutput_FuseValues.sEfuse = sInput_FuseValues;
792 795
793 result = cgs_atom_exec_cmd_table(hwmgr->device, 796 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
794 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 797 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
795 &sOutput_FuseValues); 798 (uint32_t *)&sOutput_FuseValues);
796 if (result) 799 if (result)
797 return result; 800 return result;
798 801
@@ -811,9 +814,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
811 sInput_FuseValues.ucBitLength = sKv_b_fuse.ucEfuseLength; 814 sInput_FuseValues.ucBitLength = sKv_b_fuse.ucEfuseLength;
812 sOutput_FuseValues.sEfuse = sInput_FuseValues; 815 sOutput_FuseValues.sEfuse = sInput_FuseValues;
813 816
814 result = cgs_atom_exec_cmd_table(hwmgr->device, 817 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
815 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 818 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
816 &sOutput_FuseValues); 819 (uint32_t *)&sOutput_FuseValues);
817 820
818 if (result) 821 if (result)
819 return result; 822 return result;
@@ -842,9 +845,9 @@ int atomctrl_calculate_voltage_evv_on_sclk(
842 845
843 sOutput_FuseValues.sEfuse = sInput_FuseValues; 846 sOutput_FuseValues.sEfuse = sInput_FuseValues;
844 847
845 result = cgs_atom_exec_cmd_table(hwmgr->device, 848 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
846 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 849 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
847 &sOutput_FuseValues); 850 (uint32_t *)&sOutput_FuseValues);
848 851
849 if (result) 852 if (result)
850 return result; 853 return result;
@@ -1053,8 +1056,9 @@ int atomctrl_get_voltage_evv_on_sclk(
1053 uint32_t sclk, uint16_t virtual_voltage_Id, 1056 uint32_t sclk, uint16_t virtual_voltage_Id,
1054 uint16_t *voltage) 1057 uint16_t *voltage)
1055{ 1058{
1056 int result; 1059 struct amdgpu_device *adev = hwmgr->adev;
1057 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 get_voltage_info_param_space; 1060 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 get_voltage_info_param_space;
1061 int result;
1058 1062
1059 get_voltage_info_param_space.ucVoltageType = 1063 get_voltage_info_param_space.ucVoltageType =
1060 voltage_type; 1064 voltage_type;
@@ -1065,9 +1069,9 @@ int atomctrl_get_voltage_evv_on_sclk(
1065 get_voltage_info_param_space.ulSCLKFreq = 1069 get_voltage_info_param_space.ulSCLKFreq =
1066 cpu_to_le32(sclk); 1070 cpu_to_le32(sclk);
1067 1071
1068 result = cgs_atom_exec_cmd_table(hwmgr->device, 1072 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1069 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), 1073 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo),
1070 &get_voltage_info_param_space); 1074 (uint32_t *)&get_voltage_info_param_space);
1071 1075
1072 if (0 != result) 1076 if (0 != result)
1073 return result; 1077 return result;
@@ -1088,9 +1092,10 @@ int atomctrl_get_voltage_evv(struct pp_hwmgr *hwmgr,
1088 uint16_t virtual_voltage_id, 1092 uint16_t virtual_voltage_id,
1089 uint16_t *voltage) 1093 uint16_t *voltage)
1090{ 1094{
1095 struct amdgpu_device *adev = hwmgr->adev;
1096 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 get_voltage_info_param_space;
1091 int result; 1097 int result;
1092 int entry_id; 1098 int entry_id;
1093 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 get_voltage_info_param_space;
1094 1099
1095 /* search for leakage voltage ID 0xff01 ~ 0xff08 and sckl */ 1100 /* search for leakage voltage ID 0xff01 ~ 0xff08 and sckl */
1096 for (entry_id = 0; entry_id < hwmgr->dyn_state.vddc_dependency_on_sclk->count; entry_id++) { 1101 for (entry_id = 0; entry_id < hwmgr->dyn_state.vddc_dependency_on_sclk->count; entry_id++) {
@@ -1111,9 +1116,9 @@ int atomctrl_get_voltage_evv(struct pp_hwmgr *hwmgr,
1111 get_voltage_info_param_space.ulSCLKFreq = 1116 get_voltage_info_param_space.ulSCLKFreq =
1112 cpu_to_le32(hwmgr->dyn_state.vddc_dependency_on_sclk->entries[entry_id].clk); 1117 cpu_to_le32(hwmgr->dyn_state.vddc_dependency_on_sclk->entries[entry_id].clk);
1113 1118
1114 result = cgs_atom_exec_cmd_table(hwmgr->device, 1119 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1115 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), 1120 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo),
1116 &get_voltage_info_param_space); 1121 (uint32_t *)&get_voltage_info_param_space);
1117 1122
1118 if (0 != result) 1123 if (0 != result)
1119 return result; 1124 return result;
@@ -1135,7 +1140,7 @@ uint32_t atomctrl_get_mpll_reference_clock(struct pp_hwmgr *hwmgr)
1135 u16 size; 1140 u16 size;
1136 1141
1137 fw_info = (ATOM_COMMON_TABLE_HEADER *) 1142 fw_info = (ATOM_COMMON_TABLE_HEADER *)
1138 cgs_atom_get_data_table(hwmgr->device, 1143 smu_atom_get_data_table(hwmgr->adev,
1139 GetIndexIntoMasterTable(DATA, FirmwareInfo), 1144 GetIndexIntoMasterTable(DATA, FirmwareInfo),
1140 &size, &frev, &crev); 1145 &size, &frev, &crev);
1141 1146
@@ -1167,7 +1172,7 @@ static ATOM_ASIC_INTERNAL_SS_INFO *asic_internal_ss_get_ss_table(void *device)
1167 u16 size; 1172 u16 size;
1168 1173
1169 table = (ATOM_ASIC_INTERNAL_SS_INFO *) 1174 table = (ATOM_ASIC_INTERNAL_SS_INFO *)
1170 cgs_atom_get_data_table(device, 1175 smu_atom_get_data_table(device,
1171 GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info), 1176 GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info),
1172 &size, &frev, &crev); 1177 &size, &frev, &crev);
1173 1178
@@ -1188,7 +1193,7 @@ static int asic_internal_ss_get_ss_asignment(struct pp_hwmgr *hwmgr,
1188 1193
1189 memset(ssEntry, 0x00, sizeof(pp_atomctrl_internal_ss_info)); 1194 memset(ssEntry, 0x00, sizeof(pp_atomctrl_internal_ss_info));
1190 1195
1191 table = asic_internal_ss_get_ss_table(hwmgr->device); 1196 table = asic_internal_ss_get_ss_table(hwmgr->adev);
1192 1197
1193 if (NULL == table) 1198 if (NULL == table)
1194 return -1; 1199 return -1;
@@ -1260,9 +1265,10 @@ int atomctrl_get_engine_clock_spread_spectrum(
1260 ASIC_INTERNAL_ENGINE_SS, engine_clock, ssInfo); 1265 ASIC_INTERNAL_ENGINE_SS, engine_clock, ssInfo);
1261} 1266}
1262 1267
1263int atomctrl_read_efuse(void *device, uint16_t start_index, 1268int atomctrl_read_efuse(struct pp_hwmgr *hwmgr, uint16_t start_index,
1264 uint16_t end_index, uint32_t mask, uint32_t *efuse) 1269 uint16_t end_index, uint32_t mask, uint32_t *efuse)
1265{ 1270{
1271 struct amdgpu_device *adev = hwmgr->adev;
1266 int result; 1272 int result;
1267 READ_EFUSE_VALUE_PARAMETER efuse_param; 1273 READ_EFUSE_VALUE_PARAMETER efuse_param;
1268 1274
@@ -1272,9 +1278,9 @@ int atomctrl_read_efuse(void *device, uint16_t start_index,
1272 efuse_param.sEfuse.ucBitLength = (uint8_t) 1278 efuse_param.sEfuse.ucBitLength = (uint8_t)
1273 ((end_index - start_index) + 1); 1279 ((end_index - start_index) + 1);
1274 1280
1275 result = cgs_atom_exec_cmd_table(device, 1281 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1276 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue), 1282 GetIndexIntoMasterTable(COMMAND, ReadEfuseValue),
1277 &efuse_param); 1283 (uint32_t *)&efuse_param);
1278 if (!result) 1284 if (!result)
1279 *efuse = le32_to_cpu(efuse_param.ulEfuseValue) & mask; 1285 *efuse = le32_to_cpu(efuse_param.ulEfuseValue) & mask;
1280 1286
@@ -1284,6 +1290,7 @@ int atomctrl_read_efuse(void *device, uint16_t start_index,
1284int atomctrl_set_ac_timing_ai(struct pp_hwmgr *hwmgr, uint32_t memory_clock, 1290int atomctrl_set_ac_timing_ai(struct pp_hwmgr *hwmgr, uint32_t memory_clock,
1285 uint8_t level) 1291 uint8_t level)
1286{ 1292{
1293 struct amdgpu_device *adev = hwmgr->adev;
1287 DYNAMICE_MEMORY_SETTINGS_PARAMETER_V2_1 memory_clock_parameters; 1294 DYNAMICE_MEMORY_SETTINGS_PARAMETER_V2_1 memory_clock_parameters;
1288 int result; 1295 int result;
1289 1296
@@ -1293,10 +1300,9 @@ int atomctrl_set_ac_timing_ai(struct pp_hwmgr *hwmgr, uint32_t memory_clock,
1293 ADJUST_MC_SETTING_PARAM; 1300 ADJUST_MC_SETTING_PARAM;
1294 memory_clock_parameters.asDPMMCReg.ucMclkDPMState = level; 1301 memory_clock_parameters.asDPMMCReg.ucMclkDPMState = level;
1295 1302
1296 result = cgs_atom_exec_cmd_table 1303 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1297 (hwmgr->device,
1298 GetIndexIntoMasterTable(COMMAND, DynamicMemorySettings), 1304 GetIndexIntoMasterTable(COMMAND, DynamicMemorySettings),
1299 &memory_clock_parameters); 1305 (uint32_t *)&memory_clock_parameters);
1300 1306
1301 return result; 1307 return result;
1302} 1308}
@@ -1304,7 +1310,7 @@ int atomctrl_set_ac_timing_ai(struct pp_hwmgr *hwmgr, uint32_t memory_clock,
1304int atomctrl_get_voltage_evv_on_sclk_ai(struct pp_hwmgr *hwmgr, uint8_t voltage_type, 1310int atomctrl_get_voltage_evv_on_sclk_ai(struct pp_hwmgr *hwmgr, uint8_t voltage_type,
1305 uint32_t sclk, uint16_t virtual_voltage_Id, uint32_t *voltage) 1311 uint32_t sclk, uint16_t virtual_voltage_Id, uint32_t *voltage)
1306{ 1312{
1307 1313 struct amdgpu_device *adev = hwmgr->adev;
1308 int result; 1314 int result;
1309 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_3 get_voltage_info_param_space; 1315 GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_3 get_voltage_info_param_space;
1310 1316
@@ -1313,9 +1319,9 @@ int atomctrl_get_voltage_evv_on_sclk_ai(struct pp_hwmgr *hwmgr, uint8_t voltage_
1313 get_voltage_info_param_space.usVoltageLevel = cpu_to_le16(virtual_voltage_Id); 1319 get_voltage_info_param_space.usVoltageLevel = cpu_to_le16(virtual_voltage_Id);
1314 get_voltage_info_param_space.ulSCLKFreq = cpu_to_le32(sclk); 1320 get_voltage_info_param_space.ulSCLKFreq = cpu_to_le32(sclk);
1315 1321
1316 result = cgs_atom_exec_cmd_table(hwmgr->device, 1322 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1317 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo), 1323 GetIndexIntoMasterTable(COMMAND, GetVoltageInfo),
1318 &get_voltage_info_param_space); 1324 (uint32_t *)&get_voltage_info_param_space);
1319 1325
1320 if (0 != result) 1326 if (0 != result)
1321 return result; 1327 return result;
@@ -1334,7 +1340,7 @@ int atomctrl_get_smc_sclk_range_table(struct pp_hwmgr *hwmgr, struct pp_atom_ctr
1334 u16 size; 1340 u16 size;
1335 1341
1336 ATOM_SMU_INFO_V2_1 *psmu_info = 1342 ATOM_SMU_INFO_V2_1 *psmu_info =
1337 (ATOM_SMU_INFO_V2_1 *)cgs_atom_get_data_table(hwmgr->device, 1343 (ATOM_SMU_INFO_V2_1 *)smu_atom_get_data_table(hwmgr->adev,
1338 GetIndexIntoMasterTable(DATA, SMU_Info), 1344 GetIndexIntoMasterTable(DATA, SMU_Info),
1339 &size, &frev, &crev); 1345 &size, &frev, &crev);
1340 1346
@@ -1362,7 +1368,7 @@ int atomctrl_get_avfs_information(struct pp_hwmgr *hwmgr,
1362 return -EINVAL; 1368 return -EINVAL;
1363 1369
1364 profile = (ATOM_ASIC_PROFILING_INFO_V3_6 *) 1370 profile = (ATOM_ASIC_PROFILING_INFO_V3_6 *)
1365 cgs_atom_get_data_table(hwmgr->device, 1371 smu_atom_get_data_table(hwmgr->adev,
1366 GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo), 1372 GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo),
1367 NULL, NULL, NULL); 1373 NULL, NULL, NULL);
1368 if (!profile) 1374 if (!profile)
@@ -1402,7 +1408,7 @@ int atomctrl_get_svi2_info(struct pp_hwmgr *hwmgr, uint8_t voltage_type,
1402 uint16_t *load_line) 1408 uint16_t *load_line)
1403{ 1409{
1404 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info = 1410 ATOM_VOLTAGE_OBJECT_INFO_V3_1 *voltage_info =
1405 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->device); 1411 (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *)get_voltage_info_table(hwmgr->adev);
1406 1412
1407 const ATOM_VOLTAGE_OBJECT_V3 *voltage_object; 1413 const ATOM_VOLTAGE_OBJECT_V3 *voltage_object;
1408 1414
@@ -1421,16 +1427,17 @@ int atomctrl_get_svi2_info(struct pp_hwmgr *hwmgr, uint8_t voltage_type,
1421 1427
1422int atomctrl_get_leakage_id_from_efuse(struct pp_hwmgr *hwmgr, uint16_t *virtual_voltage_id) 1428int atomctrl_get_leakage_id_from_efuse(struct pp_hwmgr *hwmgr, uint16_t *virtual_voltage_id)
1423{ 1429{
1424 int result; 1430 struct amdgpu_device *adev = hwmgr->adev;
1425 SET_VOLTAGE_PS_ALLOCATION allocation; 1431 SET_VOLTAGE_PS_ALLOCATION allocation;
1426 SET_VOLTAGE_PARAMETERS_V1_3 *voltage_parameters = 1432 SET_VOLTAGE_PARAMETERS_V1_3 *voltage_parameters =
1427 (SET_VOLTAGE_PARAMETERS_V1_3 *)&allocation.sASICSetVoltage; 1433 (SET_VOLTAGE_PARAMETERS_V1_3 *)&allocation.sASICSetVoltage;
1434 int result;
1428 1435
1429 voltage_parameters->ucVoltageMode = ATOM_GET_LEAKAGE_ID; 1436 voltage_parameters->ucVoltageMode = ATOM_GET_LEAKAGE_ID;
1430 1437
1431 result = cgs_atom_exec_cmd_table(hwmgr->device, 1438 result = amdgpu_atom_execute_table(adev->mode_info.atom_context,
1432 GetIndexIntoMasterTable(COMMAND, SetVoltage), 1439 GetIndexIntoMasterTable(COMMAND, SetVoltage),
1433 voltage_parameters); 1440 (uint32_t *)voltage_parameters);
1434 1441
1435 *virtual_voltage_id = voltage_parameters->usVoltageLevel; 1442 *virtual_voltage_id = voltage_parameters->usVoltageLevel;
1436 1443
@@ -1453,7 +1460,7 @@ int atomctrl_get_leakage_vddc_base_on_leakage(struct pp_hwmgr *hwmgr,
1453 ix = GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo); 1460 ix = GetIndexIntoMasterTable(DATA, ASIC_ProfilingInfo);
1454 1461
1455 profile = (ATOM_ASIC_PROFILING_INFO_V2_1 *) 1462 profile = (ATOM_ASIC_PROFILING_INFO_V2_1 *)
1456 cgs_atom_get_data_table(hwmgr->device, 1463 smu_atom_get_data_table(hwmgr->adev,
1457 ix, 1464 ix,
1458 NULL, NULL, NULL); 1465 NULL, NULL, NULL);
1459 if (!profile) 1466 if (!profile)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h
index c44a92064cf1..c672a5069840 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h
@@ -298,7 +298,7 @@ extern int atomctrl_get_memory_pll_dividers_vi(struct pp_hwmgr *hwmgr,
298extern int atomctrl_get_engine_pll_dividers_kong(struct pp_hwmgr *hwmgr, 298extern int atomctrl_get_engine_pll_dividers_kong(struct pp_hwmgr *hwmgr,
299 uint32_t clock_value, 299 uint32_t clock_value,
300 pp_atomctrl_clock_dividers_kong *dividers); 300 pp_atomctrl_clock_dividers_kong *dividers);
301extern int atomctrl_read_efuse(void *device, uint16_t start_index, 301extern int atomctrl_read_efuse(struct pp_hwmgr *hwmgr, uint16_t start_index,
302 uint16_t end_index, uint32_t mask, uint32_t *efuse); 302 uint16_t end_index, uint32_t mask, uint32_t *efuse);
303extern int atomctrl_calculate_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, 303extern int atomctrl_calculate_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type,
304 uint32_t sclk, uint16_t virtual_voltage_Id, uint16_t *voltage, uint16_t dpm_level, bool debug); 304 uint32_t sclk, uint16_t virtual_voltage_Id, uint16_t *voltage, uint16_t dpm_level, bool debug);
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
index ad42caac033e..0adaf36b6d68 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
@@ -23,9 +23,9 @@
23 23
24#include "ppatomfwctrl.h" 24#include "ppatomfwctrl.h"
25#include "atomfirmware.h" 25#include "atomfirmware.h"
26#include "atom.h"
26#include "pp_debug.h" 27#include "pp_debug.h"
27 28
28
29static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4( 29static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4(
30 const struct atom_voltage_objects_info_v4_1 *voltage_object_info_table, 30 const struct atom_voltage_objects_info_v4_1 *voltage_object_info_table,
31 uint8_t voltage_type, uint8_t voltage_mode) 31 uint8_t voltage_type, uint8_t voltage_mode)
@@ -38,35 +38,34 @@ static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4(
38 38
39 while (offset < size) { 39 while (offset < size) {
40 const union atom_voltage_object_v4 *voltage_object = 40 const union atom_voltage_object_v4 *voltage_object =
41 (const union atom_voltage_object_v4 *)(start + offset); 41 (const union atom_voltage_object_v4 *)(start + offset);
42 42
43 if (voltage_type == voltage_object->gpio_voltage_obj.header.voltage_type && 43 if (voltage_type == voltage_object->gpio_voltage_obj.header.voltage_type &&
44 voltage_mode == voltage_object->gpio_voltage_obj.header.voltage_mode) 44 voltage_mode == voltage_object->gpio_voltage_obj.header.voltage_mode)
45 return voltage_object; 45 return voltage_object;
46 46
47 offset += le16_to_cpu(voltage_object->gpio_voltage_obj.header.object_size); 47 offset += le16_to_cpu(voltage_object->gpio_voltage_obj.header.object_size);
48 48
49 } 49 }
50 50
51 return NULL; 51 return NULL;
52} 52}
53 53
54static struct atom_voltage_objects_info_v4_1 *pp_atomfwctrl_get_voltage_info_table( 54static struct atom_voltage_objects_info_v4_1 *pp_atomfwctrl_get_voltage_info_table(
55 struct pp_hwmgr *hwmgr) 55 struct pp_hwmgr *hwmgr)
56{ 56{
57 const void *table_address; 57 const void *table_address;
58 uint16_t idx; 58 uint16_t idx;
59 59
60 idx = GetIndexIntoMasterDataTable(voltageobject_info); 60 idx = GetIndexIntoMasterDataTable(voltageobject_info);
61 table_address = cgs_atom_get_data_table(hwmgr->device, 61 table_address = smu_atom_get_data_table(hwmgr->adev,
62 idx, NULL, NULL, NULL); 62 idx, NULL, NULL, NULL);
63 63
64 PP_ASSERT_WITH_CODE( 64 PP_ASSERT_WITH_CODE(table_address,
65 table_address, 65 "Error retrieving BIOS Table Address!",
66 "Error retrieving BIOS Table Address!", 66 return NULL);
67 return NULL);
68 67
69 return (struct atom_voltage_objects_info_v4_1 *)table_address; 68 return (struct atom_voltage_objects_info_v4_1 *)table_address;
70} 69}
71 70
72/** 71/**
@@ -167,7 +166,7 @@ static struct atom_gpio_pin_lut_v2_1 *pp_atomfwctrl_get_gpio_lookup_table(
167 uint16_t idx; 166 uint16_t idx;
168 167
169 idx = GetIndexIntoMasterDataTable(gpio_pin_lut); 168 idx = GetIndexIntoMasterDataTable(gpio_pin_lut);
170 table_address = cgs_atom_get_data_table(hwmgr->device, 169 table_address = smu_atom_get_data_table(hwmgr->adev,
171 idx, NULL, NULL, NULL); 170 idx, NULL, NULL, NULL);
172 PP_ASSERT_WITH_CODE(table_address, 171 PP_ASSERT_WITH_CODE(table_address,
173 "Error retrieving BIOS Table Address!", 172 "Error retrieving BIOS Table Address!",
@@ -248,28 +247,30 @@ int pp_atomfwctrl_get_gpu_pll_dividers_vega10(struct pp_hwmgr *hwmgr,
248 uint32_t clock_type, uint32_t clock_value, 247 uint32_t clock_type, uint32_t clock_value,
249 struct pp_atomfwctrl_clock_dividers_soc15 *dividers) 248 struct pp_atomfwctrl_clock_dividers_soc15 *dividers)
250{ 249{
250 struct amdgpu_device *adev = hwmgr->adev;
251 struct compute_gpu_clock_input_parameter_v1_8 pll_parameters; 251 struct compute_gpu_clock_input_parameter_v1_8 pll_parameters;
252 struct compute_gpu_clock_output_parameter_v1_8 *pll_output; 252 struct compute_gpu_clock_output_parameter_v1_8 *pll_output;
253 int result;
254 uint32_t idx; 253 uint32_t idx;
255 254
256 pll_parameters.gpuclock_10khz = (uint32_t)clock_value; 255 pll_parameters.gpuclock_10khz = (uint32_t)clock_value;
257 pll_parameters.gpu_clock_type = clock_type; 256 pll_parameters.gpu_clock_type = clock_type;
258 257
259 idx = GetIndexIntoMasterCmdTable(computegpuclockparam); 258 idx = GetIndexIntoMasterCmdTable(computegpuclockparam);
260 result = cgs_atom_exec_cmd_table(hwmgr->device, idx, &pll_parameters); 259
261 260 if (amdgpu_atom_execute_table(
262 if (!result) { 261 adev->mode_info.atom_context, idx, (uint32_t *)&pll_parameters))
263 pll_output = (struct compute_gpu_clock_output_parameter_v1_8 *) 262 return -EINVAL;
264 &pll_parameters; 263
265 dividers->ulClock = le32_to_cpu(pll_output->gpuclock_10khz); 264 pll_output = (struct compute_gpu_clock_output_parameter_v1_8 *)
266 dividers->ulDid = le32_to_cpu(pll_output->dfs_did); 265 &pll_parameters;
267 dividers->ulPll_fb_mult = le32_to_cpu(pll_output->pll_fb_mult); 266 dividers->ulClock = le32_to_cpu(pll_output->gpuclock_10khz);
268 dividers->ulPll_ss_fbsmult = le32_to_cpu(pll_output->pll_ss_fbsmult); 267 dividers->ulDid = le32_to_cpu(pll_output->dfs_did);
269 dividers->usPll_ss_slew_frac = le16_to_cpu(pll_output->pll_ss_slew_frac); 268 dividers->ulPll_fb_mult = le32_to_cpu(pll_output->pll_fb_mult);
270 dividers->ucPll_ss_enable = pll_output->pll_ss_enable; 269 dividers->ulPll_ss_fbsmult = le32_to_cpu(pll_output->pll_ss_fbsmult);
271 } 270 dividers->usPll_ss_slew_frac = le16_to_cpu(pll_output->pll_ss_slew_frac);
272 return result; 271 dividers->ucPll_ss_enable = pll_output->pll_ss_enable;
272
273 return 0;
273} 274}
274 275
275int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr, 276int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr,
@@ -283,7 +284,7 @@ int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr,
283 284
284 idx = GetIndexIntoMasterDataTable(asic_profiling_info); 285 idx = GetIndexIntoMasterDataTable(asic_profiling_info);
285 profile = (struct atom_asic_profiling_info_v4_1 *) 286 profile = (struct atom_asic_profiling_info_v4_1 *)
286 cgs_atom_get_data_table(hwmgr->device, 287 smu_atom_get_data_table(hwmgr->adev,
287 idx, NULL, NULL, NULL); 288 idx, NULL, NULL, NULL);
288 289
289 if (!profile) 290 if (!profile)
@@ -467,7 +468,7 @@ int pp_atomfwctrl_get_gpio_information(struct pp_hwmgr *hwmgr,
467 468
468 idx = GetIndexIntoMasterDataTable(smu_info); 469 idx = GetIndexIntoMasterDataTable(smu_info);
469 info = (struct atom_smu_info_v3_1 *) 470 info = (struct atom_smu_info_v3_1 *)
470 cgs_atom_get_data_table(hwmgr->device, 471 smu_atom_get_data_table(hwmgr->adev,
471 idx, NULL, NULL, NULL); 472 idx, NULL, NULL, NULL);
472 473
473 if (!info) { 474 if (!info) {
@@ -489,6 +490,7 @@ int pp_atomfwctrl_get_gpio_information(struct pp_hwmgr *hwmgr,
489 490
490int pp_atomfwctrl__get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKID id, uint32_t *frequency) 491int pp_atomfwctrl__get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKID id, uint32_t *frequency)
491{ 492{
493 struct amdgpu_device *adev = hwmgr->adev;
492 struct atom_get_smu_clock_info_parameters_v3_1 parameters; 494 struct atom_get_smu_clock_info_parameters_v3_1 parameters;
493 struct atom_get_smu_clock_info_output_parameters_v3_1 *output; 495 struct atom_get_smu_clock_info_output_parameters_v3_1 *output;
494 uint32_t ix; 496 uint32_t ix;
@@ -497,13 +499,13 @@ int pp_atomfwctrl__get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLK
497 parameters.command = GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ; 499 parameters.command = GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ;
498 500
499 ix = GetIndexIntoMasterCmdTable(getsmuclockinfo); 501 ix = GetIndexIntoMasterCmdTable(getsmuclockinfo);
500 if (!cgs_atom_exec_cmd_table(hwmgr->device, ix, &parameters)) { 502
501 output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&parameters; 503 if (amdgpu_atom_execute_table(
502 *frequency = output->atom_smu_outputclkfreq.smu_clock_freq_hz / 10000; 504 adev->mode_info.atom_context, ix, (uint32_t *)&parameters))
503 } else { 505 return -EINVAL;
504 pr_info("Error execute_table getsmuclockinfo!"); 506
505 return -1; 507 output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&parameters;
506 } 508 *frequency = output->atom_smu_outputclkfreq.smu_clock_freq_hz / 10000;
507 509
508 return 0; 510 return 0;
509} 511}
@@ -517,7 +519,7 @@ int pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr *hwmgr,
517 519
518 ix = GetIndexIntoMasterDataTable(firmwareinfo); 520 ix = GetIndexIntoMasterDataTable(firmwareinfo);
519 info = (struct atom_firmware_info_v3_1 *) 521 info = (struct atom_firmware_info_v3_1 *)
520 cgs_atom_get_data_table(hwmgr->device, 522 smu_atom_get_data_table(hwmgr->adev,
521 ix, NULL, NULL, NULL); 523 ix, NULL, NULL, NULL);
522 524
523 if (!info) { 525 if (!info) {
@@ -553,7 +555,7 @@ int pp_atomfwctrl_get_smc_dpm_information(struct pp_hwmgr *hwmgr,
553 555
554 ix = GetIndexIntoMasterDataTable(smc_dpm_info); 556 ix = GetIndexIntoMasterDataTable(smc_dpm_info);
555 info = (struct atom_smc_dpm_info_v4_1 *) 557 info = (struct atom_smc_dpm_info_v4_1 *)
556 cgs_atom_get_data_table(hwmgr->device, 558 smu_atom_get_data_table(hwmgr->adev,
557 ix, NULL, NULL, NULL); 559 ix, NULL, NULL, NULL);
558 if (!info) { 560 if (!info) {
559 pr_info("Error retrieving BIOS Table Address!"); 561 pr_info("Error retrieving BIOS Table Address!");
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
index c9eecce5683f..8516516eb6cc 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
@@ -141,7 +141,7 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)
141 141
142 if (!table_address) { 142 if (!table_address) {
143 table_address = (ATOM_Tonga_POWERPLAYTABLE *) 143 table_address = (ATOM_Tonga_POWERPLAYTABLE *)
144 cgs_atom_get_data_table(hwmgr->device, 144 smu_atom_get_data_table(hwmgr->adev,
145 index, &size, &frev, &crev); 145 index, &size, &frev, &crev);
146 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/ 146 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/
147 hwmgr->soft_pp_table_size = size; 147 hwmgr->soft_pp_table_size = size;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
index 36ca7c419c90..ce64dfabd34b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
@@ -837,7 +837,7 @@ static const ATOM_PPLIB_POWERPLAYTABLE *get_powerplay_table(
837 hwmgr->soft_pp_table = &soft_dummy_pp_table[0]; 837 hwmgr->soft_pp_table = &soft_dummy_pp_table[0];
838 hwmgr->soft_pp_table_size = sizeof(soft_dummy_pp_table); 838 hwmgr->soft_pp_table_size = sizeof(soft_dummy_pp_table);
839 } else { 839 } else {
840 table_addr = cgs_atom_get_data_table(hwmgr->device, 840 table_addr = smu_atom_get_data_table(hwmgr->adev,
841 GetIndexIntoMasterTable(DATA, PowerPlayInfo), 841 GetIndexIntoMasterTable(DATA, PowerPlayInfo),
842 &size, &frev, &crev); 842 &size, &frev, &crev);
843 hwmgr->soft_pp_table = table_addr; 843 hwmgr->soft_pp_table = table_addr;
@@ -1058,7 +1058,7 @@ static int init_overdrive_limits(struct pp_hwmgr *hwmgr,
1058 return 0; 1058 return 0;
1059 1059
1060 /* We assume here that fw_info is unchanged if this call fails.*/ 1060 /* We assume here that fw_info is unchanged if this call fails.*/
1061 fw_info = cgs_atom_get_data_table(hwmgr->device, 1061 fw_info = smu_atom_get_data_table(hwmgr->adev,
1062 GetIndexIntoMasterTable(DATA, FirmwareInfo), 1062 GetIndexIntoMasterTable(DATA, FirmwareInfo),
1063 &size, &frev, &crev); 1063 &size, &frev, &crev);
1064 1064
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index add90675fd2a..9087ef91b50b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2957,8 +2957,7 @@ static int smu7_dpm_patch_boot_state(struct pp_hwmgr *hwmgr,
2957 /* First retrieve the Boot clocks and VDDC from the firmware info table. 2957 /* First retrieve the Boot clocks and VDDC from the firmware info table.
2958 * We assume here that fw_info is unchanged if this call fails. 2958 * We assume here that fw_info is unchanged if this call fails.
2959 */ 2959 */
2960 fw_info = (ATOM_FIRMWARE_INFO_V2_2 *)cgs_atom_get_data_table( 2960 fw_info = (ATOM_FIRMWARE_INFO_V2_2 *)smu_atom_get_data_table(hwmgr->adev, index,
2961 hwmgr->device, index,
2962 &size, &frev, &crev); 2961 &size, &frev, &crev);
2963 if (!fw_info) 2962 if (!fw_info)
2964 /* During a test, there is no firmware info table. */ 2963 /* During a test, there is no firmware info table. */
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c
index 7b26607c646a..3ac07fabbe5c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c
@@ -314,8 +314,7 @@ static int smu8_get_system_info_data(struct pp_hwmgr *hwmgr)
314 uint8_t frev, crev; 314 uint8_t frev, crev;
315 uint16_t size; 315 uint16_t size;
316 316
317 info = (ATOM_INTEGRATED_SYSTEM_INFO_V1_9 *) cgs_atom_get_data_table( 317 info = (ATOM_INTEGRATED_SYSTEM_INFO_V1_9 *)smu_atom_get_data_table(hwmgr->adev,
318 hwmgr->device,
319 GetIndexIntoMasterTable(DATA, IntegratedSystemInfo), 318 GetIndexIntoMasterTable(DATA, IntegratedSystemInfo),
320 &size, &frev, &crev); 319 &size, &frev, &crev);
321 320
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
index 598122854ab5..529be3cd768a 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
@@ -24,6 +24,7 @@
24#include "pp_debug.h" 24#include "pp_debug.h"
25#include "ppatomctrl.h" 25#include "ppatomctrl.h"
26#include "ppsmc.h" 26#include "ppsmc.h"
27#include "atom.h"
27 28
28uint8_t convert_to_vid(uint16_t vddc) 29uint8_t convert_to_vid(uint16_t vddc)
29{ 30{
@@ -608,3 +609,18 @@ int smu9_register_irq_handlers(struct pp_hwmgr *hwmgr)
608 609
609 return 0; 610 return 0;
610} 611}
612
613void *smu_atom_get_data_table(void *dev, uint32_t table, uint16_t *size,
614 uint8_t *frev, uint8_t *crev)
615{
616 struct amdgpu_device *adev = dev;
617 uint16_t data_start;
618
619 if (amdgpu_atom_parse_data_header(
620 adev->mode_info.atom_context, table, size,
621 frev, crev, &data_start))
622 return (uint8_t *)adev->mode_info.atom_context->bios +
623 data_start;
624
625 return NULL;
626}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h
index d37d16e4b613..14ee162ac92a 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h
@@ -82,6 +82,9 @@ int phm_irq_process(struct amdgpu_device *adev,
82 82
83int smu9_register_irq_handlers(struct pp_hwmgr *hwmgr); 83int smu9_register_irq_handlers(struct pp_hwmgr *hwmgr);
84 84
85void *smu_atom_get_data_table(void *dev, uint32_t table, uint16_t *size,
86 uint8_t *frev, uint8_t *crev);
87
85#define PHM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT 88#define PHM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT
86#define PHM_FIELD_MASK(reg, field) reg##__##field##_MASK 89#define PHM_FIELD_MASK(reg, field) reg##__##field##_MASK
87 90
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index c61d0744860d..0768d259c07c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -52,7 +52,7 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)
52 52
53 if (!table_address) { 53 if (!table_address) {
54 table_address = (ATOM_Vega10_POWERPLAYTABLE *) 54 table_address = (ATOM_Vega10_POWERPLAYTABLE *)
55 cgs_atom_get_data_table(hwmgr->device, index, 55 smu_atom_get_data_table(hwmgr->adev, index,
56 &size, &frev, &crev); 56 &size, &frev, &crev);
57 57
58 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/ 58 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c
index b34113f45904..7fa1ba89ac54 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c
@@ -51,7 +51,7 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)
51 51
52 if (!table_address) { 52 if (!table_address) {
53 table_address = (ATOM_Vega12_POWERPLAYTABLE *) 53 table_address = (ATOM_Vega12_POWERPLAYTABLE *)
54 cgs_atom_get_data_table(hwmgr->device, index, 54 smu_atom_get_data_table(hwmgr->adev, index,
55 &size, &frev, &crev); 55 &size, &frev, &crev);
56 56
57 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/ 57 hwmgr->soft_pp_table = table_address; /*Cache the result in RAM.*/
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
index 35b947e5292c..1eec527add99 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
@@ -337,7 +337,7 @@ static bool fiji_is_hw_avfs_present(struct pp_hwmgr *hwmgr)
337 if (!hwmgr->not_vf) 337 if (!hwmgr->not_vf)
338 return false; 338 return false;
339 339
340 if (!atomctrl_read_efuse(hwmgr->device, AVFS_EN_LSB, AVFS_EN_MSB, 340 if (!atomctrl_read_efuse(hwmgr, AVFS_EN_LSB, AVFS_EN_MSB,
341 mask, &efuse)) { 341 mask, &efuse)) {
342 if (efuse) 342 if (efuse)
343 return true; 343 return true;