Path: blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
26517 views
/*1* Copyright 2014 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 __AMDGPU_ATOMBIOS_H__24#define __AMDGPU_ATOMBIOS_H__2526struct atom_clock_dividers {27u32 post_div;28union {29struct {30#ifdef __BIG_ENDIAN31u32 reserved : 6;32u32 whole_fb_div : 12;33u32 frac_fb_div : 14;34#else35u32 frac_fb_div : 14;36u32 whole_fb_div : 12;37u32 reserved : 6;38#endif39};40u32 fb_div;41};42u32 ref_div;43bool enable_post_div;44bool enable_dithen;45u32 vco_mode;46u32 real_clock;47/* added for CI */48u32 post_divider;49u32 flags;50};5152struct atom_mpll_param {53union {54struct {55#ifdef __BIG_ENDIAN56u32 reserved : 8;57u32 clkfrac : 12;58u32 clkf : 12;59#else60u32 clkf : 12;61u32 clkfrac : 12;62u32 reserved : 8;63#endif64};65u32 fb_div;66};67u32 post_div;68u32 bwcntl;69u32 dll_speed;70u32 vco_mode;71u32 yclk_sel;72u32 qdr;73u32 half_rate;74};7576#define MEM_TYPE_GDDR5 0x5077#define MEM_TYPE_GDDR4 0x4078#define MEM_TYPE_GDDR3 0x3079#define MEM_TYPE_DDR2 0x2080#define MEM_TYPE_GDDR1 0x1081#define MEM_TYPE_DDR3 0xb082#define MEM_TYPE_MASK 0xf08384struct atom_memory_info {85u8 mem_vendor;86u8 mem_type;87};8889#define MAX_AC_TIMING_ENTRIES 169091struct atom_memory_clock_range_table {92u8 num_entries;93u8 rsv[3];94u32 mclk[MAX_AC_TIMING_ENTRIES];95};9697#define VBIOS_MC_REGISTER_ARRAY_SIZE 3298#define VBIOS_MAX_AC_TIMING_ENTRIES 2099100struct atom_mc_reg_entry {101u32 mclk_max;102u32 mc_data[VBIOS_MC_REGISTER_ARRAY_SIZE];103};104105struct atom_mc_register_address {106u16 s1;107u8 pre_reg_data;108};109110struct atom_mc_reg_table {111u8 last;112u8 num_entries;113struct atom_mc_reg_entry mc_reg_table_entry[VBIOS_MAX_AC_TIMING_ENTRIES];114struct atom_mc_register_address mc_reg_address[VBIOS_MC_REGISTER_ARRAY_SIZE];115};116117#define MAX_VOLTAGE_ENTRIES 32118119struct atom_voltage_table_entry {120u16 value;121u32 smio_low;122};123124struct atom_voltage_table {125u32 count;126u32 mask_low;127u32 phase_delay;128struct atom_voltage_table_entry entries[MAX_VOLTAGE_ENTRIES];129};130131struct amdgpu_gpio_rec132amdgpu_atombios_lookup_gpio(struct amdgpu_device *adev,133u8 id);134135struct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *adev,136uint8_t id);137void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);138void amdgpu_atombios_oem_i2c_init(struct amdgpu_device *adev, u8 i2c_id);139140bool amdgpu_atombios_has_dce_engine_info(struct amdgpu_device *adev);141142bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev);143144int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);145146int amdgpu_atombios_get_gfx_info(struct amdgpu_device *adev);147148int amdgpu_atombios_get_vram_width(struct amdgpu_device *adev);149150bool amdgpu_atombios_get_asic_ss_info(struct amdgpu_device *adev,151struct amdgpu_atom_ss *ss,152int id, u32 clock);153154int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,155u8 clock_type,156u32 clock,157bool strobe_mode,158struct atom_clock_dividers *dividers);159160#ifdef CONFIG_DRM_AMDGPU_SI161int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,162u32 clock,163bool strobe_mode,164struct atom_mpll_param *mpll_param);165166int amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev,167u32 eng_clock, u32 mem_clock);168169bool170amdgpu_atombios_is_voltage_gpio(struct amdgpu_device *adev,171u8 voltage_type, u8 voltage_mode);172173int amdgpu_atombios_get_voltage_table(struct amdgpu_device *adev,174u8 voltage_type, u8 voltage_mode,175struct atom_voltage_table *voltage_table);176177int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev,178u8 module_index,179struct atom_mc_reg_table *reg_table);180int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type,181u16 voltage_id, u16 *voltage);182int amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device *adev,183u16 *voltage,184u16 leakage_idx);185void amdgpu_atombios_get_default_voltages(struct amdgpu_device *adev,186u16 *vddc, u16 *vddci, u16 *mvdd);187int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev,188u8 voltage_type,189u8 *svd_gpio_id, u8 *svc_gpio_id);190#endif191192bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);193194void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);195void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,196bool hung);197void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,198u32 backlight_level);199bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);200201void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);202int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,203u8 clock_type,204u32 clock,205bool strobe_mode,206struct atom_clock_dividers *dividers);207208int amdgpu_atombios_get_data_table(struct amdgpu_device *adev,209uint32_t table,210uint16_t *size,211uint8_t *frev,212uint8_t *crev,213uint8_t **addr);214215void amdgpu_atombios_fini(struct amdgpu_device *adev);216int amdgpu_atombios_init(struct amdgpu_device *adev);217int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev);218219#endif220221222