aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c6
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c1
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c4
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c146
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h5
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c137
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h13
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/smumgr.h6
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c6
11 files changed, 55 insertions, 274 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
index ce378bd21661..a3991c0dff2e 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
@@ -306,8 +306,10 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRa
306 range.min = temperature_range->min; 306 range.min = temperature_range->min;
307 } 307 }
308 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, 308 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
309 PHM_PlatformCaps_ThermalController)) 309 PHM_PlatformCaps_ThermalController)
310 return phm_dispatch_table(hwmgr, &(hwmgr->start_thermal_controller), &range, NULL); 310 && hwmgr->hwmgr_func->start_thermal_controller != NULL)
311 return hwmgr->hwmgr_func->start_thermal_controller(hwmgr, &range);
312
311 return 0; 313 return 0;
312} 314}
313 315
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 4f1b932361b2..387d0b62100c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -73,6 +73,7 @@ int hwmgr_early_init(struct pp_instance *handle)
73 hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; 73 hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO;
74 hwmgr_init_default_caps(hwmgr); 74 hwmgr_init_default_caps(hwmgr);
75 hwmgr_set_user_specify_caps(hwmgr); 75 hwmgr_set_user_specify_caps(hwmgr);
76 hwmgr->fan_ctrl_is_in_default_mode = true;
76 77
77 switch (hwmgr->chip_family) { 78 switch (hwmgr->chip_family) {
78 case AMDGPU_FAMILY_CZ: 79 case AMDGPU_FAMILY_CZ:
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index dfe06d98304c..c631b1926be7 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2284,7 +2284,6 @@ static int smu7_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
2284{ 2284{
2285 kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl); 2285 kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl);
2286 hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; 2286 hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL;
2287 pp_smu7_thermal_fini(hwmgr);
2288 kfree(hwmgr->backend); 2287 kfree(hwmgr->backend);
2289 hwmgr->backend = NULL; 2288 hwmgr->backend = NULL;
2290 2289
@@ -2301,8 +2300,6 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
2301 return -ENOMEM; 2300 return -ENOMEM;
2302 2301
2303 hwmgr->backend = data; 2302 hwmgr->backend = data;
2304 pp_smu7_thermal_initialize(hwmgr);
2305
2306 smu7_patch_voltage_workaround(hwmgr); 2303 smu7_patch_voltage_workaround(hwmgr);
2307 smu7_init_dpm_defaults(hwmgr); 2304 smu7_init_dpm_defaults(hwmgr);
2308 2305
@@ -4661,6 +4658,7 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
4661 .set_power_profile_state = smu7_set_power_profile_state, 4658 .set_power_profile_state = smu7_set_power_profile_state,
4662 .avfs_control = smu7_avfs_control, 4659 .avfs_control = smu7_avfs_control,
4663 .disable_smc_firmware_ctf = smu7_thermal_disable_alert, 4660 .disable_smc_firmware_ctf = smu7_thermal_disable_alert,
4661 .start_thermal_controller = smu7_start_thermal_controller,
4664}; 4662};
4665 4663
4666uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, 4664uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
index a457b884dd7d..10e12b2b4385 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
@@ -360,7 +360,7 @@ static int smu7_thermal_initialize(struct pp_hwmgr *hwmgr)
360* 360*
361* @param hwmgr The address of the hardware manager. 361* @param hwmgr The address of the hardware manager.
362*/ 362*/
363int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr) 363static void smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr)
364{ 364{
365 uint32_t alert; 365 uint32_t alert;
366 366
@@ -371,7 +371,7 @@ int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr)
371 CG_THERMAL_INT, THERM_INT_MASK, alert); 371 CG_THERMAL_INT, THERM_INT_MASK, alert);
372 372
373 /* send message to SMU to enable internal thermal interrupts */ 373 /* send message to SMU to enable internal thermal interrupts */
374 return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable); 374 smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable);
375} 375}
376 376
377/** 377/**
@@ -416,8 +416,7 @@ int smu7_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
416* @param Result the last failure code 416* @param Result the last failure code
417* @return result from set temperature range routine 417* @return result from set temperature range routine
418*/ 418*/
419static int tf_smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, 419static int smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr)
420 void *input, void *output, void *storage, int result)
421{ 420{
422/* If the fantable setup has failed we could have disabled 421/* If the fantable setup has failed we could have disabled
423 * PHM_PlatformCaps_MicrocodeFanControl even after 422 * PHM_PlatformCaps_MicrocodeFanControl even after
@@ -432,108 +431,34 @@ static int tf_smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr,
432 return 0; 431 return 0;
433} 432}
434 433
435/** 434int smu7_start_thermal_controller(struct pp_hwmgr *hwmgr,
436* Set temperature range for high and low alerts 435 struct PP_TemperatureRange *range)
437* @param hwmgr the address of the powerplay hardware manager.
438* @param pInput the pointer to input data
439* @param pOutput the pointer to output data
440* @param pStorage the pointer to temporary storage
441* @param Result the last failure code
442* @return result from set temperature range routine
443*/
444static int tf_smu7_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
445 void *input, void *output, void *storage, int result)
446{ 436{
447 struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input; 437 int ret = 0;
448 438
449 if (range == NULL) 439 if (range == NULL)
450 return -EINVAL; 440 return -EINVAL;
451 441
452 return smu7_thermal_set_temperature_range(hwmgr, range->min, range->max); 442 smu7_thermal_initialize(hwmgr);
453} 443 ret = smu7_thermal_set_temperature_range(hwmgr, range->min, range->max);
454 444 if (ret)
455/** 445 return -EINVAL;
456* Programs one-time setting registers 446 smu7_thermal_enable_alert(hwmgr);
457* @param hwmgr the address of the powerplay hardware manager. 447 ret = smum_thermal_avfs_enable(hwmgr);
458* @param pInput the pointer to input data 448 if (ret)
459* @param pOutput the pointer to output data 449 return -EINVAL;
460* @param pStorage the pointer to temporary storage
461* @param Result the last failure code
462* @return result from initialize thermal controller routine
463*/
464static int tf_smu7_thermal_initialize(struct pp_hwmgr *hwmgr,
465 void *input, void *output, void *storage, int result)
466{
467 return smu7_thermal_initialize(hwmgr);
468}
469
470/**
471* Enable high and low alerts
472* @param hwmgr the address of the powerplay hardware manager.
473* @param pInput the pointer to input data
474* @param pOutput the pointer to output data
475* @param pStorage the pointer to temporary storage
476* @param Result the last failure code
477* @return result from enable alert routine
478*/
479static int tf_smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr,
480 void *input, void *output, void *storage, int result)
481{
482 return smu7_thermal_enable_alert(hwmgr);
483}
484
485/**
486* Disable high and low alerts
487* @param hwmgr the address of the powerplay hardware manager.
488* @param pInput the pointer to input data
489* @param pOutput the pointer to output data
490* @param pStorage the pointer to temporary storage
491* @param Result the last failure code
492* @return result from disable alert routine
493*/
494static int tf_smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr,
495 void *input, void *output, void *storage, int result)
496{
497 return smu7_thermal_disable_alert(hwmgr);
498}
499 450
500static const struct phm_master_table_item
501phm_thermal_start_thermal_controller_master_list[] = {
502 { .tableFunction = tf_smu7_thermal_initialize },
503 { .tableFunction = tf_smu7_thermal_set_temperature_range },
504 { .tableFunction = tf_smu7_thermal_enable_alert },
505 { .tableFunction = smum_thermal_avfs_enable },
506/* We should restrict performance levels to low before we halt the SMC. 451/* We should restrict performance levels to low before we halt the SMC.
507 * On the other hand we are still in boot state when we do this 452 * On the other hand we are still in boot state when we do this
508 * so it would be pointless. 453 * so it would be pointless.
509 * If this assumption changes we have to revisit this table. 454 * If this assumption changes we have to revisit this table.
510 */ 455 */
511 { .tableFunction = smum_thermal_setup_fan_table }, 456 smum_thermal_setup_fan_table(hwmgr);
512 { .tableFunction = tf_smu7_thermal_start_smc_fan_control }, 457 smu7_thermal_start_smc_fan_control(hwmgr);
513 { } 458 return 0;
514}; 459}
515 460
516static const struct phm_master_table_header 461
517phm_thermal_start_thermal_controller_master = {
518 0,
519 PHM_MasterTableFlag_None,
520 phm_thermal_start_thermal_controller_master_list
521};
522
523static const struct phm_master_table_item
524phm_thermal_set_temperature_range_master_list[] = {
525 { .tableFunction = tf_smu7_thermal_disable_alert },
526 { .tableFunction = tf_smu7_thermal_set_temperature_range },
527 { .tableFunction = tf_smu7_thermal_enable_alert },
528 { }
529};
530
531static const struct phm_master_table_header
532phm_thermal_set_temperature_range_master = {
533 0,
534 PHM_MasterTableFlag_None,
535 phm_thermal_set_temperature_range_master_list
536};
537 462
538int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) 463int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
539{ 464{
@@ -542,34 +467,3 @@ int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
542 return 0; 467 return 0;
543} 468}
544 469
545/**
546* Initializes the thermal controller related functions in the Hardware Manager structure.
547* @param hwmgr The address of the hardware manager.
548* @exception Any error code from the low-level communication.
549*/
550int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr)
551{
552 int result;
553
554 result = phm_construct_table(hwmgr,
555 &phm_thermal_set_temperature_range_master,
556 &(hwmgr->set_temperature_range));
557
558 if (!result) {
559 result = phm_construct_table(hwmgr,
560 &phm_thermal_start_thermal_controller_master,
561 &(hwmgr->start_thermal_controller));
562 if (result)
563 phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range));
564 }
565
566 if (!result)
567 hwmgr->fan_ctrl_is_in_default_mode = true;
568 return result;
569}
570
571void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr)
572{
573 phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range));
574 phm_destroy_table(hwmgr, &(hwmgr->start_thermal_controller));
575}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
index ba71b608fa75..42c1ba0fad78 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
@@ -46,14 +46,13 @@ extern int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr);
46extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode); 46extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode);
47extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed); 47extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed);
48extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); 48extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr);
49extern int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr);
50extern void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr);
51extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr); 49extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr);
52extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed); 50extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed);
53extern int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed); 51extern int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed);
54extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); 52extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
55extern int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr);
56extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr); 53extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr);
57extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); 54extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);
55extern int smu7_start_thermal_controller(struct pp_hwmgr *hwmgr,
56 struct PP_TemperatureRange *temperature_range);
58#endif 57#endif
59 58
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index 4d7bd9fc91a8..0eb3c2907de9 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5060,6 +5060,6 @@ int vega10_hwmgr_init(struct pp_hwmgr *hwmgr)
5060{ 5060{
5061 hwmgr->hwmgr_func = &vega10_hwmgr_funcs; 5061 hwmgr->hwmgr_func = &vega10_hwmgr_funcs;
5062 hwmgr->pptable_func = &vega10_pptable_funcs; 5062 hwmgr->pptable_func = &vega10_pptable_funcs;
5063 pp_vega10_thermal_initialize(hwmgr); 5063
5064 return 0; 5064 return 0;
5065} 5065}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
index 5b3c443d4e94..ce873e40a8fd 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
@@ -528,8 +528,7 @@ int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
528* @param Result the last failure code 528* @param Result the last failure code
529* @return result from set temperature range routine 529* @return result from set temperature range routine
530*/ 530*/
531int tf_vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, 531int vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
532 void *input, void *output, void *storage, int result)
533{ 532{
534 int ret; 533 int ret;
535 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); 534 struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
@@ -593,8 +592,7 @@ int tf_vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr,
593* @param Result the last failure code 592* @param Result the last failure code
594* @return result from set temperature range routine 593* @return result from set temperature range routine
595*/ 594*/
596int tf_vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, 595int vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr)
597 void *input, void *output, void *storage, int result)
598{ 596{
599/* If the fantable setup has failed we could have disabled 597/* If the fantable setup has failed we could have disabled
600 * PHM_PlatformCaps_MicrocodeFanControl even after 598 * PHM_PlatformCaps_MicrocodeFanControl even after
@@ -607,107 +605,37 @@ int tf_vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr,
607 return 0; 605 return 0;
608} 606}
609 607
610/** 608
611* Set temperature range for high and low alerts 609int vega10_start_thermal_controller(struct pp_hwmgr *hwmgr,
612* @param hwmgr the address of the powerplay hardware manager. 610 struct PP_TemperatureRange *range)
613* @param pInput the pointer to input data
614* @param pOutput the pointer to output data
615* @param pStorage the pointer to temporary storage
616* @param Result the last failure code
617* @return result from set temperature range routine
618*/
619int tf_vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
620 void *input, void *output, void *storage, int result)
621{ 611{
622 struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input; 612 int ret = 0;
623 613
624 if (range == NULL) 614 if (range == NULL)
625 return -EINVAL; 615 return -EINVAL;
626 616
627 return vega10_thermal_set_temperature_range(hwmgr, range); 617 vega10_thermal_initialize(hwmgr);
628} 618 ret = vega10_thermal_set_temperature_range(hwmgr, range);
629 619 if (ret)
630/** 620 return -EINVAL;
631* Programs one-time setting registers
632* @param hwmgr the address of the powerplay hardware manager.
633* @param pInput the pointer to input data
634* @param pOutput the pointer to output data
635* @param pStorage the pointer to temporary storage
636* @param Result the last failure code
637* @return result from initialize thermal controller routine
638*/
639int tf_vega10_thermal_initialize(struct pp_hwmgr *hwmgr,
640 void *input, void *output, void *storage, int result)
641{
642 return vega10_thermal_initialize(hwmgr);
643}
644
645/**
646* Enable high and low alerts
647* @param hwmgr the address of the powerplay hardware manager.
648* @param pInput the pointer to input data
649* @param pOutput the pointer to output data
650* @param pStorage the pointer to temporary storage
651* @param Result the last failure code
652* @return result from enable alert routine
653*/
654int tf_vega10_thermal_enable_alert(struct pp_hwmgr *hwmgr,
655 void *input, void *output, void *storage, int result)
656{
657 return vega10_thermal_enable_alert(hwmgr);
658}
659
660/**
661* Disable high and low alerts
662* @param hwmgr the address of the powerplay hardware manager.
663* @param pInput the pointer to input data
664* @param pOutput the pointer to output data
665* @param pStorage the pointer to temporary storage
666* @param Result the last failure code
667* @return result from disable alert routine
668*/
669static int tf_vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr,
670 void *input, void *output, void *storage, int result)
671{
672 return vega10_thermal_disable_alert(hwmgr);
673}
674 621
675static struct phm_master_table_item 622 vega10_thermal_enable_alert(hwmgr);
676vega10_thermal_start_thermal_controller_master_list[] = {
677 { .tableFunction = tf_vega10_thermal_initialize },
678 { .tableFunction = tf_vega10_thermal_set_temperature_range },
679 { .tableFunction = tf_vega10_thermal_enable_alert },
680/* We should restrict performance levels to low before we halt the SMC. 623/* We should restrict performance levels to low before we halt the SMC.
681 * On the other hand we are still in boot state when we do this 624 * On the other hand we are still in boot state when we do this
682 * so it would be pointless. 625 * so it would be pointless.
683 * If this assumption changes we have to revisit this table. 626 * If this assumption changes we have to revisit this table.
684 */ 627 */
685 { .tableFunction = tf_vega10_thermal_setup_fan_table }, 628 ret = vega10_thermal_setup_fan_table(hwmgr);
686 { .tableFunction = tf_vega10_thermal_start_smc_fan_control }, 629 if (ret)
687 { } 630 return -EINVAL;
688};
689 631
690static struct phm_master_table_header 632 vega10_thermal_start_smc_fan_control(hwmgr);
691vega10_thermal_start_thermal_controller_master = {
692 0,
693 PHM_MasterTableFlag_None,
694 vega10_thermal_start_thermal_controller_master_list
695};
696 633
697static struct phm_master_table_item 634 return 0;
698vega10_thermal_set_temperature_range_master_list[] = {
699 { .tableFunction = tf_vega10_thermal_disable_alert },
700 { .tableFunction = tf_vega10_thermal_set_temperature_range },
701 { .tableFunction = tf_vega10_thermal_enable_alert },
702 { }
703}; 635};
704 636
705struct phm_master_table_header 637
706vega10_thermal_set_temperature_range_master = { 638
707 0,
708 PHM_MasterTableFlag_None,
709 vega10_thermal_set_temperature_range_master_list
710};
711 639
712int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) 640int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
713{ 641{
@@ -717,32 +645,3 @@ int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
717 } 645 }
718 return 0; 646 return 0;
719} 647}
720
721/**
722* Initializes the thermal controller related functions
723* in the Hardware Manager structure.
724* @param hwmgr The address of the hardware manager.
725* @exception Any error code from the low-level communication.
726*/
727int pp_vega10_thermal_initialize(struct pp_hwmgr *hwmgr)
728{
729 int result;
730
731 result = phm_construct_table(hwmgr,
732 &vega10_thermal_set_temperature_range_master,
733 &(hwmgr->set_temperature_range));
734
735 if (!result) {
736 result = phm_construct_table(hwmgr,
737 &vega10_thermal_start_thermal_controller_master,
738 &(hwmgr->start_thermal_controller));
739 if (result)
740 phm_destroy_table(hwmgr,
741 &(hwmgr->set_temperature_range));
742 }
743
744 if (!result)
745 hwmgr->fan_ctrl_is_in_default_mode = true;
746 return result;
747}
748
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h
index 776f3a2effc0..f34ce04cfd89 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h
@@ -50,13 +50,6 @@ struct vega10_temperature {
50#define FDO_PWM_MODE_STATIC_RPM 5 50#define FDO_PWM_MODE_STATIC_RPM 5
51 51
52 52
53extern int tf_vega10_thermal_initialize(struct pp_hwmgr *hwmgr,
54 void *input, void *output, void *storage, int result);
55extern int tf_vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
56 void *input, void *output, void *storage, int result);
57extern int tf_vega10_thermal_enable_alert(struct pp_hwmgr *hwmgr,
58 void *input, void *output, void *storage, int result);
59
60extern int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr); 53extern int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr);
61extern int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); 54extern int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr);
62extern int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, 55extern int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,
@@ -69,7 +62,6 @@ extern int vega10_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr,
69extern int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 62extern int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr,
70 uint32_t speed); 63 uint32_t speed);
71extern int vega10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); 64extern int vega10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr);
72extern int pp_vega10_thermal_initialize(struct pp_hwmgr *hwmgr);
73extern int vega10_thermal_ctrl_uninitialize_thermal_controller( 65extern int vega10_thermal_ctrl_uninitialize_thermal_controller(
74 struct pp_hwmgr *hwmgr); 66 struct pp_hwmgr *hwmgr);
75extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, 67extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr,
@@ -77,9 +69,10 @@ extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr,
77extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, 69extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr,
78 uint32_t *speed); 70 uint32_t *speed);
79extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); 71extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
80extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr);
81extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr); 72extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr);
82int vega10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); 73extern int vega10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);
74
75extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr);
83 76
84#endif 77#endif
85 78
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 3bbe7d5cb6de..831add448614 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -380,6 +380,7 @@ struct pp_hwmgr_func {
380 int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr); 380 int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr);
381 int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count); 381 int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count);
382 int (*set_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock); 382 int (*set_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock);
383 int (*start_thermal_controller)(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range);
383}; 384};
384 385
385struct pp_table_func { 386struct pp_table_func {
@@ -766,8 +767,6 @@ struct pp_hwmgr {
766 struct phm_runtime_table_header set_power_state; 767 struct phm_runtime_table_header set_power_state;
767 struct phm_runtime_table_header enable_clock_power_gatings; 768 struct phm_runtime_table_header enable_clock_power_gatings;
768 struct phm_runtime_table_header display_configuration_changed; 769 struct phm_runtime_table_header display_configuration_changed;
769 struct phm_runtime_table_header start_thermal_controller;
770 struct phm_runtime_table_header set_temperature_range;
771 const struct pp_hwmgr_func *hwmgr_func; 770 const struct pp_hwmgr_func *hwmgr_func;
772 const struct pp_table_func *pptable_func; 771 const struct pp_table_func *pptable_func;
773 struct pp_power_state *ps; 772 struct pp_power_state *ps;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
index 5d61cc9d4554..eb6609116a7a 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
@@ -186,10 +186,8 @@ extern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr);
186 186
187extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type); 187extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type);
188extern int smum_process_firmware_header(struct pp_hwmgr *hwmgr); 188extern int smum_process_firmware_header(struct pp_hwmgr *hwmgr);
189extern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, 189extern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr);
190 void *input, void *output, void *storage, int result); 190extern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr);
191extern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr,
192 void *input, void *output, void *storage, int result);
193extern int smum_init_smc_table(struct pp_hwmgr *hwmgr); 191extern int smum_init_smc_table(struct pp_hwmgr *hwmgr);
194extern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr); 192extern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr);
195extern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr); 193extern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr);
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index e397349ce1c9..4527c07bc679 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -114,8 +114,7 @@ int smum_early_init(struct pp_instance *handle)
114 return 0; 114 return 0;
115} 115}
116 116
117int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, 117int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr)
118 void *input, void *output, void *storage, int result)
119{ 118{
120 if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable) 119 if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable)
121 return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr); 120 return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr);
@@ -123,8 +122,7 @@ int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr,
123 return 0; 122 return 0;
124} 123}
125 124
126int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, 125int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
127 void *input, void *output, void *storage, int result)
128{ 126{
129 if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table) 127 if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table)
130 return hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table(hwmgr); 128 return hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table(hwmgr);