Home | History | Annotate | Line # | Download | only in radeon
      1  1.2  riastrad /*	$NetBSD: sumo_dpm.h,v 1.3 2021/12/18 23:45:43 riastradh Exp $	*/
      2  1.2  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2012 Advanced Micro Devices, Inc.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  *
     24  1.1  riastrad  */
     25  1.1  riastrad #ifndef __SUMO_DPM_H__
     26  1.1  riastrad #define __SUMO_DPM_H__
     27  1.1  riastrad 
     28  1.1  riastrad #include "atom.h"
     29  1.3  riastrad #include "radeon.h"
     30  1.1  riastrad 
     31  1.1  riastrad #define SUMO_MAX_HARDWARE_POWERLEVELS 5
     32  1.1  riastrad #define SUMO_PM_NUMBER_OF_TC 15
     33  1.1  riastrad 
     34  1.1  riastrad struct sumo_pl {
     35  1.1  riastrad 	u32 sclk;
     36  1.1  riastrad 	u32 vddc_index;
     37  1.1  riastrad 	u32 ds_divider_index;
     38  1.1  riastrad 	u32 ss_divider_index;
     39  1.1  riastrad 	u32 allow_gnb_slow;
     40  1.1  riastrad 	u32 sclk_dpm_tdp_limit;
     41  1.1  riastrad };
     42  1.1  riastrad 
     43  1.1  riastrad /* used for the flags field */
     44  1.1  riastrad #define SUMO_POWERSTATE_FLAGS_FORCE_NBPS1_STATE (1 << 0)
     45  1.1  riastrad #define SUMO_POWERSTATE_FLAGS_BOOST_STATE       (1 << 1)
     46  1.1  riastrad 
     47  1.1  riastrad struct sumo_ps {
     48  1.1  riastrad 	struct sumo_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS];
     49  1.1  riastrad 	u32 num_levels;
     50  1.1  riastrad 	/* flags */
     51  1.1  riastrad 	u32 flags;
     52  1.1  riastrad };
     53  1.1  riastrad 
     54  1.1  riastrad #define NUMBER_OF_M3ARB_PARAM_SETS 10
     55  1.1  riastrad #define SUMO_MAX_NUMBER_VOLTAGES    4
     56  1.1  riastrad 
     57  1.1  riastrad struct sumo_disp_clock_voltage_mapping_table {
     58  1.1  riastrad 	u32 num_max_voltage_levels;
     59  1.1  riastrad 	u32 display_clock_frequency[SUMO_MAX_NUMBER_VOLTAGES];
     60  1.1  riastrad };
     61  1.1  riastrad 
     62  1.1  riastrad struct sumo_vid_mapping_entry {
     63  1.1  riastrad 	u16 vid_2bit;
     64  1.1  riastrad 	u16 vid_7bit;
     65  1.1  riastrad };
     66  1.1  riastrad 
     67  1.1  riastrad struct sumo_vid_mapping_table {
     68  1.1  riastrad 	u32 num_entries;
     69  1.1  riastrad 	struct sumo_vid_mapping_entry entries[SUMO_MAX_NUMBER_VOLTAGES];
     70  1.1  riastrad };
     71  1.1  riastrad 
     72  1.1  riastrad struct sumo_sclk_voltage_mapping_entry {
     73  1.1  riastrad 	u32 sclk_frequency;
     74  1.1  riastrad 	u16 vid_2bit;
     75  1.1  riastrad 	u16 rsv;
     76  1.1  riastrad };
     77  1.1  riastrad 
     78  1.1  riastrad struct sumo_sclk_voltage_mapping_table {
     79  1.1  riastrad 	u32 num_max_dpm_entries;
     80  1.1  riastrad 	struct sumo_sclk_voltage_mapping_entry entries[SUMO_MAX_HARDWARE_POWERLEVELS];
     81  1.1  riastrad };
     82  1.1  riastrad 
     83  1.1  riastrad struct sumo_sys_info {
     84  1.1  riastrad 	u32 bootup_sclk;
     85  1.1  riastrad 	u32 min_sclk;
     86  1.1  riastrad 	u32 bootup_uma_clk;
     87  1.1  riastrad 	u16 bootup_nb_voltage_index;
     88  1.1  riastrad 	u8 htc_tmp_lmt;
     89  1.1  riastrad 	u8 htc_hyst_lmt;
     90  1.1  riastrad 	struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table;
     91  1.1  riastrad 	struct sumo_disp_clock_voltage_mapping_table disp_clk_voltage_mapping_table;
     92  1.1  riastrad 	struct sumo_vid_mapping_table vid_mapping_table;
     93  1.1  riastrad 	u32 csr_m3_arb_cntl_default[NUMBER_OF_M3ARB_PARAM_SETS];
     94  1.1  riastrad 	u32 csr_m3_arb_cntl_uvd[NUMBER_OF_M3ARB_PARAM_SETS];
     95  1.1  riastrad 	u32 csr_m3_arb_cntl_fs3d[NUMBER_OF_M3ARB_PARAM_SETS];
     96  1.1  riastrad 	u32 sclk_dpm_boost_margin;
     97  1.1  riastrad 	u32 sclk_dpm_throttle_margin;
     98  1.1  riastrad 	u32 sclk_dpm_tdp_limit_pg;
     99  1.1  riastrad 	u32 gnb_tdp_limit;
    100  1.1  riastrad 	u32 sclk_dpm_tdp_limit_boost;
    101  1.1  riastrad 	u32 boost_sclk;
    102  1.1  riastrad 	u32 boost_vid_2bit;
    103  1.1  riastrad 	bool enable_boost;
    104  1.1  riastrad };
    105  1.1  riastrad 
    106  1.1  riastrad struct sumo_power_info {
    107  1.1  riastrad 	u32 asi;
    108  1.1  riastrad 	u32 pasi;
    109  1.1  riastrad 	u32 bsp;
    110  1.1  riastrad 	u32 bsu;
    111  1.1  riastrad 	u32 pbsp;
    112  1.1  riastrad 	u32 pbsu;
    113  1.1  riastrad 	u32 dsp;
    114  1.1  riastrad 	u32 psp;
    115  1.1  riastrad 	u32 thermal_auto_throttling;
    116  1.1  riastrad 	u32 uvd_m3_arbiter;
    117  1.1  riastrad 	u32 fw_version;
    118  1.1  riastrad 	struct sumo_sys_info sys_info;
    119  1.1  riastrad 	struct sumo_pl acpi_pl;
    120  1.1  riastrad 	struct sumo_pl boot_pl;
    121  1.1  riastrad 	struct sumo_pl boost_pl;
    122  1.1  riastrad 	bool disable_gfx_power_gating_in_uvd;
    123  1.1  riastrad 	bool driver_nbps_policy_disable;
    124  1.1  riastrad 	bool enable_alt_vddnb;
    125  1.1  riastrad 	bool enable_dynamic_m3_arbiter;
    126  1.1  riastrad 	bool enable_gfx_clock_gating;
    127  1.1  riastrad 	bool enable_gfx_power_gating;
    128  1.1  riastrad 	bool enable_mg_clock_gating;
    129  1.1  riastrad 	bool enable_sclk_ds;
    130  1.1  riastrad 	bool enable_auto_thermal_throttling;
    131  1.1  riastrad 	bool enable_dynamic_patch_ps;
    132  1.1  riastrad 	bool enable_dpm;
    133  1.1  riastrad 	bool enable_boost;
    134  1.1  riastrad 	struct radeon_ps current_rps;
    135  1.1  riastrad 	struct sumo_ps current_ps;
    136  1.1  riastrad 	struct radeon_ps requested_rps;
    137  1.1  riastrad 	struct sumo_ps requested_ps;
    138  1.1  riastrad };
    139  1.1  riastrad 
    140  1.1  riastrad #define SUMO_UTC_DFLT_00                     0x48
    141  1.1  riastrad #define SUMO_UTC_DFLT_01                     0x44
    142  1.1  riastrad #define SUMO_UTC_DFLT_02                     0x44
    143  1.1  riastrad #define SUMO_UTC_DFLT_03                     0x44
    144  1.1  riastrad #define SUMO_UTC_DFLT_04                     0x44
    145  1.1  riastrad #define SUMO_UTC_DFLT_05                     0x44
    146  1.1  riastrad #define SUMO_UTC_DFLT_06                     0x44
    147  1.1  riastrad #define SUMO_UTC_DFLT_07                     0x44
    148  1.1  riastrad #define SUMO_UTC_DFLT_08                     0x44
    149  1.1  riastrad #define SUMO_UTC_DFLT_09                     0x44
    150  1.1  riastrad #define SUMO_UTC_DFLT_10                     0x44
    151  1.1  riastrad #define SUMO_UTC_DFLT_11                     0x44
    152  1.1  riastrad #define SUMO_UTC_DFLT_12                     0x44
    153  1.1  riastrad #define SUMO_UTC_DFLT_13                     0x44
    154  1.1  riastrad #define SUMO_UTC_DFLT_14                     0x44
    155  1.1  riastrad 
    156  1.1  riastrad #define SUMO_DTC_DFLT_00                     0x48
    157  1.1  riastrad #define SUMO_DTC_DFLT_01                     0x44
    158  1.1  riastrad #define SUMO_DTC_DFLT_02                     0x44
    159  1.1  riastrad #define SUMO_DTC_DFLT_03                     0x44
    160  1.1  riastrad #define SUMO_DTC_DFLT_04                     0x44
    161  1.1  riastrad #define SUMO_DTC_DFLT_05                     0x44
    162  1.1  riastrad #define SUMO_DTC_DFLT_06                     0x44
    163  1.1  riastrad #define SUMO_DTC_DFLT_07                     0x44
    164  1.1  riastrad #define SUMO_DTC_DFLT_08                     0x44
    165  1.1  riastrad #define SUMO_DTC_DFLT_09                     0x44
    166  1.1  riastrad #define SUMO_DTC_DFLT_10                     0x44
    167  1.1  riastrad #define SUMO_DTC_DFLT_11                     0x44
    168  1.1  riastrad #define SUMO_DTC_DFLT_12                     0x44
    169  1.1  riastrad #define SUMO_DTC_DFLT_13                     0x44
    170  1.1  riastrad #define SUMO_DTC_DFLT_14                     0x44
    171  1.1  riastrad 
    172  1.1  riastrad #define SUMO_AH_DFLT               5
    173  1.1  riastrad 
    174  1.1  riastrad #define SUMO_R_DFLT0               70
    175  1.1  riastrad #define SUMO_R_DFLT1               70
    176  1.1  riastrad #define SUMO_R_DFLT2               70
    177  1.1  riastrad #define SUMO_R_DFLT3               70
    178  1.1  riastrad #define SUMO_R_DFLT4               100
    179  1.1  riastrad 
    180  1.1  riastrad #define SUMO_L_DFLT0               0
    181  1.1  riastrad #define SUMO_L_DFLT1               20
    182  1.1  riastrad #define SUMO_L_DFLT2               20
    183  1.1  riastrad #define SUMO_L_DFLT3               20
    184  1.1  riastrad #define SUMO_L_DFLT4               20
    185  1.1  riastrad #define SUMO_VRC_DFLT              0x30033
    186  1.1  riastrad #define SUMO_MGCGTTLOCAL0_DFLT     0
    187  1.1  riastrad #define SUMO_MGCGTTLOCAL1_DFLT     0
    188  1.1  riastrad #define SUMO_GICST_DFLT            19
    189  1.1  riastrad #define SUMO_SST_DFLT              8
    190  1.1  riastrad #define SUMO_VOLTAGEDROPT_DFLT     1
    191  1.1  riastrad #define SUMO_GFXPOWERGATINGT_DFLT  100
    192  1.1  riastrad 
    193  1.1  riastrad /* sumo_dpm.c */
    194  1.1  riastrad void sumo_gfx_clockgating_initialize(struct radeon_device *rdev);
    195  1.1  riastrad void sumo_program_vc(struct radeon_device *rdev, u32 vrc);
    196  1.1  riastrad void sumo_clear_vc(struct radeon_device *rdev);
    197  1.1  riastrad void sumo_program_sstp(struct radeon_device *rdev);
    198  1.1  riastrad void sumo_take_smu_control(struct radeon_device *rdev, bool enable);
    199  1.1  riastrad void sumo_construct_sclk_voltage_mapping_table(struct radeon_device *rdev,
    200  1.1  riastrad 					       struct sumo_sclk_voltage_mapping_table *sclk_voltage_mapping_table,
    201  1.1  riastrad 					       ATOM_AVAILABLE_SCLK_LIST *table);
    202  1.1  riastrad void sumo_construct_vid_mapping_table(struct radeon_device *rdev,
    203  1.1  riastrad 				      struct sumo_vid_mapping_table *vid_mapping_table,
    204  1.1  riastrad 				      ATOM_AVAILABLE_SCLK_LIST *table);
    205  1.1  riastrad u32 sumo_convert_vid2_to_vid7(struct radeon_device *rdev,
    206  1.1  riastrad 			      struct sumo_vid_mapping_table *vid_mapping_table,
    207  1.1  riastrad 			      u32 vid_2bit);
    208  1.1  riastrad u32 sumo_get_sleep_divider_from_id(u32 id);
    209  1.1  riastrad u32 sumo_get_sleep_divider_id_from_clock(struct radeon_device *rdev,
    210  1.1  riastrad 					 u32 sclk,
    211  1.1  riastrad 					 u32 min_sclk_in_sr);
    212  1.1  riastrad 
    213  1.1  riastrad /* sumo_smc.c */
    214  1.1  riastrad void sumo_initialize_m3_arb(struct radeon_device *rdev);
    215  1.1  riastrad void sumo_smu_pg_init(struct radeon_device *rdev);
    216  1.1  riastrad void sumo_set_tdp_limit(struct radeon_device *rdev, u32 index, u32 tdp_limit);
    217  1.1  riastrad void sumo_smu_notify_alt_vddnb_change(struct radeon_device *rdev,
    218  1.1  riastrad 				      bool powersaving, bool force_nbps1);
    219  1.1  riastrad void sumo_boost_state_enable(struct radeon_device *rdev, bool enable);
    220  1.1  riastrad void sumo_enable_boost_timer(struct radeon_device *rdev);
    221  1.1  riastrad u32 sumo_get_running_fw_version(struct radeon_device *rdev);
    222  1.1  riastrad 
    223  1.1  riastrad #endif
    224