nouveau_bios.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * Copyright 2007-2008 Nouveau Project
  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 (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __NOUVEAU_BIOS_H__
  24. #define __NOUVEAU_BIOS_H__
  25. #include "nvreg.h"
  26. #include "nouveau_i2c.h"
  27. #define DCB_MAX_NUM_ENTRIES 16
  28. #define DCB_MAX_NUM_I2C_ENTRIES 16
  29. #define DCB_MAX_NUM_GPIO_ENTRIES 32
  30. #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
  31. #define DCB_LOC_ON_CHIP 0
  32. struct dcb_entry {
  33. int index; /* may not be raw dcb index if merging has happened */
  34. uint8_t type;
  35. uint8_t i2c_index;
  36. uint8_t heads;
  37. uint8_t connector;
  38. uint8_t bus;
  39. uint8_t location;
  40. uint8_t or;
  41. bool duallink_possible;
  42. union {
  43. struct sor_conf {
  44. int link;
  45. } sorconf;
  46. struct {
  47. int maxfreq;
  48. } crtconf;
  49. struct {
  50. struct sor_conf sor;
  51. bool use_straps_for_mode;
  52. bool use_power_scripts;
  53. } lvdsconf;
  54. struct {
  55. bool has_component_output;
  56. } tvconf;
  57. struct {
  58. struct sor_conf sor;
  59. int link_nr;
  60. int link_bw;
  61. } dpconf;
  62. struct {
  63. struct sor_conf sor;
  64. } tmdsconf;
  65. };
  66. bool i2c_upper_default;
  67. };
  68. struct dcb_i2c_entry {
  69. uint8_t port_type;
  70. uint8_t read, write;
  71. struct nouveau_i2c_chan *chan;
  72. };
  73. struct parsed_dcb {
  74. int entries;
  75. struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
  76. struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
  77. };
  78. enum dcb_gpio_tag {
  79. DCB_GPIO_TVDAC0 = 0xc,
  80. DCB_GPIO_TVDAC1 = 0x2d,
  81. };
  82. struct dcb_gpio_entry {
  83. enum dcb_gpio_tag tag;
  84. int line;
  85. bool invert;
  86. };
  87. struct parsed_dcb_gpio {
  88. int entries;
  89. struct dcb_gpio_entry entry[DCB_MAX_NUM_GPIO_ENTRIES];
  90. };
  91. struct dcb_connector_table_entry {
  92. uint32_t entry;
  93. uint8_t type;
  94. uint8_t index;
  95. uint8_t gpio_tag;
  96. };
  97. struct dcb_connector_table {
  98. int entries;
  99. struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES];
  100. };
  101. struct bios_parsed_dcb {
  102. uint8_t version;
  103. struct parsed_dcb dcb;
  104. uint8_t *i2c_table;
  105. uint8_t i2c_default_indices;
  106. uint16_t gpio_table_ptr;
  107. struct parsed_dcb_gpio gpio;
  108. uint16_t connector_table_ptr;
  109. struct dcb_connector_table connector;
  110. };
  111. enum nouveau_encoder_type {
  112. OUTPUT_ANALOG = 0,
  113. OUTPUT_TV = 1,
  114. OUTPUT_TMDS = 2,
  115. OUTPUT_LVDS = 3,
  116. OUTPUT_DP = 6,
  117. OUTPUT_ANY = -1
  118. };
  119. enum nouveau_or {
  120. OUTPUT_A = (1 << 0),
  121. OUTPUT_B = (1 << 1),
  122. OUTPUT_C = (1 << 2)
  123. };
  124. enum LVDS_script {
  125. /* Order *does* matter here */
  126. LVDS_INIT = 1,
  127. LVDS_RESET,
  128. LVDS_BACKLIGHT_ON,
  129. LVDS_BACKLIGHT_OFF,
  130. LVDS_PANEL_ON,
  131. LVDS_PANEL_OFF
  132. };
  133. /* changing these requires matching changes to reg tables in nv_get_clock */
  134. #define MAX_PLL_TYPES 4
  135. enum pll_types {
  136. NVPLL,
  137. MPLL,
  138. VPLL1,
  139. VPLL2
  140. };
  141. struct pll_lims {
  142. struct {
  143. int minfreq;
  144. int maxfreq;
  145. int min_inputfreq;
  146. int max_inputfreq;
  147. uint8_t min_m;
  148. uint8_t max_m;
  149. uint8_t min_n;
  150. uint8_t max_n;
  151. } vco1, vco2;
  152. uint8_t max_log2p;
  153. /*
  154. * for most pre nv50 cards setting a log2P of 7 (the common max_log2p
  155. * value) is no different to 6 (at least for vplls) so allowing the MNP
  156. * calc to use 7 causes the generated clock to be out by a factor of 2.
  157. * however, max_log2p cannot be fixed-up during parsing as the
  158. * unmodified max_log2p value is still needed for setting mplls, hence
  159. * an additional max_usable_log2p member
  160. */
  161. uint8_t max_usable_log2p;
  162. uint8_t log2p_bias;
  163. uint8_t min_p;
  164. uint8_t max_p;
  165. int refclk;
  166. };
  167. struct nouveau_bios_info {
  168. struct parsed_dcb *dcb;
  169. uint8_t chip_version;
  170. uint32_t dactestval;
  171. uint32_t tvdactestval;
  172. uint8_t digital_min_front_porch;
  173. bool fp_no_ddc;
  174. };
  175. struct nvbios {
  176. struct drm_device *dev;
  177. struct nouveau_bios_info pub;
  178. uint8_t data[NV_PROM_SIZE];
  179. unsigned int length;
  180. bool execute;
  181. uint8_t major_version;
  182. uint8_t feature_byte;
  183. bool is_mobile;
  184. uint32_t fmaxvco, fminvco;
  185. bool old_style_init;
  186. uint16_t init_script_tbls_ptr;
  187. uint16_t extra_init_script_tbl_ptr;
  188. uint16_t macro_index_tbl_ptr;
  189. uint16_t macro_tbl_ptr;
  190. uint16_t condition_tbl_ptr;
  191. uint16_t io_condition_tbl_ptr;
  192. uint16_t io_flag_condition_tbl_ptr;
  193. uint16_t init_function_tbl_ptr;
  194. uint16_t pll_limit_tbl_ptr;
  195. uint16_t ram_restrict_tbl_ptr;
  196. uint8_t ram_restrict_group_count;
  197. uint16_t some_script_ptr; /* BIT I + 14 */
  198. uint16_t init96_tbl_ptr; /* BIT I + 16 */
  199. struct bios_parsed_dcb bdcb;
  200. struct {
  201. int crtchead;
  202. /* these need remembering across suspend */
  203. uint32_t saved_nv_pfb_cfg0;
  204. } state;
  205. struct {
  206. struct dcb_entry *output;
  207. uint16_t script_table_ptr;
  208. uint16_t dp_table_ptr;
  209. } display;
  210. struct {
  211. uint16_t fptablepointer; /* also used by tmds */
  212. uint16_t fpxlatetableptr;
  213. int xlatwidth;
  214. uint16_t lvdsmanufacturerpointer;
  215. uint16_t fpxlatemanufacturertableptr;
  216. uint16_t mode_ptr;
  217. uint16_t xlated_entry;
  218. bool power_off_for_reset;
  219. bool reset_after_pclk_change;
  220. bool dual_link;
  221. bool link_c_increment;
  222. bool BITbit1;
  223. bool if_is_24bit;
  224. int duallink_transition_clk;
  225. uint8_t strapless_is_24bit;
  226. uint8_t *edid;
  227. /* will need resetting after suspend */
  228. int last_script_invoc;
  229. bool lvds_init_run;
  230. } fp;
  231. struct {
  232. uint16_t output0_script_ptr;
  233. uint16_t output1_script_ptr;
  234. } tmds;
  235. struct {
  236. uint16_t mem_init_tbl_ptr;
  237. uint16_t sdr_seq_tbl_ptr;
  238. uint16_t ddr_seq_tbl_ptr;
  239. struct {
  240. uint8_t crt, tv, panel;
  241. } i2c_indices;
  242. uint16_t lvds_single_a_script_ptr;
  243. } legacy;
  244. };
  245. #endif