11.1Sriastrad/* $NetBSD: amdgpu_atombios.h,v 1.3 2021/12/18 23:44:58 riastradh Exp $ */ 21.1Sriastrad 31.1Sriastrad/* 41.1Sriastrad * Copyright 2014 Advanced Micro Devices, Inc. 51.1Sriastrad * 61.1Sriastrad * Permission is hereby granted, free of charge, to any person obtaining a 71.1Sriastrad * copy of this software and associated documentation files (the "Software"), 81.1Sriastrad * to deal in the Software without restriction, including without limitation 91.1Sriastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 101.1Sriastrad * and/or sell copies of the Software, and to permit persons to whom the 111.1Sriastrad * Software is furnished to do so, subject to the following conditions: 121.1Sriastrad * 131.1Sriastrad * The above copyright notice and this permission notice shall be included in 141.1Sriastrad * all copies or substantial portions of the Software. 151.1Sriastrad * 161.1Sriastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 171.1Sriastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 181.1Sriastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 191.1Sriastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 201.1Sriastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 211.1Sriastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 221.1Sriastrad * OTHER DEALINGS IN THE SOFTWARE. 231.1Sriastrad * 241.1Sriastrad */ 251.1Sriastrad 261.1Sriastrad#ifndef __AMDGPU_ATOMBIOS_H__ 271.1Sriastrad#define __AMDGPU_ATOMBIOS_H__ 281.1Sriastrad 291.1Sriastradstruct atom_clock_dividers { 301.1Sriastrad u32 post_div; 311.1Sriastrad union { 321.1Sriastrad struct { 331.1Sriastrad#ifdef __BIG_ENDIAN 341.1Sriastrad u32 reserved : 6; 351.1Sriastrad u32 whole_fb_div : 12; 361.1Sriastrad u32 frac_fb_div : 14; 371.1Sriastrad#else 381.1Sriastrad u32 frac_fb_div : 14; 391.1Sriastrad u32 whole_fb_div : 12; 401.1Sriastrad u32 reserved : 6; 411.1Sriastrad#endif 421.1Sriastrad }; 431.1Sriastrad u32 fb_div; 441.1Sriastrad }; 451.1Sriastrad u32 ref_div; 461.1Sriastrad bool enable_post_div; 471.1Sriastrad bool enable_dithen; 481.1Sriastrad u32 vco_mode; 491.1Sriastrad u32 real_clock; 501.1Sriastrad /* added for CI */ 511.1Sriastrad u32 post_divider; 521.1Sriastrad u32 flags; 531.1Sriastrad}; 541.1Sriastrad 551.1Sriastradstruct atom_mpll_param { 561.1Sriastrad union { 571.1Sriastrad struct { 581.1Sriastrad#ifdef __BIG_ENDIAN 591.1Sriastrad u32 reserved : 8; 601.1Sriastrad u32 clkfrac : 12; 611.1Sriastrad u32 clkf : 12; 621.1Sriastrad#else 631.1Sriastrad u32 clkf : 12; 641.1Sriastrad u32 clkfrac : 12; 651.1Sriastrad u32 reserved : 8; 661.1Sriastrad#endif 671.1Sriastrad }; 681.1Sriastrad u32 fb_div; 691.1Sriastrad }; 701.1Sriastrad u32 post_div; 711.1Sriastrad u32 bwcntl; 721.1Sriastrad u32 dll_speed; 731.1Sriastrad u32 vco_mode; 741.1Sriastrad u32 yclk_sel; 751.1Sriastrad u32 qdr; 761.1Sriastrad u32 half_rate; 771.1Sriastrad}; 781.1Sriastrad 791.1Sriastrad#define MEM_TYPE_GDDR5 0x50 801.1Sriastrad#define MEM_TYPE_GDDR4 0x40 811.1Sriastrad#define MEM_TYPE_GDDR3 0x30 821.1Sriastrad#define MEM_TYPE_DDR2 0x20 831.1Sriastrad#define MEM_TYPE_GDDR1 0x10 841.1Sriastrad#define MEM_TYPE_DDR3 0xb0 851.1Sriastrad#define MEM_TYPE_MASK 0xf0 861.1Sriastrad 871.1Sriastradstruct atom_memory_info { 881.1Sriastrad u8 mem_vendor; 891.1Sriastrad u8 mem_type; 901.1Sriastrad}; 911.1Sriastrad 921.1Sriastrad#define MAX_AC_TIMING_ENTRIES 16 931.1Sriastrad 941.1Sriastradstruct atom_memory_clock_range_table 951.1Sriastrad{ 961.1Sriastrad u8 num_entries; 971.1Sriastrad u8 rsv[3]; 981.1Sriastrad u32 mclk[MAX_AC_TIMING_ENTRIES]; 991.1Sriastrad}; 1001.1Sriastrad 1011.1Sriastrad#define VBIOS_MC_REGISTER_ARRAY_SIZE 32 1021.1Sriastrad#define VBIOS_MAX_AC_TIMING_ENTRIES 20 1031.1Sriastrad 1041.1Sriastradstruct atom_mc_reg_entry { 1051.1Sriastrad u32 mclk_max; 1061.1Sriastrad u32 mc_data[VBIOS_MC_REGISTER_ARRAY_SIZE]; 1071.1Sriastrad}; 1081.1Sriastrad 1091.1Sriastradstruct atom_mc_register_address { 1101.1Sriastrad u16 s1; 1111.1Sriastrad u8 pre_reg_data; 1121.1Sriastrad}; 1131.1Sriastrad 1141.1Sriastradstruct atom_mc_reg_table { 1151.1Sriastrad u8 last; 1161.1Sriastrad u8 num_entries; 1171.1Sriastrad struct atom_mc_reg_entry mc_reg_table_entry[VBIOS_MAX_AC_TIMING_ENTRIES]; 1181.1Sriastrad struct atom_mc_register_address mc_reg_address[VBIOS_MC_REGISTER_ARRAY_SIZE]; 1191.1Sriastrad}; 1201.1Sriastrad 1211.1Sriastrad#define MAX_VOLTAGE_ENTRIES 32 1221.1Sriastrad 1231.1Sriastradstruct atom_voltage_table_entry 1241.1Sriastrad{ 1251.1Sriastrad u16 value; 1261.1Sriastrad u32 smio_low; 1271.1Sriastrad}; 1281.1Sriastrad 1291.1Sriastradstruct atom_voltage_table 1301.1Sriastrad{ 1311.1Sriastrad u32 count; 1321.1Sriastrad u32 mask_low; 1331.1Sriastrad u32 phase_delay; 1341.1Sriastrad struct atom_voltage_table_entry entries[MAX_VOLTAGE_ENTRIES]; 1351.1Sriastrad}; 1361.1Sriastrad 1371.1Sriastradstruct amdgpu_gpio_rec 1381.1Sriastradamdgpu_atombios_lookup_gpio(struct amdgpu_device *adev, 1391.1Sriastrad u8 id); 1401.1Sriastrad 1411.1Sriastradstruct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *adev, 1421.1Sriastrad uint8_t id); 1431.1Sriastradvoid amdgpu_atombios_i2c_init(struct amdgpu_device *adev); 1441.1Sriastrad 1451.3Sriastradbool amdgpu_atombios_has_dce_engine_info(struct amdgpu_device *adev); 1461.3Sriastrad 1471.1Sriastradbool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev); 1481.1Sriastrad 1491.1Sriastradint amdgpu_atombios_get_clock_info(struct amdgpu_device *adev); 1501.1Sriastrad 1511.3Sriastradint amdgpu_atombios_get_gfx_info(struct amdgpu_device *adev); 1521.3Sriastrad 1531.3Sriastradint amdgpu_atombios_get_vram_width(struct amdgpu_device *adev); 1541.3Sriastrad 1551.1Sriastradbool amdgpu_atombios_get_asic_ss_info(struct amdgpu_device *adev, 1561.1Sriastrad struct amdgpu_atom_ss *ss, 1571.1Sriastrad int id, u32 clock); 1581.1Sriastrad 1591.1Sriastradint amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, 1601.1Sriastrad u8 clock_type, 1611.1Sriastrad u32 clock, 1621.1Sriastrad bool strobe_mode, 1631.1Sriastrad struct atom_clock_dividers *dividers); 1641.1Sriastrad 1651.1Sriastradint amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev, 1661.1Sriastrad u32 clock, 1671.1Sriastrad bool strobe_mode, 1681.1Sriastrad struct atom_mpll_param *mpll_param); 1691.1Sriastrad 1701.1Sriastradvoid amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev, 1711.1Sriastrad u32 eng_clock, u32 mem_clock); 1721.1Sriastrad 1731.1Sriastradint amdgpu_atombios_get_leakage_id_from_vbios(struct amdgpu_device *adev, 1741.1Sriastrad u16 *leakage_id); 1751.1Sriastrad 1761.1Sriastradint amdgpu_atombios_get_leakage_vddc_based_on_leakage_params(struct amdgpu_device *adev, 1771.1Sriastrad u16 *vddc, u16 *vddci, 1781.1Sriastrad u16 virtual_voltage_id, 1791.1Sriastrad u16 vbios_voltage_id); 1801.1Sriastrad 1811.1Sriastradint amdgpu_atombios_get_voltage_evv(struct amdgpu_device *adev, 1821.1Sriastrad u16 virtual_voltage_id, 1831.1Sriastrad u16 *voltage); 1841.1Sriastrad 1851.1Sriastradbool 1861.1Sriastradamdgpu_atombios_is_voltage_gpio(struct amdgpu_device *adev, 1871.1Sriastrad u8 voltage_type, u8 voltage_mode); 1881.1Sriastrad 1891.1Sriastradint amdgpu_atombios_get_voltage_table(struct amdgpu_device *adev, 1901.1Sriastrad u8 voltage_type, u8 voltage_mode, 1911.1Sriastrad struct atom_voltage_table *voltage_table); 1921.1Sriastrad 1931.1Sriastradint amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev, 1941.1Sriastrad u8 module_index, 1951.1Sriastrad struct atom_mc_reg_table *reg_table); 1961.1Sriastrad 1971.3Sriastradbool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev); 1981.3Sriastrad 1991.1Sriastradvoid amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock); 2001.3Sriastradvoid amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, 2011.3Sriastrad bool hung); 2021.3Sriastradbool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev); 2031.1Sriastrad 2041.1Sriastradvoid amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); 2051.3Sriastradint amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, 2061.3Sriastrad u16 voltage_id, u16 *voltage); 2071.3Sriastradint amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(struct amdgpu_device *adev, 2081.3Sriastrad u16 *voltage, 2091.3Sriastrad u16 leakage_idx); 2101.3Sriastradvoid amdgpu_atombios_get_default_voltages(struct amdgpu_device *adev, 2111.3Sriastrad u16 *vddc, u16 *vddci, u16 *mvdd); 2121.3Sriastradint amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, 2131.3Sriastrad u8 clock_type, 2141.3Sriastrad u32 clock, 2151.3Sriastrad bool strobe_mode, 2161.3Sriastrad struct atom_clock_dividers *dividers); 2171.3Sriastradint amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, 2181.3Sriastrad u8 voltage_type, 2191.3Sriastrad u8 *svd_gpio_id, u8 *svc_gpio_id); 2201.3Sriastrad 2211.3Sriastradvoid amdgpu_atombios_fini(struct amdgpu_device *adev); 2221.3Sriastradint amdgpu_atombios_init(struct amdgpu_device *adev); 2231.1Sriastrad 2241.1Sriastrad#endif 225