162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2011 Advanced Micro Devices, Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1262306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci */ 2362306a36Sopenharmony_ci#ifndef __RV770_SMC_H__ 2462306a36Sopenharmony_ci#define __RV770_SMC_H__ 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#include "ppsmc.h" 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#pragma pack(push, 1) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define RV770_SMC_TABLE_ADDRESS 0xB000 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 3 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistruct RV770_SMC_SCLK_VALUE 3562306a36Sopenharmony_ci{ 3662306a36Sopenharmony_ci uint32_t vCG_SPLL_FUNC_CNTL; 3762306a36Sopenharmony_ci uint32_t vCG_SPLL_FUNC_CNTL_2; 3862306a36Sopenharmony_ci uint32_t vCG_SPLL_FUNC_CNTL_3; 3962306a36Sopenharmony_ci uint32_t vCG_SPLL_SPREAD_SPECTRUM; 4062306a36Sopenharmony_ci uint32_t vCG_SPLL_SPREAD_SPECTRUM_2; 4162306a36Sopenharmony_ci uint32_t sclk_value; 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_citypedef struct RV770_SMC_SCLK_VALUE RV770_SMC_SCLK_VALUE; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistruct RV770_SMC_MCLK_VALUE 4762306a36Sopenharmony_ci{ 4862306a36Sopenharmony_ci uint32_t vMPLL_AD_FUNC_CNTL; 4962306a36Sopenharmony_ci uint32_t vMPLL_AD_FUNC_CNTL_2; 5062306a36Sopenharmony_ci uint32_t vMPLL_DQ_FUNC_CNTL; 5162306a36Sopenharmony_ci uint32_t vMPLL_DQ_FUNC_CNTL_2; 5262306a36Sopenharmony_ci uint32_t vMCLK_PWRMGT_CNTL; 5362306a36Sopenharmony_ci uint32_t vDLL_CNTL; 5462306a36Sopenharmony_ci uint32_t vMPLL_SS; 5562306a36Sopenharmony_ci uint32_t vMPLL_SS2; 5662306a36Sopenharmony_ci uint32_t mclk_value; 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_citypedef struct RV770_SMC_MCLK_VALUE RV770_SMC_MCLK_VALUE; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistruct RV730_SMC_MCLK_VALUE 6362306a36Sopenharmony_ci{ 6462306a36Sopenharmony_ci uint32_t vMCLK_PWRMGT_CNTL; 6562306a36Sopenharmony_ci uint32_t vDLL_CNTL; 6662306a36Sopenharmony_ci uint32_t vMPLL_FUNC_CNTL; 6762306a36Sopenharmony_ci uint32_t vMPLL_FUNC_CNTL2; 6862306a36Sopenharmony_ci uint32_t vMPLL_FUNC_CNTL3; 6962306a36Sopenharmony_ci uint32_t vMPLL_SS; 7062306a36Sopenharmony_ci uint32_t vMPLL_SS2; 7162306a36Sopenharmony_ci uint32_t mclk_value; 7262306a36Sopenharmony_ci}; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_citypedef struct RV730_SMC_MCLK_VALUE RV730_SMC_MCLK_VALUE; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistruct RV770_SMC_VOLTAGE_VALUE 7762306a36Sopenharmony_ci{ 7862306a36Sopenharmony_ci uint16_t value; 7962306a36Sopenharmony_ci uint8_t index; 8062306a36Sopenharmony_ci uint8_t padding; 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_citypedef struct RV770_SMC_VOLTAGE_VALUE RV770_SMC_VOLTAGE_VALUE; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciunion RV7XX_SMC_MCLK_VALUE 8662306a36Sopenharmony_ci{ 8762306a36Sopenharmony_ci RV770_SMC_MCLK_VALUE mclk770; 8862306a36Sopenharmony_ci RV730_SMC_MCLK_VALUE mclk730; 8962306a36Sopenharmony_ci}; 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_citypedef union RV7XX_SMC_MCLK_VALUE RV7XX_SMC_MCLK_VALUE, *LPRV7XX_SMC_MCLK_VALUE; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistruct RV770_SMC_HW_PERFORMANCE_LEVEL 9462306a36Sopenharmony_ci{ 9562306a36Sopenharmony_ci uint8_t arbValue; 9662306a36Sopenharmony_ci union{ 9762306a36Sopenharmony_ci uint8_t seqValue; 9862306a36Sopenharmony_ci uint8_t ACIndex; 9962306a36Sopenharmony_ci }; 10062306a36Sopenharmony_ci uint8_t displayWatermark; 10162306a36Sopenharmony_ci uint8_t gen2PCIE; 10262306a36Sopenharmony_ci uint8_t gen2XSP; 10362306a36Sopenharmony_ci uint8_t backbias; 10462306a36Sopenharmony_ci uint8_t strobeMode; 10562306a36Sopenharmony_ci uint8_t mcFlags; 10662306a36Sopenharmony_ci uint32_t aT; 10762306a36Sopenharmony_ci uint32_t bSP; 10862306a36Sopenharmony_ci RV770_SMC_SCLK_VALUE sclk; 10962306a36Sopenharmony_ci RV7XX_SMC_MCLK_VALUE mclk; 11062306a36Sopenharmony_ci RV770_SMC_VOLTAGE_VALUE vddc; 11162306a36Sopenharmony_ci RV770_SMC_VOLTAGE_VALUE mvdd; 11262306a36Sopenharmony_ci RV770_SMC_VOLTAGE_VALUE vddci; 11362306a36Sopenharmony_ci uint8_t reserved1; 11462306a36Sopenharmony_ci uint8_t reserved2; 11562306a36Sopenharmony_ci uint8_t stateFlags; 11662306a36Sopenharmony_ci uint8_t padding; 11762306a36Sopenharmony_ci}; 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define SMC_STROBE_RATIO 0x0F 12062306a36Sopenharmony_ci#define SMC_STROBE_ENABLE 0x10 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#define SMC_MC_EDC_RD_FLAG 0x01 12362306a36Sopenharmony_ci#define SMC_MC_EDC_WR_FLAG 0x02 12462306a36Sopenharmony_ci#define SMC_MC_RTT_ENABLE 0x04 12562306a36Sopenharmony_ci#define SMC_MC_STUTTER_EN 0x08 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_citypedef struct RV770_SMC_HW_PERFORMANCE_LEVEL RV770_SMC_HW_PERFORMANCE_LEVEL; 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_cistruct RV770_SMC_SWSTATE 13062306a36Sopenharmony_ci{ 13162306a36Sopenharmony_ci uint8_t flags; 13262306a36Sopenharmony_ci uint8_t padding1; 13362306a36Sopenharmony_ci uint8_t padding2; 13462306a36Sopenharmony_ci uint8_t padding3; 13562306a36Sopenharmony_ci RV770_SMC_HW_PERFORMANCE_LEVEL levels[RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE]; 13662306a36Sopenharmony_ci}; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_citypedef struct RV770_SMC_SWSTATE RV770_SMC_SWSTATE; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci#define RV770_SMC_VOLTAGEMASK_VDDC 0 14162306a36Sopenharmony_ci#define RV770_SMC_VOLTAGEMASK_MVDD 1 14262306a36Sopenharmony_ci#define RV770_SMC_VOLTAGEMASK_VDDCI 2 14362306a36Sopenharmony_ci#define RV770_SMC_VOLTAGEMASK_MAX 4 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistruct RV770_SMC_VOLTAGEMASKTABLE 14662306a36Sopenharmony_ci{ 14762306a36Sopenharmony_ci uint8_t highMask[RV770_SMC_VOLTAGEMASK_MAX]; 14862306a36Sopenharmony_ci uint32_t lowMask[RV770_SMC_VOLTAGEMASK_MAX]; 14962306a36Sopenharmony_ci}; 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_citypedef struct RV770_SMC_VOLTAGEMASKTABLE RV770_SMC_VOLTAGEMASKTABLE; 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci#define MAX_NO_VREG_STEPS 32 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_cistruct RV770_SMC_STATETABLE 15662306a36Sopenharmony_ci{ 15762306a36Sopenharmony_ci uint8_t thermalProtectType; 15862306a36Sopenharmony_ci uint8_t systemFlags; 15962306a36Sopenharmony_ci uint8_t maxVDDCIndexInPPTable; 16062306a36Sopenharmony_ci uint8_t extraFlags; 16162306a36Sopenharmony_ci uint8_t highSMIO[MAX_NO_VREG_STEPS]; 16262306a36Sopenharmony_ci uint32_t lowSMIO[MAX_NO_VREG_STEPS]; 16362306a36Sopenharmony_ci RV770_SMC_VOLTAGEMASKTABLE voltageMaskTable; 16462306a36Sopenharmony_ci RV770_SMC_SWSTATE initialState; 16562306a36Sopenharmony_ci RV770_SMC_SWSTATE ACPIState; 16662306a36Sopenharmony_ci RV770_SMC_SWSTATE driverState; 16762306a36Sopenharmony_ci RV770_SMC_SWSTATE ULVState; 16862306a36Sopenharmony_ci}; 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_citypedef struct RV770_SMC_STATETABLE RV770_SMC_STATETABLE; 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci#define PPSMC_STATEFLAG_AUTO_PULSE_SKIP 0x01 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci#pragma pack(pop) 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTERS_START 0x104 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0 17962306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_baby_step_timer 0x8 18062306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_delay_bbias 0xC 18162306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_delay_vreg 0x10 18262306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_delay_acpi 0x2C 18362306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_seq_index 0x64 18462306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_mvdd_chg_time 0x68 18562306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_mclk_switch_lim 0x78 18662306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_mc_block_delay 0x90 18762306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C 18862306a36Sopenharmony_ci#define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ciint rv770_copy_bytes_to_smc(struct radeon_device *rdev, 19162306a36Sopenharmony_ci u16 smc_start_address, const u8 *src, 19262306a36Sopenharmony_ci u16 byte_count, u16 limit); 19362306a36Sopenharmony_civoid rv770_start_smc(struct radeon_device *rdev); 19462306a36Sopenharmony_civoid rv770_reset_smc(struct radeon_device *rdev); 19562306a36Sopenharmony_civoid rv770_stop_smc_clock(struct radeon_device *rdev); 19662306a36Sopenharmony_civoid rv770_start_smc_clock(struct radeon_device *rdev); 19762306a36Sopenharmony_cibool rv770_is_smc_running(struct radeon_device *rdev); 19862306a36Sopenharmony_ciPPSMC_Result rv770_send_msg_to_smc(struct radeon_device *rdev, PPSMC_Msg msg); 19962306a36Sopenharmony_ciPPSMC_Result rv770_wait_for_smc_inactive(struct radeon_device *rdev); 20062306a36Sopenharmony_ciint rv770_read_smc_sram_dword(struct radeon_device *rdev, 20162306a36Sopenharmony_ci u16 smc_address, u32 *value, u16 limit); 20262306a36Sopenharmony_ciint rv770_write_smc_sram_dword(struct radeon_device *rdev, 20362306a36Sopenharmony_ci u16 smc_address, u32 value, u16 limit); 20462306a36Sopenharmony_ciint rv770_load_smc_ucode(struct radeon_device *rdev, 20562306a36Sopenharmony_ci u16 limit); 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci#endif 208