hw.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. /*
  2. * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
  3. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License as published by the Free Software Foundation;
  7. * either version 2, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
  10. * the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. * A PARTICULAR PURPOSE.See the GNU General Public License
  12. * for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #ifndef __HW_H__
  19. #define __HW_H__
  20. #include "viamode.h"
  21. #include "global.h"
  22. #include "via_modesetting.h"
  23. #define viafb_read_reg(p, i) via_read_reg(p, i)
  24. #define viafb_write_reg(i, p, d) via_write_reg(p, i, d)
  25. #define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m)
  26. /* VIA output devices */
  27. #define VIA_6C 0x00000001
  28. #define VIA_93 0x00000002
  29. #define VIA_96 0x00000004
  30. #define VIA_CRT 0x00000010
  31. #define VIA_DVP1 0x00000020
  32. #define VIA_LVDS1 0x00000040
  33. #define VIA_LVDS2 0x00000080
  34. /***************************************************
  35. * Definition IGA1 Design Method of CRTC Registers *
  36. ****************************************************/
  37. #define IGA1_HOR_TOTAL_FORMULA(x) (((x)/8)-5)
  38. #define IGA1_HOR_ADDR_FORMULA(x) (((x)/8)-1)
  39. #define IGA1_HOR_BLANK_START_FORMULA(x) (((x)/8)-1)
  40. #define IGA1_HOR_BLANK_END_FORMULA(x, y) (((x+y)/8)-1)
  41. #define IGA1_HOR_SYNC_START_FORMULA(x) ((x)/8)
  42. #define IGA1_HOR_SYNC_END_FORMULA(x, y) ((x+y)/8)
  43. #define IGA1_VER_TOTAL_FORMULA(x) ((x)-2)
  44. #define IGA1_VER_ADDR_FORMULA(x) ((x)-1)
  45. #define IGA1_VER_BLANK_START_FORMULA(x) ((x)-1)
  46. #define IGA1_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
  47. #define IGA1_VER_SYNC_START_FORMULA(x) ((x)-1)
  48. #define IGA1_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
  49. /***************************************************
  50. ** Definition IGA2 Design Method of CRTC Registers *
  51. ****************************************************/
  52. #define IGA2_HOR_TOTAL_FORMULA(x) ((x)-1)
  53. #define IGA2_HOR_ADDR_FORMULA(x) ((x)-1)
  54. #define IGA2_HOR_BLANK_START_FORMULA(x) ((x)-1)
  55. #define IGA2_HOR_BLANK_END_FORMULA(x, y) ((x+y)-1)
  56. #define IGA2_HOR_SYNC_START_FORMULA(x) ((x)-1)
  57. #define IGA2_HOR_SYNC_END_FORMULA(x, y) ((x+y)-1)
  58. #define IGA2_VER_TOTAL_FORMULA(x) ((x)-1)
  59. #define IGA2_VER_ADDR_FORMULA(x) ((x)-1)
  60. #define IGA2_VER_BLANK_START_FORMULA(x) ((x)-1)
  61. #define IGA2_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
  62. #define IGA2_VER_SYNC_START_FORMULA(x) ((x)-1)
  63. #define IGA2_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
  64. /**********************************************************/
  65. /* Definition IGA2 Design Method of CRTC Shadow Registers */
  66. /**********************************************************/
  67. #define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5)
  68. #define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1)
  69. #define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2)
  70. #define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1)
  71. #define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1)
  72. #define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1)
  73. #define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x)
  74. #define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y)
  75. /* Define Register Number for IGA1 CRTC Timing */
  76. /* location: {CR00,0,7},{CR36,3,3} */
  77. #define IGA1_HOR_TOTAL_REG_NUM 2
  78. /* location: {CR01,0,7} */
  79. #define IGA1_HOR_ADDR_REG_NUM 1
  80. /* location: {CR02,0,7} */
  81. #define IGA1_HOR_BLANK_START_REG_NUM 1
  82. /* location: {CR03,0,4},{CR05,7,7},{CR33,5,5} */
  83. #define IGA1_HOR_BLANK_END_REG_NUM 3
  84. /* location: {CR04,0,7},{CR33,4,4} */
  85. #define IGA1_HOR_SYNC_START_REG_NUM 2
  86. /* location: {CR05,0,4} */
  87. #define IGA1_HOR_SYNC_END_REG_NUM 1
  88. /* location: {CR06,0,7},{CR07,0,0},{CR07,5,5},{CR35,0,0} */
  89. #define IGA1_VER_TOTAL_REG_NUM 4
  90. /* location: {CR12,0,7},{CR07,1,1},{CR07,6,6},{CR35,2,2} */
  91. #define IGA1_VER_ADDR_REG_NUM 4
  92. /* location: {CR15,0,7},{CR07,3,3},{CR09,5,5},{CR35,3,3} */
  93. #define IGA1_VER_BLANK_START_REG_NUM 4
  94. /* location: {CR16,0,7} */
  95. #define IGA1_VER_BLANK_END_REG_NUM 1
  96. /* location: {CR10,0,7},{CR07,2,2},{CR07,7,7},{CR35,1,1} */
  97. #define IGA1_VER_SYNC_START_REG_NUM 4
  98. /* location: {CR11,0,3} */
  99. #define IGA1_VER_SYNC_END_REG_NUM 1
  100. /* Define Register Number for IGA2 Shadow CRTC Timing */
  101. /* location: {CR6D,0,7},{CR71,3,3} */
  102. #define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2
  103. /* location: {CR6E,0,7} */
  104. #define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1
  105. /* location: {CR6F,0,7},{CR71,0,2} */
  106. #define IGA2_SHADOW_VER_TOTAL_REG_NUM 2
  107. /* location: {CR70,0,7},{CR71,4,6} */
  108. #define IGA2_SHADOW_VER_ADDR_REG_NUM 2
  109. /* location: {CR72,0,7},{CR74,4,6} */
  110. #define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2
  111. /* location: {CR73,0,7},{CR74,0,2} */
  112. #define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2
  113. /* location: {CR75,0,7},{CR76,4,6} */
  114. #define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2
  115. /* location: {CR76,0,3} */
  116. #define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1
  117. /* Define Register Number for IGA2 CRTC Timing */
  118. /* location: {CR50,0,7},{CR55,0,3} */
  119. #define IGA2_HOR_TOTAL_REG_NUM 2
  120. /* location: {CR51,0,7},{CR55,4,6} */
  121. #define IGA2_HOR_ADDR_REG_NUM 2
  122. /* location: {CR52,0,7},{CR54,0,2} */
  123. #define IGA2_HOR_BLANK_START_REG_NUM 2
  124. /* location: CLE266: {CR53,0,7},{CR54,3,5} => CLE266's CR5D[6]
  125. is reserved, so it may have problem to set 1600x1200 on IGA2. */
  126. /* Others: {CR53,0,7},{CR54,3,5},{CR5D,6,6} */
  127. #define IGA2_HOR_BLANK_END_REG_NUM 3
  128. /* location: {CR56,0,7},{CR54,6,7},{CR5C,7,7} */
  129. /* VT3314 and Later: {CR56,0,7},{CR54,6,7},{CR5C,7,7}, {CR5D,7,7} */
  130. #define IGA2_HOR_SYNC_START_REG_NUM 4
  131. /* location: {CR57,0,7},{CR5C,6,6} */
  132. #define IGA2_HOR_SYNC_END_REG_NUM 2
  133. /* location: {CR58,0,7},{CR5D,0,2} */
  134. #define IGA2_VER_TOTAL_REG_NUM 2
  135. /* location: {CR59,0,7},{CR5D,3,5} */
  136. #define IGA2_VER_ADDR_REG_NUM 2
  137. /* location: {CR5A,0,7},{CR5C,0,2} */
  138. #define IGA2_VER_BLANK_START_REG_NUM 2
  139. /* location: {CR5E,0,7},{CR5C,3,5} */
  140. #define IGA2_VER_BLANK_END_REG_NUM 2
  141. /* location: {CR5E,0,7},{CR5F,5,7} */
  142. #define IGA2_VER_SYNC_START_REG_NUM 2
  143. /* location: {CR5F,0,4} */
  144. #define IGA2_VER_SYNC_END_REG_NUM 1
  145. /* Define Fetch Count Register*/
  146. /* location: {SR1C,0,7},{SR1D,0,1} */
  147. #define IGA1_FETCH_COUNT_REG_NUM 2
  148. /* 16 bytes alignment. */
  149. #define IGA1_FETCH_COUNT_ALIGN_BYTE 16
  150. /* x: H resolution, y: color depth */
  151. #define IGA1_FETCH_COUNT_PATCH_VALUE 4
  152. #define IGA1_FETCH_COUNT_FORMULA(x, y) \
  153. (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE)
  154. /* location: {CR65,0,7},{CR67,2,3} */
  155. #define IGA2_FETCH_COUNT_REG_NUM 2
  156. #define IGA2_FETCH_COUNT_ALIGN_BYTE 16
  157. #define IGA2_FETCH_COUNT_PATCH_VALUE 0
  158. #define IGA2_FETCH_COUNT_FORMULA(x, y) \
  159. (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE)
  160. /* Staring Address*/
  161. /* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */
  162. #define IGA1_STARTING_ADDR_REG_NUM 4
  163. /* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */
  164. #define IGA2_STARTING_ADDR_REG_NUM 3
  165. /* Define Display OFFSET*/
  166. /* These value are by HW suggested value*/
  167. /* location: {SR17,0,7} */
  168. #define K800_IGA1_FIFO_MAX_DEPTH 384
  169. /* location: {SR16,0,5},{SR16,7,7} */
  170. #define K800_IGA1_FIFO_THRESHOLD 328
  171. /* location: {SR18,0,5},{SR18,7,7} */
  172. #define K800_IGA1_FIFO_HIGH_THRESHOLD 296
  173. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  174. /* because HW only 5 bits */
  175. #define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  176. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  177. #define K800_IGA2_FIFO_MAX_DEPTH 384
  178. /* location: {CR68,0,3},{CR95,4,6} */
  179. #define K800_IGA2_FIFO_THRESHOLD 328
  180. /* location: {CR92,0,3},{CR95,0,2} */
  181. #define K800_IGA2_FIFO_HIGH_THRESHOLD 296
  182. /* location: {CR94,0,6} */
  183. #define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  184. /* location: {SR17,0,7} */
  185. #define P880_IGA1_FIFO_MAX_DEPTH 192
  186. /* location: {SR16,0,5},{SR16,7,7} */
  187. #define P880_IGA1_FIFO_THRESHOLD 128
  188. /* location: {SR18,0,5},{SR18,7,7} */
  189. #define P880_IGA1_FIFO_HIGH_THRESHOLD 64
  190. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  191. /* because HW only 5 bits */
  192. #define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  193. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  194. #define P880_IGA2_FIFO_MAX_DEPTH 96
  195. /* location: {CR68,0,3},{CR95,4,6} */
  196. #define P880_IGA2_FIFO_THRESHOLD 64
  197. /* location: {CR92,0,3},{CR95,0,2} */
  198. #define P880_IGA2_FIFO_HIGH_THRESHOLD 32
  199. /* location: {CR94,0,6} */
  200. #define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  201. /* VT3314 chipset*/
  202. /* location: {SR17,0,7} */
  203. #define CN700_IGA1_FIFO_MAX_DEPTH 96
  204. /* location: {SR16,0,5},{SR16,7,7} */
  205. #define CN700_IGA1_FIFO_THRESHOLD 80
  206. /* location: {SR18,0,5},{SR18,7,7} */
  207. #define CN700_IGA1_FIFO_HIGH_THRESHOLD 64
  208. /* location: {SR22,0,4}. (128/4) =64, P800 must be set zero,
  209. because HW only 5 bits */
  210. #define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  211. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  212. #define CN700_IGA2_FIFO_MAX_DEPTH 96
  213. /* location: {CR68,0,3},{CR95,4,6} */
  214. #define CN700_IGA2_FIFO_THRESHOLD 80
  215. /* location: {CR92,0,3},{CR95,0,2} */
  216. #define CN700_IGA2_FIFO_HIGH_THRESHOLD 32
  217. /* location: {CR94,0,6} */
  218. #define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  219. /* For VT3324, these values are suggested by HW */
  220. /* location: {SR17,0,7} */
  221. #define CX700_IGA1_FIFO_MAX_DEPTH 192
  222. /* location: {SR16,0,5},{SR16,7,7} */
  223. #define CX700_IGA1_FIFO_THRESHOLD 128
  224. /* location: {SR18,0,5},{SR18,7,7} */
  225. #define CX700_IGA1_FIFO_HIGH_THRESHOLD 128
  226. /* location: {SR22,0,4} */
  227. #define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  228. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  229. #define CX700_IGA2_FIFO_MAX_DEPTH 96
  230. /* location: {CR68,0,3},{CR95,4,6} */
  231. #define CX700_IGA2_FIFO_THRESHOLD 64
  232. /* location: {CR92,0,3},{CR95,0,2} */
  233. #define CX700_IGA2_FIFO_HIGH_THRESHOLD 32
  234. /* location: {CR94,0,6} */
  235. #define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  236. /* VT3336 chipset*/
  237. /* location: {SR17,0,7} */
  238. #define K8M890_IGA1_FIFO_MAX_DEPTH 360
  239. /* location: {SR16,0,5},{SR16,7,7} */
  240. #define K8M890_IGA1_FIFO_THRESHOLD 328
  241. /* location: {SR18,0,5},{SR18,7,7} */
  242. #define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296
  243. /* location: {SR22,0,4}. */
  244. #define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  245. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  246. #define K8M890_IGA2_FIFO_MAX_DEPTH 360
  247. /* location: {CR68,0,3},{CR95,4,6} */
  248. #define K8M890_IGA2_FIFO_THRESHOLD 328
  249. /* location: {CR92,0,3},{CR95,0,2} */
  250. #define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296
  251. /* location: {CR94,0,6} */
  252. #define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124
  253. /* VT3327 chipset*/
  254. /* location: {SR17,0,7} */
  255. #define P4M890_IGA1_FIFO_MAX_DEPTH 96
  256. /* location: {SR16,0,5},{SR16,7,7} */
  257. #define P4M890_IGA1_FIFO_THRESHOLD 76
  258. /* location: {SR18,0,5},{SR18,7,7} */
  259. #define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64
  260. /* location: {SR22,0,4}. (32/4) =8 */
  261. #define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  262. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  263. #define P4M890_IGA2_FIFO_MAX_DEPTH 96
  264. /* location: {CR68,0,3},{CR95,4,6} */
  265. #define P4M890_IGA2_FIFO_THRESHOLD 76
  266. /* location: {CR92,0,3},{CR95,0,2} */
  267. #define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64
  268. /* location: {CR94,0,6} */
  269. #define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  270. /* VT3364 chipset*/
  271. /* location: {SR17,0,7} */
  272. #define P4M900_IGA1_FIFO_MAX_DEPTH 96
  273. /* location: {SR16,0,5},{SR16,7,7} */
  274. #define P4M900_IGA1_FIFO_THRESHOLD 76
  275. /* location: {SR18,0,5},{SR18,7,7} */
  276. #define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76
  277. /* location: {SR22,0,4}. */
  278. #define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  279. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  280. #define P4M900_IGA2_FIFO_MAX_DEPTH 96
  281. /* location: {CR68,0,3},{CR95,4,6} */
  282. #define P4M900_IGA2_FIFO_THRESHOLD 76
  283. /* location: {CR92,0,3},{CR95,0,2} */
  284. #define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76
  285. /* location: {CR94,0,6} */
  286. #define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  287. /* For VT3353, these values are suggested by HW */
  288. /* location: {SR17,0,7} */
  289. #define VX800_IGA1_FIFO_MAX_DEPTH 192
  290. /* location: {SR16,0,5},{SR16,7,7} */
  291. #define VX800_IGA1_FIFO_THRESHOLD 152
  292. /* location: {SR18,0,5},{SR18,7,7} */
  293. #define VX800_IGA1_FIFO_HIGH_THRESHOLD 152
  294. /* location: {SR22,0,4} */
  295. #define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64
  296. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  297. #define VX800_IGA2_FIFO_MAX_DEPTH 96
  298. /* location: {CR68,0,3},{CR95,4,6} */
  299. #define VX800_IGA2_FIFO_THRESHOLD 64
  300. /* location: {CR92,0,3},{CR95,0,2} */
  301. #define VX800_IGA2_FIFO_HIGH_THRESHOLD 32
  302. /* location: {CR94,0,6} */
  303. #define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  304. /* For VT3409 */
  305. #define VX855_IGA1_FIFO_MAX_DEPTH 400
  306. #define VX855_IGA1_FIFO_THRESHOLD 320
  307. #define VX855_IGA1_FIFO_HIGH_THRESHOLD 320
  308. #define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  309. #define VX855_IGA2_FIFO_MAX_DEPTH 200
  310. #define VX855_IGA2_FIFO_THRESHOLD 160
  311. #define VX855_IGA2_FIFO_HIGH_THRESHOLD 160
  312. #define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  313. #define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1
  314. #define IGA1_FIFO_THRESHOLD_REG_NUM 2
  315. #define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2
  316. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  317. #define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3
  318. #define IGA2_FIFO_THRESHOLD_REG_NUM 2
  319. #define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2
  320. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  321. #define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1)
  322. #define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4)
  323. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  324. #define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  325. #define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1)
  326. #define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4)
  327. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  328. #define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  329. /************************************************************************/
  330. /* LCD Timing */
  331. /************************************************************************/
  332. /* 500 ms = 500000 us */
  333. #define LCD_POWER_SEQ_TD0 500000
  334. /* 50 ms = 50000 us */
  335. #define LCD_POWER_SEQ_TD1 50000
  336. /* 0 us */
  337. #define LCD_POWER_SEQ_TD2 0
  338. /* 210 ms = 210000 us */
  339. #define LCD_POWER_SEQ_TD3 210000
  340. /* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */
  341. #define CLE266_POWER_SEQ_UNIT 71
  342. /* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */
  343. #define K800_POWER_SEQ_UNIT 142
  344. /* 2^13 * (1/14.31818M) = 572.1 us */
  345. #define P880_POWER_SEQ_UNIT 572
  346. #define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT)
  347. #define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT)
  348. #define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT)
  349. /* location: {CR8B,0,7},{CR8F,0,3} */
  350. #define LCD_POWER_SEQ_TD0_REG_NUM 2
  351. /* location: {CR8C,0,7},{CR8F,4,7} */
  352. #define LCD_POWER_SEQ_TD1_REG_NUM 2
  353. /* location: {CR8D,0,7},{CR90,0,3} */
  354. #define LCD_POWER_SEQ_TD2_REG_NUM 2
  355. /* location: {CR8E,0,7},{CR90,4,7} */
  356. #define LCD_POWER_SEQ_TD3_REG_NUM 2
  357. /* LCD Scaling factor*/
  358. /* x: indicate setting horizontal size*/
  359. /* y: indicate panel horizontal size*/
  360. /* Horizontal scaling factor 10 bits (2^10) */
  361. #define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  362. /* Vertical scaling factor 10 bits (2^10) */
  363. #define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  364. /* Horizontal scaling factor 10 bits (2^12) */
  365. #define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1))
  366. /* Vertical scaling factor 10 bits (2^11) */
  367. #define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1))
  368. /* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */
  369. #define LCD_HOR_SCALING_FACTOR_REG_NUM 3
  370. /* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */
  371. #define LCD_VER_SCALING_FACTOR_REG_NUM 3
  372. /* location: {CR77,0,7},{CR79,4,5} */
  373. #define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2
  374. /* location: {CR78,0,7},{CR79,6,7} */
  375. #define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2
  376. /************************************************
  377. ***** Define IGA1 Display Timing *****
  378. ************************************************/
  379. struct io_register {
  380. u8 io_addr;
  381. u8 start_bit;
  382. u8 end_bit;
  383. };
  384. /* IGA1 Horizontal Total */
  385. struct iga1_hor_total {
  386. int reg_num;
  387. struct io_register reg[IGA1_HOR_TOTAL_REG_NUM];
  388. };
  389. /* IGA1 Horizontal Addressable Video */
  390. struct iga1_hor_addr {
  391. int reg_num;
  392. struct io_register reg[IGA1_HOR_ADDR_REG_NUM];
  393. };
  394. /* IGA1 Horizontal Blank Start */
  395. struct iga1_hor_blank_start {
  396. int reg_num;
  397. struct io_register reg[IGA1_HOR_BLANK_START_REG_NUM];
  398. };
  399. /* IGA1 Horizontal Blank End */
  400. struct iga1_hor_blank_end {
  401. int reg_num;
  402. struct io_register reg[IGA1_HOR_BLANK_END_REG_NUM];
  403. };
  404. /* IGA1 Horizontal Sync Start */
  405. struct iga1_hor_sync_start {
  406. int reg_num;
  407. struct io_register reg[IGA1_HOR_SYNC_START_REG_NUM];
  408. };
  409. /* IGA1 Horizontal Sync End */
  410. struct iga1_hor_sync_end {
  411. int reg_num;
  412. struct io_register reg[IGA1_HOR_SYNC_END_REG_NUM];
  413. };
  414. /* IGA1 Vertical Total */
  415. struct iga1_ver_total {
  416. int reg_num;
  417. struct io_register reg[IGA1_VER_TOTAL_REG_NUM];
  418. };
  419. /* IGA1 Vertical Addressable Video */
  420. struct iga1_ver_addr {
  421. int reg_num;
  422. struct io_register reg[IGA1_VER_ADDR_REG_NUM];
  423. };
  424. /* IGA1 Vertical Blank Start */
  425. struct iga1_ver_blank_start {
  426. int reg_num;
  427. struct io_register reg[IGA1_VER_BLANK_START_REG_NUM];
  428. };
  429. /* IGA1 Vertical Blank End */
  430. struct iga1_ver_blank_end {
  431. int reg_num;
  432. struct io_register reg[IGA1_VER_BLANK_END_REG_NUM];
  433. };
  434. /* IGA1 Vertical Sync Start */
  435. struct iga1_ver_sync_start {
  436. int reg_num;
  437. struct io_register reg[IGA1_VER_SYNC_START_REG_NUM];
  438. };
  439. /* IGA1 Vertical Sync End */
  440. struct iga1_ver_sync_end {
  441. int reg_num;
  442. struct io_register reg[IGA1_VER_SYNC_END_REG_NUM];
  443. };
  444. /*****************************************************
  445. ** Define IGA2 Shadow Display Timing ****
  446. *****************************************************/
  447. /* IGA2 Shadow Horizontal Total */
  448. struct iga2_shadow_hor_total {
  449. int reg_num;
  450. struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM];
  451. };
  452. /* IGA2 Shadow Horizontal Blank End */
  453. struct iga2_shadow_hor_blank_end {
  454. int reg_num;
  455. struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM];
  456. };
  457. /* IGA2 Shadow Vertical Total */
  458. struct iga2_shadow_ver_total {
  459. int reg_num;
  460. struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM];
  461. };
  462. /* IGA2 Shadow Vertical Addressable Video */
  463. struct iga2_shadow_ver_addr {
  464. int reg_num;
  465. struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM];
  466. };
  467. /* IGA2 Shadow Vertical Blank Start */
  468. struct iga2_shadow_ver_blank_start {
  469. int reg_num;
  470. struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM];
  471. };
  472. /* IGA2 Shadow Vertical Blank End */
  473. struct iga2_shadow_ver_blank_end {
  474. int reg_num;
  475. struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM];
  476. };
  477. /* IGA2 Shadow Vertical Sync Start */
  478. struct iga2_shadow_ver_sync_start {
  479. int reg_num;
  480. struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM];
  481. };
  482. /* IGA2 Shadow Vertical Sync End */
  483. struct iga2_shadow_ver_sync_end {
  484. int reg_num;
  485. struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM];
  486. };
  487. /*****************************************************
  488. ** Define IGA2 Display Timing ****
  489. ******************************************************/
  490. /* IGA2 Horizontal Total */
  491. struct iga2_hor_total {
  492. int reg_num;
  493. struct io_register reg[IGA2_HOR_TOTAL_REG_NUM];
  494. };
  495. /* IGA2 Horizontal Addressable Video */
  496. struct iga2_hor_addr {
  497. int reg_num;
  498. struct io_register reg[IGA2_HOR_ADDR_REG_NUM];
  499. };
  500. /* IGA2 Horizontal Blank Start */
  501. struct iga2_hor_blank_start {
  502. int reg_num;
  503. struct io_register reg[IGA2_HOR_BLANK_START_REG_NUM];
  504. };
  505. /* IGA2 Horizontal Blank End */
  506. struct iga2_hor_blank_end {
  507. int reg_num;
  508. struct io_register reg[IGA2_HOR_BLANK_END_REG_NUM];
  509. };
  510. /* IGA2 Horizontal Sync Start */
  511. struct iga2_hor_sync_start {
  512. int reg_num;
  513. struct io_register reg[IGA2_HOR_SYNC_START_REG_NUM];
  514. };
  515. /* IGA2 Horizontal Sync End */
  516. struct iga2_hor_sync_end {
  517. int reg_num;
  518. struct io_register reg[IGA2_HOR_SYNC_END_REG_NUM];
  519. };
  520. /* IGA2 Vertical Total */
  521. struct iga2_ver_total {
  522. int reg_num;
  523. struct io_register reg[IGA2_VER_TOTAL_REG_NUM];
  524. };
  525. /* IGA2 Vertical Addressable Video */
  526. struct iga2_ver_addr {
  527. int reg_num;
  528. struct io_register reg[IGA2_VER_ADDR_REG_NUM];
  529. };
  530. /* IGA2 Vertical Blank Start */
  531. struct iga2_ver_blank_start {
  532. int reg_num;
  533. struct io_register reg[IGA2_VER_BLANK_START_REG_NUM];
  534. };
  535. /* IGA2 Vertical Blank End */
  536. struct iga2_ver_blank_end {
  537. int reg_num;
  538. struct io_register reg[IGA2_VER_BLANK_END_REG_NUM];
  539. };
  540. /* IGA2 Vertical Sync Start */
  541. struct iga2_ver_sync_start {
  542. int reg_num;
  543. struct io_register reg[IGA2_VER_SYNC_START_REG_NUM];
  544. };
  545. /* IGA2 Vertical Sync End */
  546. struct iga2_ver_sync_end {
  547. int reg_num;
  548. struct io_register reg[IGA2_VER_SYNC_END_REG_NUM];
  549. };
  550. /* IGA1 Fetch Count Register */
  551. struct iga1_fetch_count {
  552. int reg_num;
  553. struct io_register reg[IGA1_FETCH_COUNT_REG_NUM];
  554. };
  555. /* IGA2 Fetch Count Register */
  556. struct iga2_fetch_count {
  557. int reg_num;
  558. struct io_register reg[IGA2_FETCH_COUNT_REG_NUM];
  559. };
  560. struct fetch_count {
  561. struct iga1_fetch_count iga1_fetch_count_reg;
  562. struct iga2_fetch_count iga2_fetch_count_reg;
  563. };
  564. /* Starting Address Register */
  565. struct iga1_starting_addr {
  566. int reg_num;
  567. struct io_register reg[IGA1_STARTING_ADDR_REG_NUM];
  568. };
  569. struct iga2_starting_addr {
  570. int reg_num;
  571. struct io_register reg[IGA2_STARTING_ADDR_REG_NUM];
  572. };
  573. struct starting_addr {
  574. struct iga1_starting_addr iga1_starting_addr_reg;
  575. struct iga2_starting_addr iga2_starting_addr_reg;
  576. };
  577. /* LCD Power Sequence Timer */
  578. struct lcd_pwd_seq_td0 {
  579. int reg_num;
  580. struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM];
  581. };
  582. struct lcd_pwd_seq_td1 {
  583. int reg_num;
  584. struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM];
  585. };
  586. struct lcd_pwd_seq_td2 {
  587. int reg_num;
  588. struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM];
  589. };
  590. struct lcd_pwd_seq_td3 {
  591. int reg_num;
  592. struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM];
  593. };
  594. struct _lcd_pwd_seq_timer {
  595. struct lcd_pwd_seq_td0 td0;
  596. struct lcd_pwd_seq_td1 td1;
  597. struct lcd_pwd_seq_td2 td2;
  598. struct lcd_pwd_seq_td3 td3;
  599. };
  600. /* LCD Scaling Factor */
  601. struct _lcd_hor_scaling_factor {
  602. int reg_num;
  603. struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM];
  604. };
  605. struct _lcd_ver_scaling_factor {
  606. int reg_num;
  607. struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM];
  608. };
  609. struct _lcd_scaling_factor {
  610. struct _lcd_hor_scaling_factor lcd_hor_scaling_factor;
  611. struct _lcd_ver_scaling_factor lcd_ver_scaling_factor;
  612. };
  613. struct pll_config {
  614. u16 multiplier;
  615. u8 divisor;
  616. u8 rshift;
  617. };
  618. struct pll_map {
  619. u32 clk;
  620. struct pll_config cle266_pll;
  621. struct pll_config k800_pll;
  622. struct pll_config cx700_pll;
  623. struct pll_config vx855_pll;
  624. };
  625. struct rgbLUT {
  626. u8 red;
  627. u8 green;
  628. u8 blue;
  629. };
  630. struct lcd_pwd_seq_timer {
  631. u16 td0;
  632. u16 td1;
  633. u16 td2;
  634. u16 td3;
  635. };
  636. /* Display FIFO Relation Registers*/
  637. struct iga1_fifo_depth_select {
  638. int reg_num;
  639. struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM];
  640. };
  641. struct iga1_fifo_threshold_select {
  642. int reg_num;
  643. struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM];
  644. };
  645. struct iga1_fifo_high_threshold_select {
  646. int reg_num;
  647. struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM];
  648. };
  649. struct iga1_display_queue_expire_num {
  650. int reg_num;
  651. struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  652. };
  653. struct iga2_fifo_depth_select {
  654. int reg_num;
  655. struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM];
  656. };
  657. struct iga2_fifo_threshold_select {
  658. int reg_num;
  659. struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM];
  660. };
  661. struct iga2_fifo_high_threshold_select {
  662. int reg_num;
  663. struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM];
  664. };
  665. struct iga2_display_queue_expire_num {
  666. int reg_num;
  667. struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  668. };
  669. struct fifo_depth_select {
  670. struct iga1_fifo_depth_select iga1_fifo_depth_select_reg;
  671. struct iga2_fifo_depth_select iga2_fifo_depth_select_reg;
  672. };
  673. struct fifo_threshold_select {
  674. struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg;
  675. struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg;
  676. };
  677. struct fifo_high_threshold_select {
  678. struct iga1_fifo_high_threshold_select
  679. iga1_fifo_high_threshold_select_reg;
  680. struct iga2_fifo_high_threshold_select
  681. iga2_fifo_high_threshold_select_reg;
  682. };
  683. struct display_queue_expire_num {
  684. struct iga1_display_queue_expire_num
  685. iga1_display_queue_expire_num_reg;
  686. struct iga2_display_queue_expire_num
  687. iga2_display_queue_expire_num_reg;
  688. };
  689. struct iga1_crtc_timing {
  690. struct iga1_hor_total hor_total;
  691. struct iga1_hor_addr hor_addr;
  692. struct iga1_hor_blank_start hor_blank_start;
  693. struct iga1_hor_blank_end hor_blank_end;
  694. struct iga1_hor_sync_start hor_sync_start;
  695. struct iga1_hor_sync_end hor_sync_end;
  696. struct iga1_ver_total ver_total;
  697. struct iga1_ver_addr ver_addr;
  698. struct iga1_ver_blank_start ver_blank_start;
  699. struct iga1_ver_blank_end ver_blank_end;
  700. struct iga1_ver_sync_start ver_sync_start;
  701. struct iga1_ver_sync_end ver_sync_end;
  702. };
  703. struct iga2_shadow_crtc_timing {
  704. struct iga2_shadow_hor_total hor_total_shadow;
  705. struct iga2_shadow_hor_blank_end hor_blank_end_shadow;
  706. struct iga2_shadow_ver_total ver_total_shadow;
  707. struct iga2_shadow_ver_addr ver_addr_shadow;
  708. struct iga2_shadow_ver_blank_start ver_blank_start_shadow;
  709. struct iga2_shadow_ver_blank_end ver_blank_end_shadow;
  710. struct iga2_shadow_ver_sync_start ver_sync_start_shadow;
  711. struct iga2_shadow_ver_sync_end ver_sync_end_shadow;
  712. };
  713. struct iga2_crtc_timing {
  714. struct iga2_hor_total hor_total;
  715. struct iga2_hor_addr hor_addr;
  716. struct iga2_hor_blank_start hor_blank_start;
  717. struct iga2_hor_blank_end hor_blank_end;
  718. struct iga2_hor_sync_start hor_sync_start;
  719. struct iga2_hor_sync_end hor_sync_end;
  720. struct iga2_ver_total ver_total;
  721. struct iga2_ver_addr ver_addr;
  722. struct iga2_ver_blank_start ver_blank_start;
  723. struct iga2_ver_blank_end ver_blank_end;
  724. struct iga2_ver_sync_start ver_sync_start;
  725. struct iga2_ver_sync_end ver_sync_end;
  726. };
  727. /* device ID */
  728. #define CLE266_FUNCTION3 0x3123
  729. #define KM400_FUNCTION3 0x3205
  730. #define CN400_FUNCTION2 0x2259
  731. #define CN400_FUNCTION3 0x3259
  732. /* support VT3314 chipset */
  733. #define CN700_FUNCTION2 0x2314
  734. #define CN700_FUNCTION3 0x3208
  735. /* VT3324 chipset */
  736. #define CX700_FUNCTION2 0x2324
  737. #define CX700_FUNCTION3 0x3324
  738. /* VT3204 chipset*/
  739. #define KM800_FUNCTION3 0x3204
  740. /* VT3336 chipset*/
  741. #define KM890_FUNCTION3 0x3336
  742. /* VT3327 chipset*/
  743. #define P4M890_FUNCTION3 0x3327
  744. /* VT3293 chipset*/
  745. #define CN750_FUNCTION3 0x3208
  746. /* VT3364 chipset*/
  747. #define P4M900_FUNCTION3 0x3364
  748. /* VT3353 chipset*/
  749. #define VX800_FUNCTION3 0x3353
  750. /* VT3409 chipset*/
  751. #define VX855_FUNCTION3 0x3409
  752. #define NUM_TOTAL_PLL_TABLE ARRAY_SIZE(pll_value)
  753. struct IODATA {
  754. u8 Index;
  755. u8 Mask;
  756. u8 Data;
  757. };
  758. struct pci_device_id_info {
  759. u32 vendor;
  760. u32 device;
  761. u32 chip_index;
  762. };
  763. extern unsigned int viafb_second_virtual_xres;
  764. extern int viafb_SAMM_ON;
  765. extern int viafb_dual_fb;
  766. extern int viafb_LCD2_ON;
  767. extern int viafb_LCD_ON;
  768. extern int viafb_DVI_ON;
  769. extern int viafb_hotplug;
  770. void viafb_set_output_path(int device, int set_iga,
  771. int output_interface);
  772. void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
  773. struct VideoModeTable *video_mode, int bpp_byte, int set_iga);
  774. void viafb_set_vclock(u32 CLK, int set_iga);
  775. void viafb_load_reg(int timing_value, int viafb_load_reg_num,
  776. struct io_register *reg,
  777. int io_type);
  778. void viafb_crt_disable(void);
  779. void viafb_crt_enable(void);
  780. void init_ad9389(void);
  781. /* Access I/O Function */
  782. void viafb_lock_crt(void);
  783. void viafb_unlock_crt(void);
  784. void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
  785. void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
  786. u32 viafb_get_clk_value(int clk);
  787. void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
  788. void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
  789. *p_gfx_dpa_setting);
  790. int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
  791. struct VideoModeTable *vmode_tbl1, int video_bpp1);
  792. void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
  793. struct VideoModeTable *vmode_tbl);
  794. void __devinit viafb_init_chip_info(int chip_type);
  795. void __devinit viafb_init_dac(int set_iga);
  796. int viafb_get_pixclock(int hres, int vres, int vmode_refresh);
  797. int viafb_get_refresh(int hres, int vres, u32 float_refresh);
  798. void viafb_update_device_setting(int hres, int vres, int bpp,
  799. int vmode_refresh, int flag);
  800. void viafb_set_iga_path(void);
  801. void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
  802. void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
  803. void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
  804. #endif /* __HW_H__ */