Path: blob/master/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.h
26552 views
/*1* Copyright 2015 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21*/2223#ifndef PP_ATOMVOLTAGECTRL_H24#define PP_ATOMVOLTAGECTRL_H2526#include "hwmgr.h"2728/* As returned from PowerConnectorDetectionTable. */29#define PP_ATOM_POWER_BUDGET_DISABLE_OVERDRIVE 0x8030#define PP_ATOM_POWER_BUDGET_SHOW_WARNING 0x4031#define PP_ATOM_POWER_BUDGET_SHOW_WAIVER 0x2032#define PP_ATOM_POWER_POWER_BUDGET_BEHAVIOUR 0x0F3334/* New functions for Evergreen and beyond. */35#define PP_ATOMCTRL_MAX_VOLTAGE_ENTRIES 323637struct pp_atomctrl_clock_dividers {38uint32_t pll_post_divider;39uint32_t pll_feedback_divider;40uint32_t pll_ref_divider;41bool enable_post_divider;42};4344typedef struct pp_atomctrl_clock_dividers pp_atomctrl_clock_dividers;4546union pp_atomctrl_tcipll_fb_divider {47struct {48uint32_t ul_fb_div_frac : 14;49uint32_t ul_fb_div : 12;50uint32_t un_used : 6;51};52uint32_t ul_fb_divider;53};5455typedef union pp_atomctrl_tcipll_fb_divider pp_atomctrl_tcipll_fb_divider;5657struct pp_atomctrl_clock_dividers_rv730 {58uint32_t pll_post_divider;59pp_atomctrl_tcipll_fb_divider mpll_feedback_divider;60uint32_t pll_ref_divider;61bool enable_post_divider;62bool enable_dithen;63uint32_t vco_mode;64};65typedef struct pp_atomctrl_clock_dividers_rv730 pp_atomctrl_clock_dividers_rv730;666768struct pp_atomctrl_clock_dividers_kong {69uint32_t pll_post_divider;70uint32_t real_clock;71};72typedef struct pp_atomctrl_clock_dividers_kong pp_atomctrl_clock_dividers_kong;7374struct pp_atomctrl_clock_dividers_ci {75uint32_t pll_post_divider; /* post divider value */76uint32_t real_clock;77pp_atomctrl_tcipll_fb_divider ul_fb_div; /* Output Parameter: PLL FB divider */78uint8_t uc_pll_ref_div; /* Output Parameter: PLL ref divider */79uint8_t uc_pll_post_div; /* Output Parameter: PLL post divider */80uint8_t uc_pll_cntl_flag; /*Output Flags: control flag */81};82typedef struct pp_atomctrl_clock_dividers_ci pp_atomctrl_clock_dividers_ci;8384struct pp_atomctrl_clock_dividers_vi {85uint32_t pll_post_divider; /* post divider value */86uint32_t real_clock;87pp_atomctrl_tcipll_fb_divider ul_fb_div; /*Output Parameter: PLL FB divider */88uint8_t uc_pll_ref_div; /*Output Parameter: PLL ref divider */89uint8_t uc_pll_post_div; /*Output Parameter: PLL post divider */90uint8_t uc_pll_cntl_flag; /*Output Flags: control flag */91};92typedef struct pp_atomctrl_clock_dividers_vi pp_atomctrl_clock_dividers_vi;9394struct pp_atomctrl_clock_dividers_ai {95u16 usSclk_fcw_frac;96u16 usSclk_fcw_int;97u8 ucSclkPostDiv;98u8 ucSclkVcoMode;99u8 ucSclkPllRange;100u8 ucSscEnable;101u16 usSsc_fcw1_frac;102u16 usSsc_fcw1_int;103u16 usReserved;104u16 usPcc_fcw_int;105u16 usSsc_fcw_slew_frac;106u16 usPcc_fcw_slew_frac;107};108typedef struct pp_atomctrl_clock_dividers_ai pp_atomctrl_clock_dividers_ai;109110111union pp_atomctrl_s_mpll_fb_divider {112struct {113uint32_t cl_kf : 12;114uint32_t clk_frac : 12;115uint32_t un_used : 8;116};117uint32_t ul_fb_divider;118};119typedef union pp_atomctrl_s_mpll_fb_divider pp_atomctrl_s_mpll_fb_divider;120121enum pp_atomctrl_spread_spectrum_mode {122pp_atomctrl_spread_spectrum_mode_down = 0,123pp_atomctrl_spread_spectrum_mode_center124};125typedef enum pp_atomctrl_spread_spectrum_mode pp_atomctrl_spread_spectrum_mode;126127struct pp_atomctrl_memory_clock_param {128pp_atomctrl_s_mpll_fb_divider mpll_fb_divider;129uint32_t mpll_post_divider;130uint32_t bw_ctrl;131uint32_t dll_speed;132uint32_t vco_mode;133uint32_t yclk_sel;134uint32_t qdr;135uint32_t half_rate;136};137typedef struct pp_atomctrl_memory_clock_param pp_atomctrl_memory_clock_param;138139struct pp_atomctrl_memory_clock_param_ai {140uint32_t ulClock;141uint32_t ulPostDiv;142uint16_t ulMclk_fcw_frac;143uint16_t ulMclk_fcw_int;144};145typedef struct pp_atomctrl_memory_clock_param_ai pp_atomctrl_memory_clock_param_ai;146147struct pp_atomctrl_internal_ss_info {148uint32_t speed_spectrum_percentage; /* in 1/100 percentage */149uint32_t speed_spectrum_rate; /* in KHz */150pp_atomctrl_spread_spectrum_mode speed_spectrum_mode;151};152typedef struct pp_atomctrl_internal_ss_info pp_atomctrl_internal_ss_info;153154#ifndef NUMBER_OF_M3ARB_PARAMS155#define NUMBER_OF_M3ARB_PARAMS 3156#endif157158#ifndef NUMBER_OF_M3ARB_PARAM_SETS159#define NUMBER_OF_M3ARB_PARAM_SETS 10160#endif161162struct pp_atomctrl_kong_system_info {163uint32_t ul_bootup_uma_clock; /* in 10kHz unit */164uint16_t us_max_nb_voltage; /* high NB voltage, calculated using current VDDNB (D24F2xDC) and VDDNB offset fuse; */165uint16_t us_min_nb_voltage; /* low NB voltage, calculated using current VDDNB (D24F2xDC) and VDDNB offset fuse; */166uint16_t us_bootup_nb_voltage; /* boot up NB voltage */167uint8_t uc_htc_tmp_lmt; /* bit [22:16] of D24F3x64 Hardware Thermal Control (HTC) Register, may not be needed, TBD */168uint8_t uc_tj_offset; /* bit [28:22] of D24F3xE4 Thermtrip Status Register,may not be needed, TBD */169/* 0: default 1: uvd 2: fs-3d */170uint32_t ul_csr_m3_srb_cntl[NUMBER_OF_M3ARB_PARAM_SETS][NUMBER_OF_M3ARB_PARAMS];/* arrays with values for CSR M3 arbiter for default */171};172typedef struct pp_atomctrl_kong_system_info pp_atomctrl_kong_system_info;173174struct pp_atomctrl_memory_info {175uint8_t memory_vendor;176uint8_t memory_type;177};178typedef struct pp_atomctrl_memory_info pp_atomctrl_memory_info;179180#define MAX_AC_TIMING_ENTRIES 16181182struct pp_atomctrl_memory_clock_range_table {183uint8_t num_entries;184uint8_t rsv[3];185186uint32_t mclk[MAX_AC_TIMING_ENTRIES];187};188typedef struct pp_atomctrl_memory_clock_range_table pp_atomctrl_memory_clock_range_table;189190struct pp_atomctrl_voltage_table_entry {191uint16_t value;192uint32_t smio_low;193};194195typedef struct pp_atomctrl_voltage_table_entry pp_atomctrl_voltage_table_entry;196197struct pp_atomctrl_voltage_table {198uint32_t count;199uint32_t mask_low;200uint32_t phase_delay; /* Used for ATOM_GPIO_VOLTAGE_OBJECT_V3 and later */201pp_atomctrl_voltage_table_entry entries[PP_ATOMCTRL_MAX_VOLTAGE_ENTRIES];202};203204typedef struct pp_atomctrl_voltage_table pp_atomctrl_voltage_table;205206#define VBIOS_MC_REGISTER_ARRAY_SIZE 32207#define VBIOS_MAX_AC_TIMING_ENTRIES 20208209struct pp_atomctrl_mc_reg_entry {210uint32_t mclk_max;211uint32_t mc_data[VBIOS_MC_REGISTER_ARRAY_SIZE];212};213typedef struct pp_atomctrl_mc_reg_entry pp_atomctrl_mc_reg_entry;214215struct pp_atomctrl_mc_register_address {216uint16_t s1;217uint8_t uc_pre_reg_data;218};219220typedef struct pp_atomctrl_mc_register_address pp_atomctrl_mc_register_address;221222#define MAX_SCLK_RANGE 8223224struct pp_atom_ctrl_sclk_range_table_entry{225uint8_t ucVco_setting;226uint8_t ucPostdiv;227uint16_t usFcw_pcc;228uint16_t usFcw_trans_upper;229uint16_t usRcw_trans_lower;230};231232233struct pp_atom_ctrl_sclk_range_table{234struct pp_atom_ctrl_sclk_range_table_entry entry[MAX_SCLK_RANGE];235};236237struct pp_atomctrl_mc_reg_table {238uint8_t last; /* number of registers */239uint8_t num_entries; /* number of AC timing entries */240pp_atomctrl_mc_reg_entry mc_reg_table_entry[VBIOS_MAX_AC_TIMING_ENTRIES];241pp_atomctrl_mc_register_address mc_reg_address[VBIOS_MC_REGISTER_ARRAY_SIZE];242};243typedef struct pp_atomctrl_mc_reg_table pp_atomctrl_mc_reg_table;244245struct pp_atomctrl_gpio_pin_assignment {246uint16_t us_gpio_pin_aindex;247uint8_t uc_gpio_pin_bit_shift;248};249typedef struct pp_atomctrl_gpio_pin_assignment pp_atomctrl_gpio_pin_assignment;250251struct pp_atom_ctrl__avfs_parameters {252uint32_t ulAVFS_meanNsigma_Acontant0;253uint32_t ulAVFS_meanNsigma_Acontant1;254uint32_t ulAVFS_meanNsigma_Acontant2;255uint16_t usAVFS_meanNsigma_DC_tol_sigma;256uint16_t usAVFS_meanNsigma_Platform_mean;257uint16_t usAVFS_meanNsigma_Platform_sigma;258uint32_t ulGB_VDROOP_TABLE_CKSOFF_a0;259uint32_t ulGB_VDROOP_TABLE_CKSOFF_a1;260uint32_t ulGB_VDROOP_TABLE_CKSOFF_a2;261uint32_t ulGB_VDROOP_TABLE_CKSON_a0;262uint32_t ulGB_VDROOP_TABLE_CKSON_a1;263uint32_t ulGB_VDROOP_TABLE_CKSON_a2;264uint32_t ulAVFSGB_FUSE_TABLE_CKSOFF_m1;265uint16_t usAVFSGB_FUSE_TABLE_CKSOFF_m2;266uint32_t ulAVFSGB_FUSE_TABLE_CKSOFF_b;267uint32_t ulAVFSGB_FUSE_TABLE_CKSON_m1;268uint16_t usAVFSGB_FUSE_TABLE_CKSON_m2;269uint32_t ulAVFSGB_FUSE_TABLE_CKSON_b;270uint16_t usMaxVoltage_0_25mv;271uint8_t ucEnableGB_VDROOP_TABLE_CKSOFF;272uint8_t ucEnableGB_VDROOP_TABLE_CKSON;273uint8_t ucEnableGB_FUSE_TABLE_CKSOFF;274uint8_t ucEnableGB_FUSE_TABLE_CKSON;275uint16_t usPSM_Age_ComFactor;276uint8_t ucEnableApplyAVFS_CKS_OFF_Voltage;277uint8_t ucReserved;278};279280struct _AtomCtrl_HiLoLeakageOffsetTable {281USHORT usHiLoLeakageThreshold;282USHORT usEdcDidtLoDpm7TableOffset;283USHORT usEdcDidtHiDpm7TableOffset;284};285typedef struct _AtomCtrl_HiLoLeakageOffsetTable AtomCtrl_HiLoLeakageOffsetTable;286287struct _AtomCtrl_EDCLeakgeTable {288ULONG DIDT_REG[24];289};290typedef struct _AtomCtrl_EDCLeakgeTable AtomCtrl_EDCLeakgeTable;291292extern bool atomctrl_get_pp_assign_pin(struct pp_hwmgr *hwmgr, const uint32_t pinId, pp_atomctrl_gpio_pin_assignment *gpio_pin_assignment);293extern int atomctrl_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, uint32_t sclk, uint16_t virtual_voltage_Id, uint16_t *voltage);294extern int atomctrl_get_voltage_evv(struct pp_hwmgr *hwmgr, uint16_t virtual_voltage_id, uint16_t *voltage);295extern uint32_t atomctrl_get_mpll_reference_clock(struct pp_hwmgr *hwmgr);296297bool atomctrl_is_asic_internal_ss_supported(struct pp_hwmgr *hwmgr);298extern int atomctrl_get_memory_clock_spread_spectrum(struct pp_hwmgr *hwmgr, const uint32_t memory_clock, pp_atomctrl_internal_ss_info *ssInfo);299extern int atomctrl_get_engine_clock_spread_spectrum(struct pp_hwmgr *hwmgr, const uint32_t engine_clock, pp_atomctrl_internal_ss_info *ssInfo);300extern int atomctrl_initialize_mc_reg_table(struct pp_hwmgr *hwmgr, uint8_t module_index, pp_atomctrl_mc_reg_table *table);301extern int atomctrl_initialize_mc_reg_table_v2_2(struct pp_hwmgr *hwmgr, uint8_t module_index, pp_atomctrl_mc_reg_table *table);302extern int atomctrl_set_engine_dram_timings_rv770(struct pp_hwmgr *hwmgr, uint32_t engine_clock, uint32_t memory_clock);303extern uint32_t atomctrl_get_reference_clock(struct pp_hwmgr *hwmgr);304extern int atomctrl_get_memory_pll_dividers_si(struct pp_hwmgr *hwmgr, uint32_t clock_value, pp_atomctrl_memory_clock_param *mpll_param, bool strobe_mode);305extern int atomctrl_get_engine_pll_dividers_vi(struct pp_hwmgr *hwmgr, uint32_t clock_value, pp_atomctrl_clock_dividers_vi *dividers);306extern int atomctrl_get_dfs_pll_dividers_vi(struct pp_hwmgr *hwmgr, uint32_t clock_value, pp_atomctrl_clock_dividers_vi *dividers);307extern bool atomctrl_is_voltage_controlled_by_gpio_v3(struct pp_hwmgr *hwmgr, uint8_t voltage_type, uint8_t voltage_mode);308extern int atomctrl_get_voltage_table_v3(struct pp_hwmgr *hwmgr, uint8_t voltage_type, uint8_t voltage_mode, pp_atomctrl_voltage_table *voltage_table);309extern int atomctrl_get_memory_pll_dividers_vi(struct pp_hwmgr *hwmgr,310uint32_t clock_value, pp_atomctrl_memory_clock_param *mpll_param);311extern int atomctrl_get_memory_pll_dividers_ai(struct pp_hwmgr *hwmgr,312uint32_t clock_value, pp_atomctrl_memory_clock_param_ai *mpll_param);313extern int atomctrl_get_engine_pll_dividers_kong(struct pp_hwmgr *hwmgr,314uint32_t clock_value,315pp_atomctrl_clock_dividers_kong *dividers);316extern int atomctrl_read_efuse(struct pp_hwmgr *hwmgr, uint16_t start_index,317uint16_t end_index, uint32_t *efuse);318extern int atomctrl_get_engine_pll_dividers_ai(struct pp_hwmgr *hwmgr, uint32_t clock_value, pp_atomctrl_clock_dividers_ai *dividers);319extern int atomctrl_set_ac_timing_ai(struct pp_hwmgr *hwmgr, uint32_t memory_clock,320uint8_t level);321extern int atomctrl_get_voltage_evv_on_sclk_ai(struct pp_hwmgr *hwmgr, uint8_t voltage_type,322uint32_t sclk, uint16_t virtual_voltage_Id, uint32_t *voltage);323extern int atomctrl_get_smc_sclk_range_table(struct pp_hwmgr *hwmgr, struct pp_atom_ctrl_sclk_range_table *table);324325extern int atomctrl_get_avfs_information(struct pp_hwmgr *hwmgr, struct pp_atom_ctrl__avfs_parameters *param);326327extern int atomctrl_get_svi2_info(struct pp_hwmgr *hwmgr, uint8_t voltage_type,328uint8_t *svd_gpio_id, uint8_t *svc_gpio_id,329uint16_t *load_line);330331extern int atomctrl_get_leakage_vddc_base_on_leakage(struct pp_hwmgr *hwmgr,332uint16_t *vddc, uint16_t *vddci,333uint16_t virtual_voltage_id,334uint16_t efuse_voltage_id);335extern int atomctrl_get_leakage_id_from_efuse(struct pp_hwmgr *hwmgr, uint16_t *virtual_voltage_id);336337extern void atomctrl_get_voltage_range(struct pp_hwmgr *hwmgr, uint32_t *max_vddc,338uint32_t *min_vddc);339340extern int atomctrl_get_edc_hilo_leakage_offset_table(struct pp_hwmgr *hwmgr,341AtomCtrl_HiLoLeakageOffsetTable *table);342343extern int atomctrl_get_edc_leakage_table(struct pp_hwmgr *hwmgr,344AtomCtrl_EDCLeakgeTable *table,345uint16_t offset);346347extern int atomctrl_get_vddc_shared_railinfo(struct pp_hwmgr *hwmgr, uint8_t *shared_rail);348#endif349350351352