2015-07-21 16:43:02 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
2017-05-18 11:43:32 +07:00
|
|
|
|
|
|
|
#include <linux/delay.h>
|
2015-07-21 16:43:02 +07:00
|
|
|
#include <linux/kernel.h>
|
2017-01-04 05:36:04 +07:00
|
|
|
#include <linux/module.h>
|
2015-07-21 16:43:02 +07:00
|
|
|
#include <linux/slab.h>
|
2017-05-18 11:43:32 +07:00
|
|
|
#include <linux/types.h>
|
2016-07-06 21:01:39 +07:00
|
|
|
#include <drm/amdgpu_drm.h>
|
2015-07-21 16:43:02 +07:00
|
|
|
#include "smumgr.h"
|
|
|
|
|
2019-02-14 03:07:06 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/bonaire_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/bonaire_k_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/hawaii_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/hawaii_k_smc.bin");
|
2017-01-04 05:36:04 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/topaz_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/topaz_k_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/tonga_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/tonga_k_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/fiji_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/polaris10_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin");
|
2017-02-09 10:35:51 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris10_k_smc.bin");
|
2018-10-17 23:24:26 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris10_k2_smc.bin");
|
2017-01-04 05:36:04 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris11_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin");
|
2017-02-09 10:35:51 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris11_k_smc.bin");
|
2018-10-17 23:24:26 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris11_k2_smc.bin");
|
2017-01-04 05:36:04 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris12_smc.bin");
|
2018-10-17 23:24:26 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/polaris12_k_smc.bin");
|
2017-11-10 01:24:47 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/vegam_smc.bin");
|
2017-06-23 14:08:15 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_smc.bin");
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin");
|
2018-03-20 02:11:09 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/vega12_smc.bin");
|
2018-04-20 11:46:21 +07:00
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_smc.bin");
|
2016-12-29 14:23:44 +07:00
|
|
|
|
2017-09-04 15:25:48 +07:00
|
|
|
int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr)
|
2016-08-08 12:44:59 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->thermal_avfs_enable)
|
|
|
|
return hwmgr->smumgr_funcs->thermal_avfs_enable(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-04 15:25:48 +07:00
|
|
|
int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
|
2016-08-08 12:44:59 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->thermal_setup_fan_table)
|
|
|
|
return hwmgr->smumgr_funcs->thermal_setup_fan_table(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
|
|
|
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->update_sclk_threshold)
|
|
|
|
return hwmgr->smumgr_funcs->update_sclk_threshold(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type)
|
|
|
|
{
|
|
|
|
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->update_smc_table)
|
|
|
|
return hwmgr->smumgr_funcs->update_smc_table(hwmgr, type);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
uint32_t smum_get_offsetof(struct pp_hwmgr *hwmgr, uint32_t type, uint32_t member)
|
2016-08-08 12:44:59 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->get_offsetof)
|
|
|
|
return hwmgr->smumgr_funcs->get_offsetof(type, member);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int smum_process_firmware_header(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->process_firmware_header)
|
|
|
|
return hwmgr->smumgr_funcs->process_firmware_header(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-13 02:59:22 +07:00
|
|
|
uint32_t smum_get_argument(struct pp_hwmgr *hwmgr)
|
2015-07-21 16:43:02 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->get_argument)
|
|
|
|
return hwmgr->smumgr_funcs->get_argument(hwmgr);
|
2015-07-21 16:43:02 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value)
|
2016-08-08 12:44:59 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->get_mac_definition)
|
|
|
|
return hwmgr->smumgr_funcs->get_mac_definition(value);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table)
|
2015-07-21 16:43:02 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->download_pptable_settings)
|
|
|
|
return hwmgr->smumgr_funcs->download_pptable_settings(hwmgr,
|
2015-07-21 16:43:02 +07:00
|
|
|
table);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
int smum_upload_powerplay_table(struct pp_hwmgr *hwmgr)
|
2015-07-21 16:43:02 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->upload_pptable_settings)
|
|
|
|
return hwmgr->smumgr_funcs->upload_pptable_settings(hwmgr);
|
2015-07-21 16:43:02 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg)
|
2015-07-21 16:43:02 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (hwmgr == NULL || hwmgr->smumgr_funcs->send_msg_to_smc == NULL)
|
2015-07-21 16:43:02 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2017-09-27 00:28:27 +07:00
|
|
|
return hwmgr->smumgr_funcs->send_msg_to_smc(hwmgr, msg);
|
2015-07-21 16:43:02 +07:00
|
|
|
}
|
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
|
2015-07-21 16:43:02 +07:00
|
|
|
uint16_t msg, uint32_t parameter)
|
|
|
|
{
|
2017-09-20 10:22:56 +07:00
|
|
|
if (hwmgr == NULL ||
|
2017-09-27 00:28:27 +07:00
|
|
|
hwmgr->smumgr_funcs->send_msg_to_smc_with_parameter == NULL)
|
2015-07-21 16:43:02 +07:00
|
|
|
return -EINVAL;
|
2017-09-27 00:28:27 +07:00
|
|
|
return hwmgr->smumgr_funcs->send_msg_to_smc_with_parameter(
|
2017-09-20 10:22:56 +07:00
|
|
|
hwmgr, msg, parameter);
|
2015-07-21 16:43:02 +07:00
|
|
|
}
|
|
|
|
|
2016-08-08 12:44:59 +07:00
|
|
|
int smum_init_smc_table(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->init_smc_table)
|
|
|
|
return hwmgr->smumgr_funcs->init_smc_table(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->populate_all_graphic_levels)
|
|
|
|
return hwmgr->smumgr_funcs->populate_all_graphic_levels(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->populate_all_memory_levels)
|
|
|
|
return hwmgr->smumgr_funcs->populate_all_memory_levels(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*this interface is needed by island ci/vi */
|
|
|
|
int smum_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->initialize_mc_reg_table)
|
|
|
|
return hwmgr->smumgr_funcs->initialize_mc_reg_table(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool smum_is_dpm_running(struct pp_hwmgr *hwmgr)
|
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (NULL != hwmgr->smumgr_funcs->is_dpm_running)
|
|
|
|
return hwmgr->smumgr_funcs->is_dpm_running(hwmgr);
|
2016-08-08 12:44:59 +07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-01-24 22:47:25 +07:00
|
|
|
|
2017-09-20 10:22:56 +07:00
|
|
|
bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr)
|
2017-07-05 17:12:46 +07:00
|
|
|
{
|
2017-09-27 00:28:27 +07:00
|
|
|
if (hwmgr->smumgr_funcs->is_hw_avfs_present)
|
|
|
|
return hwmgr->smumgr_funcs->is_hw_avfs_present(hwmgr);
|
2017-07-05 17:12:46 +07:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-24 13:48:17 +07:00
|
|
|
|
|
|
|
int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_setting)
|
|
|
|
{
|
|
|
|
if (hwmgr->smumgr_funcs->update_dpm_settings)
|
|
|
|
return hwmgr->smumgr_funcs->update_dpm_settings(hwmgr, profile_setting);
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2018-03-07 15:12:05 +07:00
|
|
|
|
|
|
|
int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw)
|
|
|
|
{
|
|
|
|
if (hwmgr->smumgr_funcs->smc_table_manager)
|
|
|
|
return hwmgr->smumgr_funcs->smc_table_manager(hwmgr, table, table_id, rw);
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|