nouveau_bios.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. #define DCB_MAX_NUM_ENTRIES 16
  27. #define DCB_MAX_NUM_I2C_ENTRIES 16
  28. #define DCB_MAX_NUM_GPIO_ENTRIES 32
  29. #define DCB_MAX_NUM_CONNECTOR_ENTRIES 16
  30. #define DCB_LOC_ON_CHIP 0
  31. #define ROM16(x) le16_to_cpu(*(u16 *)&(x))
  32. #define ROM32(x) le32_to_cpu(*(u32 *)&(x))
  33. #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
  34. #define ROM64(x) le64_to_cpu(*(u64 *)&(x))
  35. #define ROMPTR(d,x) ({ \
  36. struct drm_nouveau_private *dev_priv = (d)->dev_private; \
  37. ROM16(x) ? &dev_priv->vbios.data[ROM16(x)] : NULL; \
  38. })
  39. struct bit_entry {
  40. uint8_t id;
  41. uint8_t version;
  42. uint16_t length;
  43. uint16_t offset;
  44. uint8_t *data;
  45. };
  46. int bit_table(struct drm_device *, u8 id, struct bit_entry *);
  47. enum dcb_connector_type {
  48. DCB_CONNECTOR_VGA = 0x00,
  49. DCB_CONNECTOR_TV_0 = 0x10,
  50. DCB_CONNECTOR_TV_1 = 0x11,
  51. DCB_CONNECTOR_TV_3 = 0x13,
  52. DCB_CONNECTOR_DVI_I = 0x30,
  53. DCB_CONNECTOR_DVI_D = 0x31,
  54. DCB_CONNECTOR_DMS59_0 = 0x38,
  55. DCB_CONNECTOR_DMS59_1 = 0x39,
  56. DCB_CONNECTOR_LVDS = 0x40,
  57. DCB_CONNECTOR_LVDS_SPWG = 0x41,
  58. DCB_CONNECTOR_DP = 0x46,
  59. DCB_CONNECTOR_eDP = 0x47,
  60. DCB_CONNECTOR_HDMI_0 = 0x60,
  61. DCB_CONNECTOR_HDMI_1 = 0x61,
  62. DCB_CONNECTOR_DMS59_DP0 = 0x64,
  63. DCB_CONNECTOR_DMS59_DP1 = 0x65,
  64. DCB_CONNECTOR_NONE = 0xff
  65. };
  66. #include <subdev/bios/dcb.h>
  67. struct dcb_table {
  68. uint8_t version;
  69. int entries;
  70. struct dcb_output entry[DCB_MAX_NUM_ENTRIES];
  71. };
  72. enum nouveau_or {
  73. DCB_OUTPUT_A = (1 << 0),
  74. DCB_OUTPUT_B = (1 << 1),
  75. DCB_OUTPUT_C = (1 << 2)
  76. };
  77. enum LVDS_script {
  78. /* Order *does* matter here */
  79. LVDS_INIT = 1,
  80. LVDS_RESET,
  81. LVDS_BACKLIGHT_ON,
  82. LVDS_BACKLIGHT_OFF,
  83. LVDS_PANEL_ON,
  84. LVDS_PANEL_OFF
  85. };
  86. struct nvbios {
  87. struct drm_device *dev;
  88. enum {
  89. NVBIOS_BMP,
  90. NVBIOS_BIT
  91. } type;
  92. uint16_t offset;
  93. uint32_t length;
  94. uint8_t *data;
  95. uint8_t chip_version;
  96. uint32_t dactestval;
  97. uint32_t tvdactestval;
  98. uint8_t digital_min_front_porch;
  99. bool fp_no_ddc;
  100. spinlock_t lock;
  101. bool execute;
  102. uint8_t major_version;
  103. uint8_t feature_byte;
  104. bool is_mobile;
  105. uint32_t fmaxvco, fminvco;
  106. bool old_style_init;
  107. uint16_t init_script_tbls_ptr;
  108. uint16_t extra_init_script_tbl_ptr;
  109. uint16_t macro_index_tbl_ptr;
  110. uint16_t macro_tbl_ptr;
  111. uint16_t condition_tbl_ptr;
  112. uint16_t io_condition_tbl_ptr;
  113. uint16_t io_flag_condition_tbl_ptr;
  114. uint16_t init_function_tbl_ptr;
  115. uint16_t pll_limit_tbl_ptr;
  116. uint16_t ram_restrict_tbl_ptr;
  117. uint8_t ram_restrict_group_count;
  118. uint16_t some_script_ptr; /* BIT I + 14 */
  119. uint16_t init96_tbl_ptr; /* BIT I + 16 */
  120. struct dcb_table dcb;
  121. struct {
  122. int crtchead;
  123. } state;
  124. struct {
  125. struct dcb_output *output;
  126. int crtc;
  127. uint16_t script_table_ptr;
  128. } display;
  129. struct {
  130. uint16_t fptablepointer; /* also used by tmds */
  131. uint16_t fpxlatetableptr;
  132. int xlatwidth;
  133. uint16_t lvdsmanufacturerpointer;
  134. uint16_t fpxlatemanufacturertableptr;
  135. uint16_t mode_ptr;
  136. uint16_t xlated_entry;
  137. bool power_off_for_reset;
  138. bool reset_after_pclk_change;
  139. bool dual_link;
  140. bool link_c_increment;
  141. bool if_is_24bit;
  142. int duallink_transition_clk;
  143. uint8_t strapless_is_24bit;
  144. uint8_t *edid;
  145. /* will need resetting after suspend */
  146. int last_script_invoc;
  147. bool lvds_init_run;
  148. } fp;
  149. struct {
  150. uint16_t output0_script_ptr;
  151. uint16_t output1_script_ptr;
  152. } tmds;
  153. struct {
  154. uint16_t mem_init_tbl_ptr;
  155. uint16_t sdr_seq_tbl_ptr;
  156. uint16_t ddr_seq_tbl_ptr;
  157. struct {
  158. uint8_t crt, tv, panel;
  159. } i2c_indices;
  160. uint16_t lvds_single_a_script_ptr;
  161. } legacy;
  162. };
  163. void *olddcb_table(struct drm_device *);
  164. void *olddcb_outp(struct drm_device *, u8 idx);
  165. int olddcb_outp_foreach(struct drm_device *, void *data,
  166. int (*)(struct drm_device *, void *, int idx, u8 *outp));
  167. u8 *olddcb_conntab(struct drm_device *);
  168. u8 *olddcb_conn(struct drm_device *, u8 idx);
  169. #endif