amdgpu_atombios.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright 2014 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef __AMDGPU_ATOMBIOS_H__
  24. #define __AMDGPU_ATOMBIOS_H__
  25. struct atom_clock_dividers {
  26. u32 post_div;
  27. union {
  28. struct {
  29. #ifdef __BIG_ENDIAN
  30. u32 reserved : 6;
  31. u32 whole_fb_div : 12;
  32. u32 frac_fb_div : 14;
  33. #else
  34. u32 frac_fb_div : 14;
  35. u32 whole_fb_div : 12;
  36. u32 reserved : 6;
  37. #endif
  38. };
  39. u32 fb_div;
  40. };
  41. u32 ref_div;
  42. bool enable_post_div;
  43. bool enable_dithen;
  44. u32 vco_mode;
  45. u32 real_clock;
  46. /* added for CI */
  47. u32 post_divider;
  48. u32 flags;
  49. };
  50. struct atom_mpll_param {
  51. union {
  52. struct {
  53. #ifdef __BIG_ENDIAN
  54. u32 reserved : 8;
  55. u32 clkfrac : 12;
  56. u32 clkf : 12;
  57. #else
  58. u32 clkf : 12;
  59. u32 clkfrac : 12;
  60. u32 reserved : 8;
  61. #endif
  62. };
  63. u32 fb_div;
  64. };
  65. u32 post_div;
  66. u32 bwcntl;
  67. u32 dll_speed;
  68. u32 vco_mode;
  69. u32 yclk_sel;
  70. u32 qdr;
  71. u32 half_rate;
  72. };
  73. #define MEM_TYPE_GDDR5 0x50
  74. #define MEM_TYPE_GDDR4 0x40
  75. #define MEM_TYPE_GDDR3 0x30
  76. #define MEM_TYPE_DDR2 0x20
  77. #define MEM_TYPE_GDDR1 0x10
  78. #define MEM_TYPE_DDR3 0xb0
  79. #define MEM_TYPE_MASK 0xf0
  80. struct atom_memory_info {
  81. u8 mem_vendor;
  82. u8 mem_type;
  83. };
  84. #define MAX_AC_TIMING_ENTRIES 16
  85. struct atom_memory_clock_range_table
  86. {
  87. u8 num_entries;
  88. u8 rsv[3];
  89. u32 mclk[MAX_AC_TIMING_ENTRIES];
  90. };
  91. #define VBIOS_MC_REGISTER_ARRAY_SIZE 32
  92. #define VBIOS_MAX_AC_TIMING_ENTRIES 20
  93. struct atom_mc_reg_entry {
  94. u32 mclk_max;
  95. u32 mc_data[VBIOS_MC_REGISTER_ARRAY_SIZE];
  96. };
  97. struct atom_mc_register_address {
  98. u16 s1;
  99. u8 pre_reg_data;
  100. };
  101. struct atom_mc_reg_table {
  102. u8 last;
  103. u8 num_entries;
  104. struct atom_mc_reg_entry mc_reg_table_entry[VBIOS_MAX_AC_TIMING_ENTRIES];
  105. struct atom_mc_register_address mc_reg_address[VBIOS_MC_REGISTER_ARRAY_SIZE];
  106. };
  107. #define MAX_VOLTAGE_ENTRIES 32
  108. struct atom_voltage_table_entry
  109. {
  110. u16 value;
  111. u32 smio_low;
  112. };
  113. struct atom_voltage_table
  114. {
  115. u32 count;
  116. u32 mask_low;
  117. u32 phase_delay;
  118. struct atom_voltage_table_entry entries[MAX_VOLTAGE_ENTRIES];
  119. };
  120. struct amdgpu_gpio_rec
  121. amdgpu_atombios_lookup_gpio(struct amdgpu_device *adev,
  122. u8 id);
  123. struct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *adev,
  124. uint8_t id);
  125. void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);
  126. bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev);
  127. int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
  128. bool amdgpu_atombios_get_asic_ss_info(struct amdgpu_device *adev,
  129. struct amdgpu_atom_ss *ss,
  130. int id, u32 clock);
  131. int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,
  132. u8 clock_type,
  133. u32 clock,
  134. bool strobe_mode,
  135. struct atom_clock_dividers *dividers);
  136. int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,
  137. u32 clock,
  138. bool strobe_mode,
  139. struct atom_mpll_param *mpll_param);
  140. uint32_t amdgpu_atombios_get_engine_clock(struct amdgpu_device *adev);
  141. uint32_t amdgpu_atombios_get_memory_clock(struct amdgpu_device *adev);
  142. void amdgpu_atombios_set_engine_clock(struct amdgpu_device *adev,
  143. uint32_t eng_clock);
  144. void amdgpu_atombios_set_memory_clock(struct amdgpu_device *adev,
  145. uint32_t mem_clock);
  146. void amdgpu_atombios_set_voltage(struct amdgpu_device *adev,
  147. u16 voltage_level,
  148. u8 voltage_type);
  149. void amdgpu_atombios_set_engine_dram_timings(struct amdgpu_device *adev,
  150. u32 eng_clock, u32 mem_clock);
  151. int amdgpu_atombios_get_leakage_id_from_vbios(struct amdgpu_device *adev,
  152. u16 *leakage_id);
  153. int amdgpu_atombios_get_leakage_vddc_based_on_leakage_params(struct amdgpu_device *adev,
  154. u16 *vddc, u16 *vddci,
  155. u16 virtual_voltage_id,
  156. u16 vbios_voltage_id);
  157. int amdgpu_atombios_get_voltage_evv(struct amdgpu_device *adev,
  158. u16 virtual_voltage_id,
  159. u16 *voltage);
  160. bool
  161. amdgpu_atombios_is_voltage_gpio(struct amdgpu_device *adev,
  162. u8 voltage_type, u8 voltage_mode);
  163. int amdgpu_atombios_get_voltage_table(struct amdgpu_device *adev,
  164. u8 voltage_type, u8 voltage_mode,
  165. struct atom_voltage_table *voltage_table);
  166. int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev,
  167. u8 module_index,
  168. struct atom_mc_reg_table *reg_table);
  169. void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
  170. void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev);
  171. void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev);
  172. void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev);
  173. void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
  174. #endif