intel_bios.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /*
  2. * Copyright (c) 2006 Intel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Authors:
  18. * Eric Anholt <eric@anholt.net>
  19. *
  20. */
  21. #ifndef _I830_BIOS_H_
  22. #define _I830_BIOS_H_
  23. #include <drm/drmP.h>
  24. struct vbt_header {
  25. u8 signature[20]; /**< Always starts with 'VBT$' */
  26. u16 version; /**< decimal */
  27. u16 header_size; /**< in bytes */
  28. u16 vbt_size; /**< in bytes */
  29. u8 vbt_checksum;
  30. u8 reserved0;
  31. u32 bdb_offset; /**< from beginning of VBT */
  32. u32 aim_offset[4]; /**< from beginning of VBT */
  33. } __attribute__((packed));
  34. struct bdb_header {
  35. u8 signature[16]; /**< Always 'BIOS_DATA_BLOCK' */
  36. u16 version; /**< decimal */
  37. u16 header_size; /**< in bytes */
  38. u16 bdb_size; /**< in bytes */
  39. };
  40. /* strictly speaking, this is a "skip" block, but it has interesting info */
  41. struct vbios_data {
  42. u8 type; /* 0 == desktop, 1 == mobile */
  43. u8 relstage;
  44. u8 chipset;
  45. u8 lvds_present:1;
  46. u8 tv_present:1;
  47. u8 rsvd2:6; /* finish byte */
  48. u8 rsvd3[4];
  49. u8 signon[155];
  50. u8 copyright[61];
  51. u16 code_segment;
  52. u8 dos_boot_mode;
  53. u8 bandwidth_percent;
  54. u8 rsvd4; /* popup memory size */
  55. u8 resize_pci_bios;
  56. u8 rsvd5; /* is crt already on ddc2 */
  57. } __attribute__((packed));
  58. /*
  59. * There are several types of BIOS data blocks (BDBs), each block has
  60. * an ID and size in the first 3 bytes (ID in first, size in next 2).
  61. * Known types are listed below.
  62. */
  63. #define BDB_GENERAL_FEATURES 1
  64. #define BDB_GENERAL_DEFINITIONS 2
  65. #define BDB_OLD_TOGGLE_LIST 3
  66. #define BDB_MODE_SUPPORT_LIST 4
  67. #define BDB_GENERIC_MODE_TABLE 5
  68. #define BDB_EXT_MMIO_REGS 6
  69. #define BDB_SWF_IO 7
  70. #define BDB_SWF_MMIO 8
  71. #define BDB_DOT_CLOCK_TABLE 9
  72. #define BDB_MODE_REMOVAL_TABLE 10
  73. #define BDB_CHILD_DEVICE_TABLE 11
  74. #define BDB_DRIVER_FEATURES 12
  75. #define BDB_DRIVER_PERSISTENCE 13
  76. #define BDB_EXT_TABLE_PTRS 14
  77. #define BDB_DOT_CLOCK_OVERRIDE 15
  78. #define BDB_DISPLAY_SELECT 16
  79. /* 17 rsvd */
  80. #define BDB_DRIVER_ROTATION 18
  81. #define BDB_DISPLAY_REMOVE 19
  82. #define BDB_OEM_CUSTOM 20
  83. #define BDB_EFP_LIST 21 /* workarounds for VGA hsync/vsync */
  84. #define BDB_SDVO_LVDS_OPTIONS 22
  85. #define BDB_SDVO_PANEL_DTDS 23
  86. #define BDB_SDVO_LVDS_PNP_IDS 24
  87. #define BDB_SDVO_LVDS_POWER_SEQ 25
  88. #define BDB_TV_OPTIONS 26
  89. #define BDB_LVDS_OPTIONS 40
  90. #define BDB_LVDS_LFP_DATA_PTRS 41
  91. #define BDB_LVDS_LFP_DATA 42
  92. #define BDB_LVDS_BACKLIGHT 43
  93. #define BDB_LVDS_POWER 44
  94. #define BDB_SKIP 254 /* VBIOS private block, ignore */
  95. struct bdb_general_features {
  96. /* bits 1 */
  97. u8 panel_fitting:2;
  98. u8 flexaim:1;
  99. u8 msg_enable:1;
  100. u8 clear_screen:3;
  101. u8 color_flip:1;
  102. /* bits 2 */
  103. u8 download_ext_vbt:1;
  104. u8 enable_ssc:1;
  105. u8 ssc_freq:1;
  106. u8 enable_lfp_on_override:1;
  107. u8 disable_ssc_ddt:1;
  108. u8 rsvd8:3; /* finish byte */
  109. /* bits 3 */
  110. u8 disable_smooth_vision:1;
  111. u8 single_dvi:1;
  112. u8 rsvd9:6; /* finish byte */
  113. /* bits 4 */
  114. u8 legacy_monitor_detect;
  115. /* bits 5 */
  116. u8 int_crt_support:1;
  117. u8 int_tv_support:1;
  118. u8 rsvd11:6; /* finish byte */
  119. } __attribute__((packed));
  120. struct bdb_general_definitions {
  121. /* DDC GPIO */
  122. u8 crt_ddc_gmbus_pin;
  123. /* DPMS bits */
  124. u8 dpms_acpi:1;
  125. u8 skip_boot_crt_detect:1;
  126. u8 dpms_aim:1;
  127. u8 rsvd1:5; /* finish byte */
  128. /* boot device bits */
  129. u8 boot_display[2];
  130. u8 child_dev_size;
  131. /* device info */
  132. u8 tv_or_lvds_info[33];
  133. u8 dev1[33];
  134. u8 dev2[33];
  135. u8 dev3[33];
  136. u8 dev4[33];
  137. /* may be another device block here on some platforms */
  138. };
  139. struct bdb_lvds_options {
  140. u8 panel_type;
  141. u8 rsvd1;
  142. /* LVDS capabilities, stored in a dword */
  143. u8 pfit_mode:2;
  144. u8 pfit_text_mode_enhanced:1;
  145. u8 pfit_gfx_mode_enhanced:1;
  146. u8 pfit_ratio_auto:1;
  147. u8 pixel_dither:1;
  148. u8 lvds_edid:1;
  149. u8 rsvd2:1;
  150. u8 rsvd4;
  151. } __attribute__((packed));
  152. struct bdb_lvds_backlight {
  153. u8 type:2;
  154. u8 pol:1;
  155. u8 gpio:3;
  156. u8 gmbus:2;
  157. u16 freq;
  158. u8 minbrightness;
  159. u8 i2caddr;
  160. u8 brightnesscmd;
  161. /*FIXME: more...*/
  162. } __attribute__((packed));
  163. /* LFP pointer table contains entries to the struct below */
  164. struct bdb_lvds_lfp_data_ptr {
  165. u16 fp_timing_offset; /* offsets are from start of bdb */
  166. u8 fp_table_size;
  167. u16 dvo_timing_offset;
  168. u8 dvo_table_size;
  169. u16 panel_pnp_id_offset;
  170. u8 pnp_table_size;
  171. } __attribute__((packed));
  172. struct bdb_lvds_lfp_data_ptrs {
  173. u8 lvds_entries; /* followed by one or more lvds_data_ptr structs */
  174. struct bdb_lvds_lfp_data_ptr ptr[16];
  175. } __attribute__((packed));
  176. /* LFP data has 3 blocks per entry */
  177. struct lvds_fp_timing {
  178. u16 x_res;
  179. u16 y_res;
  180. u32 lvds_reg;
  181. u32 lvds_reg_val;
  182. u32 pp_on_reg;
  183. u32 pp_on_reg_val;
  184. u32 pp_off_reg;
  185. u32 pp_off_reg_val;
  186. u32 pp_cycle_reg;
  187. u32 pp_cycle_reg_val;
  188. u32 pfit_reg;
  189. u32 pfit_reg_val;
  190. u16 terminator;
  191. } __attribute__((packed));
  192. struct lvds_dvo_timing {
  193. u16 clock; /**< In 10khz */
  194. u8 hactive_lo;
  195. u8 hblank_lo;
  196. u8 hblank_hi:4;
  197. u8 hactive_hi:4;
  198. u8 vactive_lo;
  199. u8 vblank_lo;
  200. u8 vblank_hi:4;
  201. u8 vactive_hi:4;
  202. u8 hsync_off_lo;
  203. u8 hsync_pulse_width;
  204. u8 vsync_pulse_width:4;
  205. u8 vsync_off:4;
  206. u8 rsvd0:6;
  207. u8 hsync_off_hi:2;
  208. u8 h_image;
  209. u8 v_image;
  210. u8 max_hv;
  211. u8 h_border;
  212. u8 v_border;
  213. u8 rsvd1:3;
  214. u8 digital:2;
  215. u8 vsync_positive:1;
  216. u8 hsync_positive:1;
  217. u8 rsvd2:1;
  218. } __attribute__((packed));
  219. struct lvds_pnp_id {
  220. u16 mfg_name;
  221. u16 product_code;
  222. u32 serial;
  223. u8 mfg_week;
  224. u8 mfg_year;
  225. } __attribute__((packed));
  226. struct bdb_lvds_lfp_data_entry {
  227. struct lvds_fp_timing fp_timing;
  228. struct lvds_dvo_timing dvo_timing;
  229. struct lvds_pnp_id pnp_id;
  230. } __attribute__((packed));
  231. struct bdb_lvds_lfp_data {
  232. struct bdb_lvds_lfp_data_entry data[16];
  233. } __attribute__((packed));
  234. struct aimdb_header {
  235. char signature[16];
  236. char oem_device[20];
  237. u16 aimdb_version;
  238. u16 aimdb_header_size;
  239. u16 aimdb_size;
  240. } __attribute__((packed));
  241. struct aimdb_block {
  242. u8 aimdb_id;
  243. u16 aimdb_size;
  244. } __attribute__((packed));
  245. struct vch_panel_data {
  246. u16 fp_timing_offset;
  247. u8 fp_timing_size;
  248. u16 dvo_timing_offset;
  249. u8 dvo_timing_size;
  250. u16 text_fitting_offset;
  251. u8 text_fitting_size;
  252. u16 graphics_fitting_offset;
  253. u8 graphics_fitting_size;
  254. } __attribute__((packed));
  255. struct vch_bdb_22 {
  256. struct aimdb_block aimdb_block;
  257. struct vch_panel_data panels[16];
  258. } __attribute__((packed));
  259. struct bdb_sdvo_lvds_options {
  260. u8 panel_backlight;
  261. u8 h40_set_panel_type;
  262. u8 panel_type;
  263. u8 ssc_clk_freq;
  264. u16 als_low_trip;
  265. u16 als_high_trip;
  266. u8 sclalarcoeff_tab_row_num;
  267. u8 sclalarcoeff_tab_row_size;
  268. u8 coefficient[8];
  269. u8 panel_misc_bits_1;
  270. u8 panel_misc_bits_2;
  271. u8 panel_misc_bits_3;
  272. u8 panel_misc_bits_4;
  273. } __attribute__((packed));
  274. extern bool psb_intel_init_bios(struct drm_device *dev);
  275. extern void psb_intel_destroy_bios(struct drm_device *dev);
  276. /*
  277. * Driver<->VBIOS interaction occurs through scratch bits in
  278. * GR18 & SWF*.
  279. */
  280. /* GR18 bits are set on display switch and hotkey events */
  281. #define GR18_DRIVER_SWITCH_EN (1<<7) /* 0: VBIOS control, 1: driver control */
  282. #define GR18_HOTKEY_MASK 0x78 /* See also SWF4 15:0 */
  283. #define GR18_HK_NONE (0x0<<3)
  284. #define GR18_HK_LFP_STRETCH (0x1<<3)
  285. #define GR18_HK_TOGGLE_DISP (0x2<<3)
  286. #define GR18_HK_DISP_SWITCH (0x4<<3) /* see SWF14 15:0 for what to enable */
  287. #define GR18_HK_POPUP_DISABLED (0x6<<3)
  288. #define GR18_HK_POPUP_ENABLED (0x7<<3)
  289. #define GR18_HK_PFIT (0x8<<3)
  290. #define GR18_HK_APM_CHANGE (0xa<<3)
  291. #define GR18_HK_MULTIPLE (0xc<<3)
  292. #define GR18_USER_INT_EN (1<<2)
  293. #define GR18_A0000_FLUSH_EN (1<<1)
  294. #define GR18_SMM_EN (1<<0)
  295. /* Set by driver, cleared by VBIOS */
  296. #define SWF00_YRES_SHIFT 16
  297. #define SWF00_XRES_SHIFT 0
  298. #define SWF00_RES_MASK 0xffff
  299. /* Set by VBIOS at boot time and driver at runtime */
  300. #define SWF01_TV2_FORMAT_SHIFT 8
  301. #define SWF01_TV1_FORMAT_SHIFT 0
  302. #define SWF01_TV_FORMAT_MASK 0xffff
  303. #define SWF10_VBIOS_BLC_I2C_EN (1<<29)
  304. #define SWF10_GTT_OVERRIDE_EN (1<<28)
  305. #define SWF10_LFP_DPMS_OVR (1<<27) /* override DPMS on display switch */
  306. #define SWF10_ACTIVE_TOGGLE_LIST_MASK (7<<24)
  307. #define SWF10_OLD_TOGGLE 0x0
  308. #define SWF10_TOGGLE_LIST_1 0x1
  309. #define SWF10_TOGGLE_LIST_2 0x2
  310. #define SWF10_TOGGLE_LIST_3 0x3
  311. #define SWF10_TOGGLE_LIST_4 0x4
  312. #define SWF10_PANNING_EN (1<<23)
  313. #define SWF10_DRIVER_LOADED (1<<22)
  314. #define SWF10_EXTENDED_DESKTOP (1<<21)
  315. #define SWF10_EXCLUSIVE_MODE (1<<20)
  316. #define SWF10_OVERLAY_EN (1<<19)
  317. #define SWF10_PLANEB_HOLDOFF (1<<18)
  318. #define SWF10_PLANEA_HOLDOFF (1<<17)
  319. #define SWF10_VGA_HOLDOFF (1<<16)
  320. #define SWF10_ACTIVE_DISP_MASK 0xffff
  321. #define SWF10_PIPEB_LFP2 (1<<15)
  322. #define SWF10_PIPEB_EFP2 (1<<14)
  323. #define SWF10_PIPEB_TV2 (1<<13)
  324. #define SWF10_PIPEB_CRT2 (1<<12)
  325. #define SWF10_PIPEB_LFP (1<<11)
  326. #define SWF10_PIPEB_EFP (1<<10)
  327. #define SWF10_PIPEB_TV (1<<9)
  328. #define SWF10_PIPEB_CRT (1<<8)
  329. #define SWF10_PIPEA_LFP2 (1<<7)
  330. #define SWF10_PIPEA_EFP2 (1<<6)
  331. #define SWF10_PIPEA_TV2 (1<<5)
  332. #define SWF10_PIPEA_CRT2 (1<<4)
  333. #define SWF10_PIPEA_LFP (1<<3)
  334. #define SWF10_PIPEA_EFP (1<<2)
  335. #define SWF10_PIPEA_TV (1<<1)
  336. #define SWF10_PIPEA_CRT (1<<0)
  337. #define SWF11_MEMORY_SIZE_SHIFT 16
  338. #define SWF11_SV_TEST_EN (1<<15)
  339. #define SWF11_IS_AGP (1<<14)
  340. #define SWF11_DISPLAY_HOLDOFF (1<<13)
  341. #define SWF11_DPMS_REDUCED (1<<12)
  342. #define SWF11_IS_VBE_MODE (1<<11)
  343. #define SWF11_PIPEB_ACCESS (1<<10) /* 0 here means pipe a */
  344. #define SWF11_DPMS_MASK 0x07
  345. #define SWF11_DPMS_OFF (1<<2)
  346. #define SWF11_DPMS_SUSPEND (1<<1)
  347. #define SWF11_DPMS_STANDBY (1<<0)
  348. #define SWF11_DPMS_ON 0
  349. #define SWF14_GFX_PFIT_EN (1<<31)
  350. #define SWF14_TEXT_PFIT_EN (1<<30)
  351. #define SWF14_LID_STATUS_CLOSED (1<<29) /* 0 here means open */
  352. #define SWF14_POPUP_EN (1<<28)
  353. #define SWF14_DISPLAY_HOLDOFF (1<<27)
  354. #define SWF14_DISP_DETECT_EN (1<<26)
  355. #define SWF14_DOCKING_STATUS_DOCKED (1<<25) /* 0 here means undocked */
  356. #define SWF14_DRIVER_STATUS (1<<24)
  357. #define SWF14_OS_TYPE_WIN9X (1<<23)
  358. #define SWF14_OS_TYPE_WINNT (1<<22)
  359. /* 21:19 rsvd */
  360. #define SWF14_PM_TYPE_MASK 0x00070000
  361. #define SWF14_PM_ACPI_VIDEO (0x4 << 16)
  362. #define SWF14_PM_ACPI (0x3 << 16)
  363. #define SWF14_PM_APM_12 (0x2 << 16)
  364. #define SWF14_PM_APM_11 (0x1 << 16)
  365. #define SWF14_HK_REQUEST_MASK 0x0000ffff /* see GR18 6:3 for event type */
  366. /* if GR18 indicates a display switch */
  367. #define SWF14_DS_PIPEB_LFP2_EN (1<<15)
  368. #define SWF14_DS_PIPEB_EFP2_EN (1<<14)
  369. #define SWF14_DS_PIPEB_TV2_EN (1<<13)
  370. #define SWF14_DS_PIPEB_CRT2_EN (1<<12)
  371. #define SWF14_DS_PIPEB_LFP_EN (1<<11)
  372. #define SWF14_DS_PIPEB_EFP_EN (1<<10)
  373. #define SWF14_DS_PIPEB_TV_EN (1<<9)
  374. #define SWF14_DS_PIPEB_CRT_EN (1<<8)
  375. #define SWF14_DS_PIPEA_LFP2_EN (1<<7)
  376. #define SWF14_DS_PIPEA_EFP2_EN (1<<6)
  377. #define SWF14_DS_PIPEA_TV2_EN (1<<5)
  378. #define SWF14_DS_PIPEA_CRT2_EN (1<<4)
  379. #define SWF14_DS_PIPEA_LFP_EN (1<<3)
  380. #define SWF14_DS_PIPEA_EFP_EN (1<<2)
  381. #define SWF14_DS_PIPEA_TV_EN (1<<1)
  382. #define SWF14_DS_PIPEA_CRT_EN (1<<0)
  383. /* if GR18 indicates a panel fitting request */
  384. #define SWF14_PFIT_EN (1<<0) /* 0 means disable */
  385. /* if GR18 indicates an APM change request */
  386. #define SWF14_APM_HIBERNATE 0x4
  387. #define SWF14_APM_SUSPEND 0x3
  388. #define SWF14_APM_STANDBY 0x1
  389. #define SWF14_APM_RESTORE 0x0
  390. #endif /* _I830_BIOS_H_ */