18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2015 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef _SMUMGR_H_
248c2ecf20Sopenharmony_ci#define _SMUMGR_H_
258c2ecf20Sopenharmony_ci#include <linux/types.h>
268c2ecf20Sopenharmony_ci#include "amd_powerplay.h"
278c2ecf20Sopenharmony_ci#include "hwmgr.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum SMU_TABLE {
308c2ecf20Sopenharmony_ci	SMU_UVD_TABLE = 0,
318c2ecf20Sopenharmony_ci	SMU_VCE_TABLE,
328c2ecf20Sopenharmony_ci	SMU_BIF_TABLE,
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cienum SMU_TYPE {
368c2ecf20Sopenharmony_ci	SMU_SoftRegisters = 0,
378c2ecf20Sopenharmony_ci	SMU_Discrete_DpmTable,
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cienum SMU_MEMBER {
418c2ecf20Sopenharmony_ci	HandshakeDisables = 0,
428c2ecf20Sopenharmony_ci	VoltageChangeTimeout,
438c2ecf20Sopenharmony_ci	AverageGraphicsActivity,
448c2ecf20Sopenharmony_ci	AverageMemoryActivity,
458c2ecf20Sopenharmony_ci	PreVBlankGap,
468c2ecf20Sopenharmony_ci	VBlankTimeout,
478c2ecf20Sopenharmony_ci	UcodeLoadStatus,
488c2ecf20Sopenharmony_ci	UvdBootLevel,
498c2ecf20Sopenharmony_ci	VceBootLevel,
508c2ecf20Sopenharmony_ci	LowSclkInterruptThreshold,
518c2ecf20Sopenharmony_ci	DRAM_LOG_ADDR_H,
528c2ecf20Sopenharmony_ci	DRAM_LOG_ADDR_L,
538c2ecf20Sopenharmony_ci	DRAM_LOG_PHY_ADDR_H,
548c2ecf20Sopenharmony_ci	DRAM_LOG_PHY_ADDR_L,
558c2ecf20Sopenharmony_ci	DRAM_LOG_BUFF_SIZE,
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cienum SMU_MAC_DEFINITION {
608c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_GRAPHICS = 0,
618c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_MEMORY,
628c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_LINK,
638c2ecf20Sopenharmony_ci	SMU_MAX_ENTRIES_SMIO,
648c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_VDDC,
658c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_VDDGFX,
668c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_VDDCI,
678c2ecf20Sopenharmony_ci	SMU_MAX_LEVELS_MVDD,
688c2ecf20Sopenharmony_ci	SMU_UVD_MCLK_HANDSHAKE_DISABLE,
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cienum SMU9_TABLE_ID {
728c2ecf20Sopenharmony_ci	PPTABLE = 0,
738c2ecf20Sopenharmony_ci	WMTABLE,
748c2ecf20Sopenharmony_ci	AVFSTABLE,
758c2ecf20Sopenharmony_ci	TOOLSTABLE,
768c2ecf20Sopenharmony_ci	AVFSFUSETABLE
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cienum SMU10_TABLE_ID {
808c2ecf20Sopenharmony_ci	SMU10_WMTABLE = 0,
818c2ecf20Sopenharmony_ci	SMU10_CLOCKTABLE,
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciextern int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciextern int smum_upload_powerplay_table(struct pp_hwmgr *hwmgr);
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciextern int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg, uint32_t *resp);
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ciextern int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
918c2ecf20Sopenharmony_ci					uint16_t msg, uint32_t parameter,
928c2ecf20Sopenharmony_ci					uint32_t *resp);
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciextern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr);
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciextern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type);
978c2ecf20Sopenharmony_ciextern int smum_process_firmware_header(struct pp_hwmgr *hwmgr);
988c2ecf20Sopenharmony_ciextern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr);
998c2ecf20Sopenharmony_ciextern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr);
1008c2ecf20Sopenharmony_ciextern int smum_init_smc_table(struct pp_hwmgr *hwmgr);
1018c2ecf20Sopenharmony_ciextern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr);
1028c2ecf20Sopenharmony_ciextern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr);
1038c2ecf20Sopenharmony_ciextern int smum_initialize_mc_reg_table(struct pp_hwmgr *hwmgr);
1048c2ecf20Sopenharmony_ciextern uint32_t smum_get_offsetof(struct pp_hwmgr *hwmgr,
1058c2ecf20Sopenharmony_ci				uint32_t type, uint32_t member);
1068c2ecf20Sopenharmony_ciextern uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciextern bool smum_is_dpm_running(struct pp_hwmgr *hwmgr);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ciextern bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ciextern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_setting);
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ciextern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw);
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciextern int smum_stop_smc(struct pp_hwmgr *hwmgr);
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#endif
119