hw.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
  4. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
  5. */
  6. #ifndef __HW_H__
  7. #define __HW_H__
  8. #include <linux/seq_file.h>
  9. #include "viamode.h"
  10. #include "global.h"
  11. #include "via_modesetting.h"
  12. #define viafb_read_reg(p, i) via_read_reg(p, i)
  13. #define viafb_write_reg(i, p, d) via_write_reg(p, i, d)
  14. #define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m)
  15. /* VIA output devices */
  16. #define VIA_LDVP0 0x00000001
  17. #define VIA_LDVP1 0x00000002
  18. #define VIA_DVP0 0x00000004
  19. #define VIA_CRT 0x00000010
  20. #define VIA_DVP1 0x00000020
  21. #define VIA_LVDS1 0x00000040
  22. #define VIA_LVDS2 0x00000080
  23. /* VIA output device power states */
  24. #define VIA_STATE_ON 0
  25. #define VIA_STATE_STANDBY 1
  26. #define VIA_STATE_SUSPEND 2
  27. #define VIA_STATE_OFF 3
  28. /* VIA output device sync polarity */
  29. #define VIA_HSYNC_NEGATIVE 0x01
  30. #define VIA_VSYNC_NEGATIVE 0x02
  31. /**********************************************************/
  32. /* Definition IGA2 Design Method of CRTC Shadow Registers */
  33. /**********************************************************/
  34. #define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5)
  35. #define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1)
  36. #define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2)
  37. #define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1)
  38. #define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1)
  39. #define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1)
  40. #define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x)
  41. #define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y)
  42. /* Define Register Number for IGA2 Shadow CRTC Timing */
  43. /* location: {CR6D,0,7},{CR71,3,3} */
  44. #define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2
  45. /* location: {CR6E,0,7} */
  46. #define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1
  47. /* location: {CR6F,0,7},{CR71,0,2} */
  48. #define IGA2_SHADOW_VER_TOTAL_REG_NUM 2
  49. /* location: {CR70,0,7},{CR71,4,6} */
  50. #define IGA2_SHADOW_VER_ADDR_REG_NUM 2
  51. /* location: {CR72,0,7},{CR74,4,6} */
  52. #define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2
  53. /* location: {CR73,0,7},{CR74,0,2} */
  54. #define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2
  55. /* location: {CR75,0,7},{CR76,4,6} */
  56. #define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2
  57. /* location: {CR76,0,3} */
  58. #define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1
  59. /* Define Fetch Count Register*/
  60. /* location: {SR1C,0,7},{SR1D,0,1} */
  61. #define IGA1_FETCH_COUNT_REG_NUM 2
  62. /* 16 bytes alignment. */
  63. #define IGA1_FETCH_COUNT_ALIGN_BYTE 16
  64. /* x: H resolution, y: color depth */
  65. #define IGA1_FETCH_COUNT_PATCH_VALUE 4
  66. #define IGA1_FETCH_COUNT_FORMULA(x, y) \
  67. (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE)
  68. /* location: {CR65,0,7},{CR67,2,3} */
  69. #define IGA2_FETCH_COUNT_REG_NUM 2
  70. #define IGA2_FETCH_COUNT_ALIGN_BYTE 16
  71. #define IGA2_FETCH_COUNT_PATCH_VALUE 0
  72. #define IGA2_FETCH_COUNT_FORMULA(x, y) \
  73. (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE)
  74. /* Staring Address*/
  75. /* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */
  76. #define IGA1_STARTING_ADDR_REG_NUM 4
  77. /* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */
  78. #define IGA2_STARTING_ADDR_REG_NUM 3
  79. /* Define Display OFFSET*/
  80. /* These value are by HW suggested value*/
  81. /* location: {SR17,0,7} */
  82. #define K800_IGA1_FIFO_MAX_DEPTH 384
  83. /* location: {SR16,0,5},{SR16,7,7} */
  84. #define K800_IGA1_FIFO_THRESHOLD 328
  85. /* location: {SR18,0,5},{SR18,7,7} */
  86. #define K800_IGA1_FIFO_HIGH_THRESHOLD 296
  87. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  88. /* because HW only 5 bits */
  89. #define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  90. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  91. #define K800_IGA2_FIFO_MAX_DEPTH 384
  92. /* location: {CR68,0,3},{CR95,4,6} */
  93. #define K800_IGA2_FIFO_THRESHOLD 328
  94. /* location: {CR92,0,3},{CR95,0,2} */
  95. #define K800_IGA2_FIFO_HIGH_THRESHOLD 296
  96. /* location: {CR94,0,6} */
  97. #define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  98. /* location: {SR17,0,7} */
  99. #define P880_IGA1_FIFO_MAX_DEPTH 192
  100. /* location: {SR16,0,5},{SR16,7,7} */
  101. #define P880_IGA1_FIFO_THRESHOLD 128
  102. /* location: {SR18,0,5},{SR18,7,7} */
  103. #define P880_IGA1_FIFO_HIGH_THRESHOLD 64
  104. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  105. /* because HW only 5 bits */
  106. #define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  107. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  108. #define P880_IGA2_FIFO_MAX_DEPTH 96
  109. /* location: {CR68,0,3},{CR95,4,6} */
  110. #define P880_IGA2_FIFO_THRESHOLD 64
  111. /* location: {CR92,0,3},{CR95,0,2} */
  112. #define P880_IGA2_FIFO_HIGH_THRESHOLD 32
  113. /* location: {CR94,0,6} */
  114. #define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  115. /* VT3314 chipset*/
  116. /* location: {SR17,0,7} */
  117. #define CN700_IGA1_FIFO_MAX_DEPTH 96
  118. /* location: {SR16,0,5},{SR16,7,7} */
  119. #define CN700_IGA1_FIFO_THRESHOLD 80
  120. /* location: {SR18,0,5},{SR18,7,7} */
  121. #define CN700_IGA1_FIFO_HIGH_THRESHOLD 64
  122. /* location: {SR22,0,4}. (128/4) =64, P800 must be set zero,
  123. because HW only 5 bits */
  124. #define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  125. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  126. #define CN700_IGA2_FIFO_MAX_DEPTH 96
  127. /* location: {CR68,0,3},{CR95,4,6} */
  128. #define CN700_IGA2_FIFO_THRESHOLD 80
  129. /* location: {CR92,0,3},{CR95,0,2} */
  130. #define CN700_IGA2_FIFO_HIGH_THRESHOLD 32
  131. /* location: {CR94,0,6} */
  132. #define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  133. /* For VT3324, these values are suggested by HW */
  134. /* location: {SR17,0,7} */
  135. #define CX700_IGA1_FIFO_MAX_DEPTH 192
  136. /* location: {SR16,0,5},{SR16,7,7} */
  137. #define CX700_IGA1_FIFO_THRESHOLD 128
  138. /* location: {SR18,0,5},{SR18,7,7} */
  139. #define CX700_IGA1_FIFO_HIGH_THRESHOLD 128
  140. /* location: {SR22,0,4} */
  141. #define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  142. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  143. #define CX700_IGA2_FIFO_MAX_DEPTH 96
  144. /* location: {CR68,0,3},{CR95,4,6} */
  145. #define CX700_IGA2_FIFO_THRESHOLD 64
  146. /* location: {CR92,0,3},{CR95,0,2} */
  147. #define CX700_IGA2_FIFO_HIGH_THRESHOLD 32
  148. /* location: {CR94,0,6} */
  149. #define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  150. /* VT3336 chipset*/
  151. /* location: {SR17,0,7} */
  152. #define K8M890_IGA1_FIFO_MAX_DEPTH 360
  153. /* location: {SR16,0,5},{SR16,7,7} */
  154. #define K8M890_IGA1_FIFO_THRESHOLD 328
  155. /* location: {SR18,0,5},{SR18,7,7} */
  156. #define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296
  157. /* location: {SR22,0,4}. */
  158. #define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  159. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  160. #define K8M890_IGA2_FIFO_MAX_DEPTH 360
  161. /* location: {CR68,0,3},{CR95,4,6} */
  162. #define K8M890_IGA2_FIFO_THRESHOLD 328
  163. /* location: {CR92,0,3},{CR95,0,2} */
  164. #define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296
  165. /* location: {CR94,0,6} */
  166. #define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124
  167. /* VT3327 chipset*/
  168. /* location: {SR17,0,7} */
  169. #define P4M890_IGA1_FIFO_MAX_DEPTH 96
  170. /* location: {SR16,0,5},{SR16,7,7} */
  171. #define P4M890_IGA1_FIFO_THRESHOLD 76
  172. /* location: {SR18,0,5},{SR18,7,7} */
  173. #define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64
  174. /* location: {SR22,0,4}. (32/4) =8 */
  175. #define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  176. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  177. #define P4M890_IGA2_FIFO_MAX_DEPTH 96
  178. /* location: {CR68,0,3},{CR95,4,6} */
  179. #define P4M890_IGA2_FIFO_THRESHOLD 76
  180. /* location: {CR92,0,3},{CR95,0,2} */
  181. #define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64
  182. /* location: {CR94,0,6} */
  183. #define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  184. /* VT3364 chipset*/
  185. /* location: {SR17,0,7} */
  186. #define P4M900_IGA1_FIFO_MAX_DEPTH 96
  187. /* location: {SR16,0,5},{SR16,7,7} */
  188. #define P4M900_IGA1_FIFO_THRESHOLD 76
  189. /* location: {SR18,0,5},{SR18,7,7} */
  190. #define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76
  191. /* location: {SR22,0,4}. */
  192. #define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  193. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  194. #define P4M900_IGA2_FIFO_MAX_DEPTH 96
  195. /* location: {CR68,0,3},{CR95,4,6} */
  196. #define P4M900_IGA2_FIFO_THRESHOLD 76
  197. /* location: {CR92,0,3},{CR95,0,2} */
  198. #define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76
  199. /* location: {CR94,0,6} */
  200. #define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  201. /* For VT3353, these values are suggested by HW */
  202. /* location: {SR17,0,7} */
  203. #define VX800_IGA1_FIFO_MAX_DEPTH 192
  204. /* location: {SR16,0,5},{SR16,7,7} */
  205. #define VX800_IGA1_FIFO_THRESHOLD 152
  206. /* location: {SR18,0,5},{SR18,7,7} */
  207. #define VX800_IGA1_FIFO_HIGH_THRESHOLD 152
  208. /* location: {SR22,0,4} */
  209. #define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64
  210. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  211. #define VX800_IGA2_FIFO_MAX_DEPTH 96
  212. /* location: {CR68,0,3},{CR95,4,6} */
  213. #define VX800_IGA2_FIFO_THRESHOLD 64
  214. /* location: {CR92,0,3},{CR95,0,2} */
  215. #define VX800_IGA2_FIFO_HIGH_THRESHOLD 32
  216. /* location: {CR94,0,6} */
  217. #define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  218. /* For VT3409 */
  219. #define VX855_IGA1_FIFO_MAX_DEPTH 400
  220. #define VX855_IGA1_FIFO_THRESHOLD 320
  221. #define VX855_IGA1_FIFO_HIGH_THRESHOLD 320
  222. #define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  223. #define VX855_IGA2_FIFO_MAX_DEPTH 200
  224. #define VX855_IGA2_FIFO_THRESHOLD 160
  225. #define VX855_IGA2_FIFO_HIGH_THRESHOLD 160
  226. #define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  227. /* For VT3410 */
  228. #define VX900_IGA1_FIFO_MAX_DEPTH 400
  229. #define VX900_IGA1_FIFO_THRESHOLD 320
  230. #define VX900_IGA1_FIFO_HIGH_THRESHOLD 320
  231. #define VX900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  232. #define VX900_IGA2_FIFO_MAX_DEPTH 192
  233. #define VX900_IGA2_FIFO_THRESHOLD 160
  234. #define VX900_IGA2_FIFO_HIGH_THRESHOLD 160
  235. #define VX900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  236. #define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1
  237. #define IGA1_FIFO_THRESHOLD_REG_NUM 2
  238. #define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2
  239. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  240. #define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3
  241. #define IGA2_FIFO_THRESHOLD_REG_NUM 2
  242. #define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2
  243. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  244. #define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1)
  245. #define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4)
  246. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  247. #define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  248. #define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1)
  249. #define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4)
  250. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  251. #define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  252. /************************************************************************/
  253. /* LCD Timing */
  254. /************************************************************************/
  255. /* 500 ms = 500000 us */
  256. #define LCD_POWER_SEQ_TD0 500000
  257. /* 50 ms = 50000 us */
  258. #define LCD_POWER_SEQ_TD1 50000
  259. /* 0 us */
  260. #define LCD_POWER_SEQ_TD2 0
  261. /* 210 ms = 210000 us */
  262. #define LCD_POWER_SEQ_TD3 210000
  263. /* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */
  264. #define CLE266_POWER_SEQ_UNIT 71
  265. /* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */
  266. #define K800_POWER_SEQ_UNIT 142
  267. /* 2^13 * (1/14.31818M) = 572.1 us */
  268. #define P880_POWER_SEQ_UNIT 572
  269. #define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT)
  270. #define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT)
  271. #define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT)
  272. /* location: {CR8B,0,7},{CR8F,0,3} */
  273. #define LCD_POWER_SEQ_TD0_REG_NUM 2
  274. /* location: {CR8C,0,7},{CR8F,4,7} */
  275. #define LCD_POWER_SEQ_TD1_REG_NUM 2
  276. /* location: {CR8D,0,7},{CR90,0,3} */
  277. #define LCD_POWER_SEQ_TD2_REG_NUM 2
  278. /* location: {CR8E,0,7},{CR90,4,7} */
  279. #define LCD_POWER_SEQ_TD3_REG_NUM 2
  280. /* LCD Scaling factor*/
  281. /* x: indicate setting horizontal size*/
  282. /* y: indicate panel horizontal size*/
  283. /* Horizontal scaling factor 10 bits (2^10) */
  284. #define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  285. /* Vertical scaling factor 10 bits (2^10) */
  286. #define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  287. /* Horizontal scaling factor 10 bits (2^12) */
  288. #define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1))
  289. /* Vertical scaling factor 10 bits (2^11) */
  290. #define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1))
  291. /* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */
  292. #define LCD_HOR_SCALING_FACTOR_REG_NUM 3
  293. /* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */
  294. #define LCD_VER_SCALING_FACTOR_REG_NUM 3
  295. /* location: {CR77,0,7},{CR79,4,5} */
  296. #define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2
  297. /* location: {CR78,0,7},{CR79,6,7} */
  298. #define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2
  299. struct io_register {
  300. u8 io_addr;
  301. u8 start_bit;
  302. u8 end_bit;
  303. };
  304. /*****************************************************
  305. ** Define IGA2 Shadow Display Timing ****
  306. *****************************************************/
  307. /* IGA2 Shadow Horizontal Total */
  308. struct iga2_shadow_hor_total {
  309. int reg_num;
  310. struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM];
  311. };
  312. /* IGA2 Shadow Horizontal Blank End */
  313. struct iga2_shadow_hor_blank_end {
  314. int reg_num;
  315. struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM];
  316. };
  317. /* IGA2 Shadow Vertical Total */
  318. struct iga2_shadow_ver_total {
  319. int reg_num;
  320. struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM];
  321. };
  322. /* IGA2 Shadow Vertical Addressable Video */
  323. struct iga2_shadow_ver_addr {
  324. int reg_num;
  325. struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM];
  326. };
  327. /* IGA2 Shadow Vertical Blank Start */
  328. struct iga2_shadow_ver_blank_start {
  329. int reg_num;
  330. struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM];
  331. };
  332. /* IGA2 Shadow Vertical Blank End */
  333. struct iga2_shadow_ver_blank_end {
  334. int reg_num;
  335. struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM];
  336. };
  337. /* IGA2 Shadow Vertical Sync Start */
  338. struct iga2_shadow_ver_sync_start {
  339. int reg_num;
  340. struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM];
  341. };
  342. /* IGA2 Shadow Vertical Sync End */
  343. struct iga2_shadow_ver_sync_end {
  344. int reg_num;
  345. struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM];
  346. };
  347. /* IGA1 Fetch Count Register */
  348. struct iga1_fetch_count {
  349. int reg_num;
  350. struct io_register reg[IGA1_FETCH_COUNT_REG_NUM];
  351. };
  352. /* IGA2 Fetch Count Register */
  353. struct iga2_fetch_count {
  354. int reg_num;
  355. struct io_register reg[IGA2_FETCH_COUNT_REG_NUM];
  356. };
  357. struct fetch_count {
  358. struct iga1_fetch_count iga1_fetch_count_reg;
  359. struct iga2_fetch_count iga2_fetch_count_reg;
  360. };
  361. /* Starting Address Register */
  362. struct iga1_starting_addr {
  363. int reg_num;
  364. struct io_register reg[IGA1_STARTING_ADDR_REG_NUM];
  365. };
  366. struct iga2_starting_addr {
  367. int reg_num;
  368. struct io_register reg[IGA2_STARTING_ADDR_REG_NUM];
  369. };
  370. struct starting_addr {
  371. struct iga1_starting_addr iga1_starting_addr_reg;
  372. struct iga2_starting_addr iga2_starting_addr_reg;
  373. };
  374. /* LCD Power Sequence Timer */
  375. struct lcd_pwd_seq_td0 {
  376. int reg_num;
  377. struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM];
  378. };
  379. struct lcd_pwd_seq_td1 {
  380. int reg_num;
  381. struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM];
  382. };
  383. struct lcd_pwd_seq_td2 {
  384. int reg_num;
  385. struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM];
  386. };
  387. struct lcd_pwd_seq_td3 {
  388. int reg_num;
  389. struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM];
  390. };
  391. struct _lcd_pwd_seq_timer {
  392. struct lcd_pwd_seq_td0 td0;
  393. struct lcd_pwd_seq_td1 td1;
  394. struct lcd_pwd_seq_td2 td2;
  395. struct lcd_pwd_seq_td3 td3;
  396. };
  397. /* LCD Scaling Factor */
  398. struct _lcd_hor_scaling_factor {
  399. int reg_num;
  400. struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM];
  401. };
  402. struct _lcd_ver_scaling_factor {
  403. int reg_num;
  404. struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM];
  405. };
  406. struct _lcd_scaling_factor {
  407. struct _lcd_hor_scaling_factor lcd_hor_scaling_factor;
  408. struct _lcd_ver_scaling_factor lcd_ver_scaling_factor;
  409. };
  410. struct pll_limit {
  411. u16 multiplier_min;
  412. u16 multiplier_max;
  413. u8 divisor;
  414. u8 rshift;
  415. };
  416. struct rgbLUT {
  417. u8 red;
  418. u8 green;
  419. u8 blue;
  420. };
  421. struct lcd_pwd_seq_timer {
  422. u16 td0;
  423. u16 td1;
  424. u16 td2;
  425. u16 td3;
  426. };
  427. /* Display FIFO Relation Registers*/
  428. struct iga1_fifo_depth_select {
  429. int reg_num;
  430. struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM];
  431. };
  432. struct iga1_fifo_threshold_select {
  433. int reg_num;
  434. struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM];
  435. };
  436. struct iga1_fifo_high_threshold_select {
  437. int reg_num;
  438. struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM];
  439. };
  440. struct iga1_display_queue_expire_num {
  441. int reg_num;
  442. struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  443. };
  444. struct iga2_fifo_depth_select {
  445. int reg_num;
  446. struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM];
  447. };
  448. struct iga2_fifo_threshold_select {
  449. int reg_num;
  450. struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM];
  451. };
  452. struct iga2_fifo_high_threshold_select {
  453. int reg_num;
  454. struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM];
  455. };
  456. struct iga2_display_queue_expire_num {
  457. int reg_num;
  458. struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  459. };
  460. struct fifo_depth_select {
  461. struct iga1_fifo_depth_select iga1_fifo_depth_select_reg;
  462. struct iga2_fifo_depth_select iga2_fifo_depth_select_reg;
  463. };
  464. struct fifo_threshold_select {
  465. struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg;
  466. struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg;
  467. };
  468. struct fifo_high_threshold_select {
  469. struct iga1_fifo_high_threshold_select
  470. iga1_fifo_high_threshold_select_reg;
  471. struct iga2_fifo_high_threshold_select
  472. iga2_fifo_high_threshold_select_reg;
  473. };
  474. struct display_queue_expire_num {
  475. struct iga1_display_queue_expire_num
  476. iga1_display_queue_expire_num_reg;
  477. struct iga2_display_queue_expire_num
  478. iga2_display_queue_expire_num_reg;
  479. };
  480. struct iga2_shadow_crtc_timing {
  481. struct iga2_shadow_hor_total hor_total_shadow;
  482. struct iga2_shadow_hor_blank_end hor_blank_end_shadow;
  483. struct iga2_shadow_ver_total ver_total_shadow;
  484. struct iga2_shadow_ver_addr ver_addr_shadow;
  485. struct iga2_shadow_ver_blank_start ver_blank_start_shadow;
  486. struct iga2_shadow_ver_blank_end ver_blank_end_shadow;
  487. struct iga2_shadow_ver_sync_start ver_sync_start_shadow;
  488. struct iga2_shadow_ver_sync_end ver_sync_end_shadow;
  489. };
  490. /* device ID */
  491. #define CLE266_FUNCTION3 0x3123
  492. #define KM400_FUNCTION3 0x3205
  493. #define CN400_FUNCTION2 0x2259
  494. #define CN400_FUNCTION3 0x3259
  495. /* support VT3314 chipset */
  496. #define CN700_FUNCTION2 0x2314
  497. #define CN700_FUNCTION3 0x3208
  498. /* VT3324 chipset */
  499. #define CX700_FUNCTION2 0x2324
  500. #define CX700_FUNCTION3 0x3324
  501. /* VT3204 chipset*/
  502. #define KM800_FUNCTION3 0x3204
  503. /* VT3336 chipset*/
  504. #define KM890_FUNCTION3 0x3336
  505. /* VT3327 chipset*/
  506. #define P4M890_FUNCTION3 0x3327
  507. /* VT3293 chipset*/
  508. #define CN750_FUNCTION3 0x3208
  509. /* VT3364 chipset*/
  510. #define P4M900_FUNCTION3 0x3364
  511. /* VT3353 chipset*/
  512. #define VX800_FUNCTION3 0x3353
  513. /* VT3409 chipset*/
  514. #define VX855_FUNCTION3 0x3409
  515. /* VT3410 chipset*/
  516. #define VX900_FUNCTION3 0x3410
  517. struct IODATA {
  518. u8 Index;
  519. u8 Mask;
  520. u8 Data;
  521. };
  522. struct pci_device_id_info {
  523. u32 vendor;
  524. u32 device;
  525. u32 chip_index;
  526. };
  527. struct via_device_mapping {
  528. u32 device;
  529. const char *name;
  530. };
  531. extern int viafb_SAMM_ON;
  532. extern int viafb_dual_fb;
  533. extern int viafb_LCD2_ON;
  534. extern int viafb_LCD_ON;
  535. extern int viafb_DVI_ON;
  536. extern int viafb_hotplug;
  537. struct via_display_timing var_to_timing(const struct fb_var_screeninfo *var,
  538. u16 cxres, u16 cyres);
  539. void viafb_fill_crtc_timing(const struct fb_var_screeninfo *var,
  540. u16 cxres, u16 cyres, int iga);
  541. void viafb_set_vclock(u32 CLK, int set_iga);
  542. void viafb_load_reg(int timing_value, int viafb_load_reg_num,
  543. struct io_register *reg,
  544. int io_type);
  545. void via_set_source(u32 devices, u8 iga);
  546. void via_set_state(u32 devices, u8 state);
  547. void via_set_sync_polarity(u32 devices, u8 polarity);
  548. u32 via_parse_odev(char *input, char **end);
  549. void via_odev_to_seq(struct seq_file *m, u32 odev);
  550. void init_ad9389(void);
  551. /* Access I/O Function */
  552. void viafb_lock_crt(void);
  553. void viafb_unlock_crt(void);
  554. void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
  555. void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
  556. void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
  557. void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
  558. *p_gfx_dpa_setting);
  559. int viafb_setmode(void);
  560. void viafb_fill_var_timing_info(struct fb_var_screeninfo *var,
  561. const struct fb_videomode *mode);
  562. void viafb_init_chip_info(int chip_type);
  563. void viafb_init_dac(int set_iga);
  564. int viafb_get_refresh(int hres, int vres, u32 float_refresh);
  565. void viafb_update_device_setting(int hres, int vres, int bpp, int flag);
  566. void viafb_set_iga_path(void);
  567. void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
  568. void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
  569. void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
  570. #endif /* __HW_H__ */