Home | History | Annotate | Line # | Download | only in radeon
      1  1.2  riastrad /*	$NetBSD: cypress_dpm.h,v 1.3 2021/12/18 23:45:42 riastradh Exp $	*/
      2  1.2  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2011 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 __CYPRESS_DPM_H__
     26  1.1  riastrad #define __CYPRESS_DPM_H__
     27  1.1  riastrad 
     28  1.1  riastrad #include "rv770_dpm.h"
     29  1.1  riastrad #include "evergreen_smc.h"
     30  1.1  riastrad 
     31  1.1  riastrad struct evergreen_mc_reg_entry {
     32  1.1  riastrad 	u32 mclk_max;
     33  1.1  riastrad 	u32 mc_data[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE];
     34  1.1  riastrad };
     35  1.1  riastrad 
     36  1.1  riastrad struct evergreen_mc_reg_table {
     37  1.1  riastrad 	u8 last;
     38  1.1  riastrad 	u8 num_entries;
     39  1.1  riastrad 	u16 valid_flag;
     40  1.1  riastrad 	struct evergreen_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
     41  1.1  riastrad 	SMC_Evergreen_MCRegisterAddress mc_reg_address[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE];
     42  1.1  riastrad };
     43  1.1  riastrad 
     44  1.1  riastrad struct evergreen_ulv_param {
     45  1.1  riastrad 	bool supported;
     46  1.1  riastrad 	struct rv7xx_pl *pl;
     47  1.1  riastrad };
     48  1.1  riastrad 
     49  1.1  riastrad struct evergreen_arb_registers {
     50  1.1  riastrad 	u32 mc_arb_dram_timing;
     51  1.1  riastrad 	u32 mc_arb_dram_timing2;
     52  1.1  riastrad 	u32 mc_arb_rfsh_rate;
     53  1.1  riastrad 	u32 mc_arb_burst_time;
     54  1.1  riastrad };
     55  1.1  riastrad 
     56  1.1  riastrad struct at {
     57  1.1  riastrad 	u32 rlp;
     58  1.1  riastrad 	u32 rmp;
     59  1.1  riastrad 	u32 lhp;
     60  1.1  riastrad 	u32 lmp;
     61  1.1  riastrad };
     62  1.1  riastrad 
     63  1.1  riastrad struct evergreen_power_info {
     64  1.1  riastrad 	/* must be first! */
     65  1.1  riastrad 	struct rv7xx_power_info rv7xx;
     66  1.1  riastrad 	/* flags */
     67  1.1  riastrad 	bool vddci_control;
     68  1.1  riastrad 	bool dynamic_ac_timing;
     69  1.1  riastrad 	bool abm;
     70  1.1  riastrad 	bool mcls;
     71  1.1  riastrad 	bool light_sleep;
     72  1.1  riastrad 	bool memory_transition;
     73  1.1  riastrad 	bool pcie_performance_request;
     74  1.1  riastrad 	bool pcie_performance_request_registered;
     75  1.1  riastrad 	bool sclk_deep_sleep;
     76  1.1  riastrad 	bool dll_default_on;
     77  1.1  riastrad 	bool ls_clock_gating;
     78  1.1  riastrad 	bool smu_uvd_hs;
     79  1.1  riastrad 	bool uvd_enabled;
     80  1.1  riastrad 	/* stored values */
     81  1.1  riastrad 	u16 acpi_vddci;
     82  1.1  riastrad 	u8 mvdd_high_index;
     83  1.1  riastrad 	u8 mvdd_low_index;
     84  1.1  riastrad 	u32 mclk_edc_wr_enable_threshold;
     85  1.1  riastrad 	struct evergreen_mc_reg_table mc_reg_table;
     86  1.1  riastrad 	struct atom_voltage_table vddc_voltage_table;
     87  1.1  riastrad 	struct atom_voltage_table vddci_voltage_table;
     88  1.1  riastrad 	struct evergreen_arb_registers bootup_arb_registers;
     89  1.1  riastrad 	struct evergreen_ulv_param ulv;
     90  1.1  riastrad 	struct at ats[2];
     91  1.1  riastrad 	/* smc offsets */
     92  1.1  riastrad 	u16 mc_reg_table_start;
     93  1.1  riastrad 	struct radeon_ps current_rps;
     94  1.1  riastrad 	struct rv7xx_ps current_ps;
     95  1.1  riastrad 	struct radeon_ps requested_rps;
     96  1.1  riastrad 	struct rv7xx_ps requested_ps;
     97  1.1  riastrad };
     98  1.1  riastrad 
     99  1.1  riastrad #define CYPRESS_HASI_DFLT                               400000
    100  1.1  riastrad #define CYPRESS_MGCGTTLOCAL0_DFLT                       0x00000000
    101  1.1  riastrad #define CYPRESS_MGCGTTLOCAL1_DFLT                       0x00000000
    102  1.1  riastrad #define CYPRESS_MGCGTTLOCAL2_DFLT                       0x00000000
    103  1.1  riastrad #define CYPRESS_MGCGTTLOCAL3_DFLT                       0x00000000
    104  1.1  riastrad #define CYPRESS_MGCGCGTSSMCTRL_DFLT                     0x81944bc0
    105  1.1  riastrad #define REDWOOD_MGCGCGTSSMCTRL_DFLT                     0x6e944040
    106  1.1  riastrad #define CEDAR_MGCGCGTSSMCTRL_DFLT                       0x46944040
    107  1.1  riastrad #define CYPRESS_VRC_DFLT                                0xC00033
    108  1.1  riastrad 
    109  1.1  riastrad #define PCIE_PERF_REQ_REMOVE_REGISTRY   0
    110  1.1  riastrad #define PCIE_PERF_REQ_FORCE_LOWPOWER    1
    111  1.1  riastrad #define PCIE_PERF_REQ_PECI_GEN1         2
    112  1.1  riastrad #define PCIE_PERF_REQ_PECI_GEN2         3
    113  1.1  riastrad #define PCIE_PERF_REQ_PECI_GEN3         4
    114  1.1  riastrad 
    115  1.1  riastrad int cypress_convert_power_level_to_smc(struct radeon_device *rdev,
    116  1.1  riastrad 				       struct rv7xx_pl *pl,
    117  1.1  riastrad 				       RV770_SMC_HW_PERFORMANCE_LEVEL *level,
    118  1.1  riastrad 				       u8 watermark_level);
    119  1.1  riastrad int cypress_populate_smc_acpi_state(struct radeon_device *rdev,
    120  1.1  riastrad 				    RV770_SMC_STATETABLE *table);
    121  1.1  riastrad int cypress_populate_smc_voltage_tables(struct radeon_device *rdev,
    122  1.1  riastrad 					RV770_SMC_STATETABLE *table);
    123  1.1  riastrad int cypress_populate_smc_initial_state(struct radeon_device *rdev,
    124  1.1  riastrad 				       struct radeon_ps *radeon_initial_state,
    125  1.1  riastrad 				       RV770_SMC_STATETABLE *table);
    126  1.1  riastrad u32 cypress_calculate_burst_time(struct radeon_device *rdev,
    127  1.1  riastrad 				 u32 engine_clock, u32 memory_clock);
    128  1.1  riastrad void cypress_notify_link_speed_change_before_state_change(struct radeon_device *rdev,
    129  1.1  riastrad 							  struct radeon_ps *radeon_new_state,
    130  1.1  riastrad 							  struct radeon_ps *radeon_current_state);
    131  1.1  riastrad int cypress_upload_sw_state(struct radeon_device *rdev,
    132  1.1  riastrad 			    struct radeon_ps *radeon_new_state);
    133  1.1  riastrad int cypress_upload_mc_reg_table(struct radeon_device *rdev,
    134  1.1  riastrad 				struct radeon_ps *radeon_new_state);
    135  1.1  riastrad void cypress_program_memory_timing_parameters(struct radeon_device *rdev,
    136  1.1  riastrad 					      struct radeon_ps *radeon_new_state);
    137  1.1  riastrad void cypress_notify_link_speed_change_after_state_change(struct radeon_device *rdev,
    138  1.1  riastrad 							 struct radeon_ps *radeon_new_state,
    139  1.1  riastrad 							 struct radeon_ps *radeon_current_state);
    140  1.1  riastrad int cypress_construct_voltage_tables(struct radeon_device *rdev);
    141  1.1  riastrad int cypress_get_mvdd_configuration(struct radeon_device *rdev);
    142  1.1  riastrad void cypress_enable_spread_spectrum(struct radeon_device *rdev,
    143  1.1  riastrad 				    bool enable);
    144  1.1  riastrad void cypress_enable_display_gap(struct radeon_device *rdev);
    145  1.1  riastrad int cypress_get_table_locations(struct radeon_device *rdev);
    146  1.1  riastrad int cypress_populate_mc_reg_table(struct radeon_device *rdev,
    147  1.1  riastrad 				  struct radeon_ps *radeon_boot_state);
    148  1.1  riastrad void cypress_program_response_times(struct radeon_device *rdev);
    149  1.1  riastrad int cypress_notify_smc_display_change(struct radeon_device *rdev,
    150  1.1  riastrad 				      bool has_display);
    151  1.1  riastrad void cypress_enable_sclk_control(struct radeon_device *rdev,
    152  1.1  riastrad 				 bool enable);
    153  1.1  riastrad void cypress_enable_mclk_control(struct radeon_device *rdev,
    154  1.1  riastrad 				 bool enable);
    155  1.1  riastrad void cypress_start_dpm(struct radeon_device *rdev);
    156  1.1  riastrad void cypress_advertise_gen2_capability(struct radeon_device *rdev);
    157  1.1  riastrad u32 cypress_map_clkf_to_ibias(struct radeon_device *rdev, u32 clkf);
    158  1.1  riastrad u8 cypress_get_mclk_frequency_ratio(struct radeon_device *rdev,
    159  1.1  riastrad 				    u32 memory_clock, bool strobe_mode);
    160  1.1  riastrad u8 cypress_get_strobe_mode_settings(struct radeon_device *rdev, u32 mclk);
    161  1.1  riastrad 
    162  1.1  riastrad #endif
    163