18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2011 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 __CYPRESS_DPM_H__
248c2ecf20Sopenharmony_ci#define __CYPRESS_DPM_H__
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "rv770_dpm.h"
278c2ecf20Sopenharmony_ci#include "evergreen_smc.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistruct evergreen_mc_reg_entry {
308c2ecf20Sopenharmony_ci	u32 mclk_max;
318c2ecf20Sopenharmony_ci	u32 mc_data[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE];
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct evergreen_mc_reg_table {
358c2ecf20Sopenharmony_ci	u8 last;
368c2ecf20Sopenharmony_ci	u8 num_entries;
378c2ecf20Sopenharmony_ci	u16 valid_flag;
388c2ecf20Sopenharmony_ci	struct evergreen_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
398c2ecf20Sopenharmony_ci	SMC_Evergreen_MCRegisterAddress mc_reg_address[SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE];
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistruct evergreen_ulv_param {
438c2ecf20Sopenharmony_ci	bool supported;
448c2ecf20Sopenharmony_ci	struct rv7xx_pl *pl;
458c2ecf20Sopenharmony_ci};
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistruct evergreen_arb_registers {
488c2ecf20Sopenharmony_ci	u32 mc_arb_dram_timing;
498c2ecf20Sopenharmony_ci	u32 mc_arb_dram_timing2;
508c2ecf20Sopenharmony_ci	u32 mc_arb_rfsh_rate;
518c2ecf20Sopenharmony_ci	u32 mc_arb_burst_time;
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistruct at {
558c2ecf20Sopenharmony_ci	u32 rlp;
568c2ecf20Sopenharmony_ci	u32 rmp;
578c2ecf20Sopenharmony_ci	u32 lhp;
588c2ecf20Sopenharmony_ci	u32 lmp;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistruct evergreen_power_info {
628c2ecf20Sopenharmony_ci	/* must be first! */
638c2ecf20Sopenharmony_ci	struct rv7xx_power_info rv7xx;
648c2ecf20Sopenharmony_ci	/* flags */
658c2ecf20Sopenharmony_ci	bool vddci_control;
668c2ecf20Sopenharmony_ci	bool dynamic_ac_timing;
678c2ecf20Sopenharmony_ci	bool abm;
688c2ecf20Sopenharmony_ci	bool mcls;
698c2ecf20Sopenharmony_ci	bool light_sleep;
708c2ecf20Sopenharmony_ci	bool memory_transition;
718c2ecf20Sopenharmony_ci	bool pcie_performance_request;
728c2ecf20Sopenharmony_ci	bool pcie_performance_request_registered;
738c2ecf20Sopenharmony_ci	bool sclk_deep_sleep;
748c2ecf20Sopenharmony_ci	bool dll_default_on;
758c2ecf20Sopenharmony_ci	bool ls_clock_gating;
768c2ecf20Sopenharmony_ci	bool smu_uvd_hs;
778c2ecf20Sopenharmony_ci	bool uvd_enabled;
788c2ecf20Sopenharmony_ci	/* stored values */
798c2ecf20Sopenharmony_ci	u16 acpi_vddci;
808c2ecf20Sopenharmony_ci	u8 mvdd_high_index;
818c2ecf20Sopenharmony_ci	u8 mvdd_low_index;
828c2ecf20Sopenharmony_ci	u32 mclk_edc_wr_enable_threshold;
838c2ecf20Sopenharmony_ci	struct evergreen_mc_reg_table mc_reg_table;
848c2ecf20Sopenharmony_ci	struct atom_voltage_table vddc_voltage_table;
858c2ecf20Sopenharmony_ci	struct atom_voltage_table vddci_voltage_table;
868c2ecf20Sopenharmony_ci	struct evergreen_arb_registers bootup_arb_registers;
878c2ecf20Sopenharmony_ci	struct evergreen_ulv_param ulv;
888c2ecf20Sopenharmony_ci	struct at ats[2];
898c2ecf20Sopenharmony_ci	/* smc offsets */
908c2ecf20Sopenharmony_ci	u16 mc_reg_table_start;
918c2ecf20Sopenharmony_ci	struct radeon_ps current_rps;
928c2ecf20Sopenharmony_ci	struct rv7xx_ps current_ps;
938c2ecf20Sopenharmony_ci	struct radeon_ps requested_rps;
948c2ecf20Sopenharmony_ci	struct rv7xx_ps requested_ps;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define CYPRESS_HASI_DFLT                               400000
988c2ecf20Sopenharmony_ci#define CYPRESS_MGCGTTLOCAL0_DFLT                       0x00000000
998c2ecf20Sopenharmony_ci#define CYPRESS_MGCGTTLOCAL1_DFLT                       0x00000000
1008c2ecf20Sopenharmony_ci#define CYPRESS_MGCGTTLOCAL2_DFLT                       0x00000000
1018c2ecf20Sopenharmony_ci#define CYPRESS_MGCGTTLOCAL3_DFLT                       0x00000000
1028c2ecf20Sopenharmony_ci#define CYPRESS_MGCGCGTSSMCTRL_DFLT                     0x81944bc0
1038c2ecf20Sopenharmony_ci#define REDWOOD_MGCGCGTSSMCTRL_DFLT                     0x6e944040
1048c2ecf20Sopenharmony_ci#define CEDAR_MGCGCGTSSMCTRL_DFLT                       0x46944040
1058c2ecf20Sopenharmony_ci#define CYPRESS_VRC_DFLT                                0xC00033
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_REMOVE_REGISTRY   0
1088c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_FORCE_LOWPOWER    1
1098c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_PECI_GEN1         2
1108c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_PECI_GEN2         3
1118c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_PECI_GEN3         4
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ciint cypress_convert_power_level_to_smc(struct radeon_device *rdev,
1148c2ecf20Sopenharmony_ci				       struct rv7xx_pl *pl,
1158c2ecf20Sopenharmony_ci				       RV770_SMC_HW_PERFORMANCE_LEVEL *level,
1168c2ecf20Sopenharmony_ci				       u8 watermark_level);
1178c2ecf20Sopenharmony_ciint cypress_populate_smc_acpi_state(struct radeon_device *rdev,
1188c2ecf20Sopenharmony_ci				    RV770_SMC_STATETABLE *table);
1198c2ecf20Sopenharmony_ciint cypress_populate_smc_voltage_tables(struct radeon_device *rdev,
1208c2ecf20Sopenharmony_ci					RV770_SMC_STATETABLE *table);
1218c2ecf20Sopenharmony_ciint cypress_populate_smc_initial_state(struct radeon_device *rdev,
1228c2ecf20Sopenharmony_ci				       struct radeon_ps *radeon_initial_state,
1238c2ecf20Sopenharmony_ci				       RV770_SMC_STATETABLE *table);
1248c2ecf20Sopenharmony_ciu32 cypress_calculate_burst_time(struct radeon_device *rdev,
1258c2ecf20Sopenharmony_ci				 u32 engine_clock, u32 memory_clock);
1268c2ecf20Sopenharmony_civoid cypress_notify_link_speed_change_before_state_change(struct radeon_device *rdev,
1278c2ecf20Sopenharmony_ci							  struct radeon_ps *radeon_new_state,
1288c2ecf20Sopenharmony_ci							  struct radeon_ps *radeon_current_state);
1298c2ecf20Sopenharmony_ciint cypress_upload_sw_state(struct radeon_device *rdev,
1308c2ecf20Sopenharmony_ci			    struct radeon_ps *radeon_new_state);
1318c2ecf20Sopenharmony_ciint cypress_upload_mc_reg_table(struct radeon_device *rdev,
1328c2ecf20Sopenharmony_ci				struct radeon_ps *radeon_new_state);
1338c2ecf20Sopenharmony_civoid cypress_program_memory_timing_parameters(struct radeon_device *rdev,
1348c2ecf20Sopenharmony_ci					      struct radeon_ps *radeon_new_state);
1358c2ecf20Sopenharmony_civoid cypress_notify_link_speed_change_after_state_change(struct radeon_device *rdev,
1368c2ecf20Sopenharmony_ci							 struct radeon_ps *radeon_new_state,
1378c2ecf20Sopenharmony_ci							 struct radeon_ps *radeon_current_state);
1388c2ecf20Sopenharmony_ciint cypress_construct_voltage_tables(struct radeon_device *rdev);
1398c2ecf20Sopenharmony_ciint cypress_get_mvdd_configuration(struct radeon_device *rdev);
1408c2ecf20Sopenharmony_civoid cypress_enable_spread_spectrum(struct radeon_device *rdev,
1418c2ecf20Sopenharmony_ci				    bool enable);
1428c2ecf20Sopenharmony_civoid cypress_enable_display_gap(struct radeon_device *rdev);
1438c2ecf20Sopenharmony_ciint cypress_get_table_locations(struct radeon_device *rdev);
1448c2ecf20Sopenharmony_ciint cypress_populate_mc_reg_table(struct radeon_device *rdev,
1458c2ecf20Sopenharmony_ci				  struct radeon_ps *radeon_boot_state);
1468c2ecf20Sopenharmony_civoid cypress_program_response_times(struct radeon_device *rdev);
1478c2ecf20Sopenharmony_ciint cypress_notify_smc_display_change(struct radeon_device *rdev,
1488c2ecf20Sopenharmony_ci				      bool has_display);
1498c2ecf20Sopenharmony_civoid cypress_enable_sclk_control(struct radeon_device *rdev,
1508c2ecf20Sopenharmony_ci				 bool enable);
1518c2ecf20Sopenharmony_civoid cypress_enable_mclk_control(struct radeon_device *rdev,
1528c2ecf20Sopenharmony_ci				 bool enable);
1538c2ecf20Sopenharmony_civoid cypress_start_dpm(struct radeon_device *rdev);
1548c2ecf20Sopenharmony_civoid cypress_advertise_gen2_capability(struct radeon_device *rdev);
1558c2ecf20Sopenharmony_ciu32 cypress_map_clkf_to_ibias(struct radeon_device *rdev, u32 clkf);
1568c2ecf20Sopenharmony_ciu8 cypress_get_mclk_frequency_ratio(struct radeon_device *rdev,
1578c2ecf20Sopenharmony_ci				    u32 memory_clock, bool strobe_mode);
1588c2ecf20Sopenharmony_ciu8 cypress_get_strobe_mode_settings(struct radeon_device *rdev, u32 mclk);
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#endif
161