newport.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* $Id: newport.h,v 1.5 1999/08/04 06:01:51 ulfc Exp $
  3. *
  4. * newport.h: Defines and register layout for NEWPORT graphics
  5. * hardware.
  6. *
  7. * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
  8. *
  9. * Ulf Carlsson - Compatibility with the IRIX structures added
  10. */
  11. #ifndef _SGI_NEWPORT_H
  12. #define _SGI_NEWPORT_H
  13. typedef volatile unsigned int npireg_t;
  14. union npfloat {
  15. volatile float flt;
  16. npireg_t word;
  17. };
  18. typedef union npfloat npfreg_t;
  19. union np_dcb {
  20. npireg_t byword;
  21. struct { volatile unsigned short s0, s1; } byshort;
  22. struct { volatile unsigned char b0, b1, b2, b3; } bybytes;
  23. };
  24. struct newport_rexregs {
  25. npireg_t drawmode1; /* GL extra mode bits */
  26. #define DM1_PLANES 0x00000007
  27. #define DM1_NOPLANES 0x00000000
  28. #define DM1_RGBPLANES 0x00000001
  29. #define DM1_RGBAPLANES 0x00000002
  30. #define DM1_OLAYPLANES 0x00000004
  31. #define DM1_PUPPLANES 0x00000005
  32. #define DM1_CIDPLANES 0x00000006
  33. #define NPORT_DMODE1_DDMASK 0x00000018
  34. #define NPORT_DMODE1_DD4 0x00000000
  35. #define NPORT_DMODE1_DD8 0x00000008
  36. #define NPORT_DMODE1_DD12 0x00000010
  37. #define NPORT_DMODE1_DD24 0x00000018
  38. #define NPORT_DMODE1_DSRC 0x00000020
  39. #define NPORT_DMODE1_YFLIP 0x00000040
  40. #define NPORT_DMODE1_RWPCKD 0x00000080
  41. #define NPORT_DMODE1_HDMASK 0x00000300
  42. #define NPORT_DMODE1_HD4 0x00000000
  43. #define NPORT_DMODE1_HD8 0x00000100
  44. #define NPORT_DMODE1_HD12 0x00000200
  45. #define NPORT_DMODE1_HD32 0x00000300
  46. #define NPORT_DMODE1_RWDBL 0x00000400
  47. #define NPORT_DMODE1_ESWAP 0x00000800 /* Endian swap */
  48. #define NPORT_DMODE1_CCMASK 0x00007000
  49. #define NPORT_DMODE1_CCLT 0x00001000
  50. #define NPORT_DMODE1_CCEQ 0x00002000
  51. #define NPORT_DMODE1_CCGT 0x00004000
  52. #define NPORT_DMODE1_RGBMD 0x00008000
  53. #define NPORT_DMODE1_DENAB 0x00010000 /* Dither enable */
  54. #define NPORT_DMODE1_FCLR 0x00020000 /* Fast clear */
  55. #define NPORT_DMODE1_BENAB 0x00040000 /* Blend enable */
  56. #define NPORT_DMODE1_SFMASK 0x00380000
  57. #define NPORT_DMODE1_SF0 0x00000000
  58. #define NPORT_DMODE1_SF1 0x00080000
  59. #define NPORT_DMODE1_SFDC 0x00100000
  60. #define NPORT_DMODE1_SFMDC 0x00180000
  61. #define NPORT_DMODE1_SFSA 0x00200000
  62. #define NPORT_DMODE1_SFMSA 0x00280000
  63. #define NPORT_DMODE1_DFMASK 0x01c00000
  64. #define NPORT_DMODE1_DF0 0x00000000
  65. #define NPORT_DMODE1_DF1 0x00400000
  66. #define NPORT_DMODE1_DFSC 0x00800000
  67. #define NPORT_DMODE1_DFMSC 0x00c00000
  68. #define NPORT_DMODE1_DFSA 0x01000000
  69. #define NPORT_DMODE1_DFMSA 0x01400000
  70. #define NPORT_DMODE1_BBENAB 0x02000000 /* Back blend enable */
  71. #define NPORT_DMODE1_PFENAB 0x04000000 /* Pre-fetch enable */
  72. #define NPORT_DMODE1_ABLEND 0x08000000 /* Alpha blend */
  73. #define NPORT_DMODE1_LOMASK 0xf0000000
  74. #define NPORT_DMODE1_LOZERO 0x00000000
  75. #define NPORT_DMODE1_LOAND 0x10000000
  76. #define NPORT_DMODE1_LOANDR 0x20000000
  77. #define NPORT_DMODE1_LOSRC 0x30000000
  78. #define NPORT_DMODE1_LOANDI 0x40000000
  79. #define NPORT_DMODE1_LODST 0x50000000
  80. #define NPORT_DMODE1_LOXOR 0x60000000
  81. #define NPORT_DMODE1_LOOR 0x70000000
  82. #define NPORT_DMODE1_LONOR 0x80000000
  83. #define NPORT_DMODE1_LOXNOR 0x90000000
  84. #define NPORT_DMODE1_LONDST 0xa0000000
  85. #define NPORT_DMODE1_LOORR 0xb0000000
  86. #define NPORT_DMODE1_LONSRC 0xc0000000
  87. #define NPORT_DMODE1_LOORI 0xd0000000
  88. #define NPORT_DMODE1_LONAND 0xe0000000
  89. #define NPORT_DMODE1_LOONE 0xf0000000
  90. npireg_t drawmode0; /* REX command register */
  91. /* These bits define the graphics opcode being performed. */
  92. #define NPORT_DMODE0_OPMASK 0x00000003 /* Opcode mask */
  93. #define NPORT_DMODE0_NOP 0x00000000 /* No operation */
  94. #define NPORT_DMODE0_RD 0x00000001 /* Read operation */
  95. #define NPORT_DMODE0_DRAW 0x00000002 /* Draw operation */
  96. #define NPORT_DMODE0_S2S 0x00000003 /* Screen to screen operation */
  97. /* The following decide what addressing mode(s) are to be used */
  98. #define NPORT_DMODE0_AMMASK 0x0000001c /* Address mode mask */
  99. #define NPORT_DMODE0_SPAN 0x00000000 /* Spanning address mode */
  100. #define NPORT_DMODE0_BLOCK 0x00000004 /* Block address mode */
  101. #define NPORT_DMODE0_ILINE 0x00000008 /* Iline address mode */
  102. #define NPORT_DMODE0_FLINE 0x0000000c /* Fline address mode */
  103. #define NPORT_DMODE0_ALINE 0x00000010 /* Aline address mode */
  104. #define NPORT_DMODE0_TLINE 0x00000014 /* Tline address mode */
  105. #define NPORT_DMODE0_BLINE 0x00000018 /* Bline address mode */
  106. /* And now some misc. operation control bits. */
  107. #define NPORT_DMODE0_DOSETUP 0x00000020
  108. #define NPORT_DMODE0_CHOST 0x00000040
  109. #define NPORT_DMODE0_AHOST 0x00000080
  110. #define NPORT_DMODE0_STOPX 0x00000100
  111. #define NPORT_DMODE0_STOPY 0x00000200
  112. #define NPORT_DMODE0_SK1ST 0x00000400
  113. #define NPORT_DMODE0_SKLST 0x00000800
  114. #define NPORT_DMODE0_ZPENAB 0x00001000
  115. #define NPORT_DMODE0_LISPENAB 0x00002000
  116. #define NPORT_DMODE0_LISLST 0x00004000
  117. #define NPORT_DMODE0_L32 0x00008000
  118. #define NPORT_DMODE0_ZOPQ 0x00010000
  119. #define NPORT_DMODE0_LISOPQ 0x00020000
  120. #define NPORT_DMODE0_SHADE 0x00040000
  121. #define NPORT_DMODE0_LRONLY 0x00080000
  122. #define NPORT_DMODE0_XYOFF 0x00100000
  123. #define NPORT_DMODE0_CLAMP 0x00200000
  124. #define NPORT_DMODE0_ENDPF 0x00400000
  125. #define NPORT_DMODE0_YSTR 0x00800000
  126. npireg_t lsmode; /* Mode for line stipple ops */
  127. npireg_t lspattern; /* Pattern for line stipple ops */
  128. npireg_t lspatsave; /* Backup save pattern */
  129. npireg_t zpattern; /* Pixel zpattern */
  130. npireg_t colorback; /* Background color */
  131. npireg_t colorvram; /* Clear color for fast vram */
  132. npireg_t alpharef; /* Reference value for afunctions */
  133. unsigned int pad0;
  134. npireg_t smask0x; /* Window GL relative screen mask 0 */
  135. npireg_t smask0y; /* Window GL relative screen mask 0 */
  136. npireg_t _setup;
  137. npireg_t _stepz;
  138. npireg_t _lsrestore;
  139. npireg_t _lssave;
  140. unsigned int _pad1[0x30];
  141. /* Iterators, full state for context switch */
  142. npfreg_t _xstart; /* X-start point (current) */
  143. npfreg_t _ystart; /* Y-start point (current) */
  144. npfreg_t _xend; /* x-end point */
  145. npfreg_t _yend; /* y-end point */
  146. npireg_t xsave; /* copy of xstart integer value for BLOCk addressing MODE */
  147. npireg_t xymove; /* x.y offset from xstart, ystart for relative operations */
  148. npfreg_t bresd;
  149. npfreg_t bress1;
  150. npireg_t bresoctinc1;
  151. volatile int bresrndinc2;
  152. npireg_t brese1;
  153. npireg_t bress2;
  154. npireg_t aweight0;
  155. npireg_t aweight1;
  156. npfreg_t xstartf;
  157. npfreg_t ystartf;
  158. npfreg_t xendf;
  159. npfreg_t yendf;
  160. npireg_t xstarti;
  161. npfreg_t xendf1;
  162. npireg_t xystarti;
  163. npireg_t xyendi;
  164. npireg_t xstartendi;
  165. unsigned int _unused2[0x29];
  166. npfreg_t colorred;
  167. npfreg_t coloralpha;
  168. npfreg_t colorgrn;
  169. npfreg_t colorblue;
  170. npfreg_t slopered;
  171. npfreg_t slopealpha;
  172. npfreg_t slopegrn;
  173. npfreg_t slopeblue;
  174. npireg_t wrmask;
  175. npireg_t colori;
  176. npfreg_t colorx;
  177. npfreg_t slopered1;
  178. npireg_t hostrw0;
  179. npireg_t hostrw1;
  180. npireg_t dcbmode;
  181. #define NPORT_DMODE_WMASK 0x00000003
  182. #define NPORT_DMODE_W4 0x00000000
  183. #define NPORT_DMODE_W1 0x00000001
  184. #define NPORT_DMODE_W2 0x00000002
  185. #define NPORT_DMODE_W3 0x00000003
  186. #define NPORT_DMODE_EDPACK 0x00000004
  187. #define NPORT_DMODE_ECINC 0x00000008
  188. #define NPORT_DMODE_CMASK 0x00000070
  189. #define NPORT_DMODE_AMASK 0x00000780
  190. #define NPORT_DMODE_AVC2 0x00000000
  191. #define NPORT_DMODE_ACMALL 0x00000080
  192. #define NPORT_DMODE_ACM0 0x00000100
  193. #define NPORT_DMODE_ACM1 0x00000180
  194. #define NPORT_DMODE_AXMALL 0x00000200
  195. #define NPORT_DMODE_AXM0 0x00000280
  196. #define NPORT_DMODE_AXM1 0x00000300
  197. #define NPORT_DMODE_ABT 0x00000380
  198. #define NPORT_DMODE_AVCC1 0x00000400
  199. #define NPORT_DMODE_AVAB1 0x00000480
  200. #define NPORT_DMODE_ALG3V0 0x00000500
  201. #define NPORT_DMODE_A1562 0x00000580
  202. #define NPORT_DMODE_ESACK 0x00000800
  203. #define NPORT_DMODE_EASACK 0x00001000
  204. #define NPORT_DMODE_CWMASK 0x0003e000
  205. #define NPORT_DMODE_CHMASK 0x007c0000
  206. #define NPORT_DMODE_CSMASK 0x0f800000
  207. #define NPORT_DMODE_SENDIAN 0x10000000
  208. unsigned int _unused3;
  209. union np_dcb dcbdata0;
  210. npireg_t dcbdata1;
  211. };
  212. struct newport_cregs {
  213. npireg_t smask1x;
  214. npireg_t smask1y;
  215. npireg_t smask2x;
  216. npireg_t smask2y;
  217. npireg_t smask3x;
  218. npireg_t smask3y;
  219. npireg_t smask4x;
  220. npireg_t smask4y;
  221. npireg_t topscan;
  222. npireg_t xywin;
  223. npireg_t clipmode;
  224. #define NPORT_CMODE_SM0 0x00000001
  225. #define NPORT_CMODE_SM1 0x00000002
  226. #define NPORT_CMODE_SM2 0x00000004
  227. #define NPORT_CMODE_SM3 0x00000008
  228. #define NPORT_CMODE_SM4 0x00000010
  229. #define NPORT_CMODE_CMSK 0x00001e00
  230. unsigned int _unused0;
  231. unsigned int config;
  232. #define NPORT_CFG_G32MD 0x00000001
  233. #define NPORT_CFG_BWIDTH 0x00000002
  234. #define NPORT_CFG_ERCVR 0x00000004
  235. #define NPORT_CFG_BDMSK 0x00000078
  236. #define NPORT_CFG_BFAINT 0x00000080
  237. #define NPORT_CFG_GDMSK 0x00001f80
  238. #define NPORT_CFG_GD0 0x00000100
  239. #define NPORT_CFG_GD1 0x00000200
  240. #define NPORT_CFG_GD2 0x00000400
  241. #define NPORT_CFG_GD3 0x00000800
  242. #define NPORT_CFG_GD4 0x00001000
  243. #define NPORT_CFG_GFAINT 0x00002000
  244. #define NPORT_CFG_TOMSK 0x0001c000
  245. #define NPORT_CFG_VRMSK 0x000e0000
  246. #define NPORT_CFG_FBTYP 0x00100000
  247. npireg_t _unused1;
  248. npireg_t status;
  249. #define NPORT_STAT_VERS 0x00000007
  250. #define NPORT_STAT_GBUSY 0x00000008
  251. #define NPORT_STAT_BBUSY 0x00000010
  252. #define NPORT_STAT_VRINT 0x00000020
  253. #define NPORT_STAT_VIDINT 0x00000040
  254. #define NPORT_STAT_GLMSK 0x00001f80
  255. #define NPORT_STAT_BLMSK 0x0007e000
  256. #define NPORT_STAT_BFIRQ 0x00080000
  257. #define NPORT_STAT_GFIRQ 0x00100000
  258. npireg_t ustatus;
  259. npireg_t dcbreset;
  260. };
  261. struct newport_regs {
  262. struct newport_rexregs set;
  263. unsigned int _unused0[0x16e];
  264. struct newport_rexregs go;
  265. unsigned int _unused1[0x22e];
  266. struct newport_cregs cset;
  267. unsigned int _unused2[0x1ef];
  268. struct newport_cregs cgo;
  269. };
  270. typedef struct {
  271. unsigned int drawmode1;
  272. unsigned int drawmode0;
  273. unsigned int lsmode;
  274. unsigned int lspattern;
  275. unsigned int lspatsave;
  276. unsigned int zpattern;
  277. unsigned int colorback;
  278. unsigned int colorvram;
  279. unsigned int alpharef;
  280. unsigned int smask0x;
  281. unsigned int smask0y;
  282. unsigned int _xstart;
  283. unsigned int _ystart;
  284. unsigned int _xend;
  285. unsigned int _yend;
  286. unsigned int xsave;
  287. unsigned int xymove;
  288. unsigned int bresd;
  289. unsigned int bress1;
  290. unsigned int bresoctinc1;
  291. unsigned int bresrndinc2;
  292. unsigned int brese1;
  293. unsigned int bress2;
  294. unsigned int aweight0;
  295. unsigned int aweight1;
  296. unsigned int colorred;
  297. unsigned int coloralpha;
  298. unsigned int colorgrn;
  299. unsigned int colorblue;
  300. unsigned int slopered;
  301. unsigned int slopealpha;
  302. unsigned int slopegrn;
  303. unsigned int slopeblue;
  304. unsigned int wrmask;
  305. unsigned int hostrw0;
  306. unsigned int hostrw1;
  307. /* configregs */
  308. unsigned int smask1x;
  309. unsigned int smask1y;
  310. unsigned int smask2x;
  311. unsigned int smask2y;
  312. unsigned int smask3x;
  313. unsigned int smask3y;
  314. unsigned int smask4x;
  315. unsigned int smask4y;
  316. unsigned int topscan;
  317. unsigned int xywin;
  318. unsigned int clipmode;
  319. unsigned int config;
  320. /* dcb registers */
  321. unsigned int dcbmode;
  322. unsigned int dcbdata0;
  323. unsigned int dcbdata1;
  324. } newport_ctx;
  325. /* Reading/writing VC2 registers. */
  326. #define VC2_REGADDR_INDEX 0x00000000
  327. #define VC2_REGADDR_IREG 0x00000010
  328. #define VC2_REGADDR_RAM 0x00000030
  329. #define VC2_PROTOCOL (NPORT_DMODE_EASACK | 0x00800000 | 0x00040000)
  330. #define VC2_VLINET_ADDR 0x000
  331. #define VC2_VFRAMET_ADDR 0x400
  332. #define VC2_CGLYPH_ADDR 0x500
  333. /* Now the Indexed registers of the VC2. */
  334. #define VC2_IREG_VENTRY 0x00
  335. #define VC2_IREG_CENTRY 0x01
  336. #define VC2_IREG_CURSX 0x02
  337. #define VC2_IREG_CURSY 0x03
  338. #define VC2_IREG_CCURSX 0x04
  339. #define VC2_IREG_DENTRY 0x05
  340. #define VC2_IREG_SLEN 0x06
  341. #define VC2_IREG_RADDR 0x07
  342. #define VC2_IREG_VFPTR 0x08
  343. #define VC2_IREG_VLSPTR 0x09
  344. #define VC2_IREG_VLIR 0x0a
  345. #define VC2_IREG_VLCTR 0x0b
  346. #define VC2_IREG_CTPTR 0x0c
  347. #define VC2_IREG_WCURSY 0x0d
  348. #define VC2_IREG_DFPTR 0x0e
  349. #define VC2_IREG_DLTPTR 0x0f
  350. #define VC2_IREG_CONTROL 0x10
  351. #define VC2_IREG_CONFIG 0x20
  352. static inline void newport_vc2_set(struct newport_regs *regs,
  353. unsigned char vc2ireg,
  354. unsigned short val)
  355. {
  356. regs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_INDEX | NPORT_DMODE_W3 |
  357. NPORT_DMODE_ECINC | VC2_PROTOCOL);
  358. regs->set.dcbdata0.byword = (vc2ireg << 24) | (val << 8);
  359. }
  360. static inline unsigned short newport_vc2_get(struct newport_regs *regs,
  361. unsigned char vc2ireg)
  362. {
  363. regs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_INDEX | NPORT_DMODE_W1 |
  364. NPORT_DMODE_ECINC | VC2_PROTOCOL);
  365. regs->set.dcbdata0.bybytes.b3 = vc2ireg;
  366. regs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_IREG | NPORT_DMODE_W2 |
  367. NPORT_DMODE_ECINC | VC2_PROTOCOL);
  368. return regs->set.dcbdata0.byshort.s1;
  369. }
  370. /* VC2 Control register bits */
  371. #define VC2_CTRL_EVIRQ 0x0001
  372. #define VC2_CTRL_EDISP 0x0002
  373. #define VC2_CTRL_EVIDEO 0x0004
  374. #define VC2_CTRL_EDIDS 0x0008
  375. #define VC2_CTRL_ECURS 0x0010
  376. #define VC2_CTRL_EGSYNC 0x0020
  377. #define VC2_CTRL_EILACE 0x0040
  378. #define VC2_CTRL_ECDISP 0x0080
  379. #define VC2_CTRL_ECCURS 0x0100
  380. #define VC2_CTRL_ECG64 0x0200
  381. #define VC2_CTRL_GLSEL 0x0400
  382. /* Controlling the color map on NEWPORT. */
  383. #define NCMAP_REGADDR_AREG 0x00000000
  384. #define NCMAP_REGADDR_ALO 0x00000000
  385. #define NCMAP_REGADDR_AHI 0x00000010
  386. #define NCMAP_REGADDR_PBUF 0x00000020
  387. #define NCMAP_REGADDR_CREG 0x00000030
  388. #define NCMAP_REGADDR_SREG 0x00000040
  389. #define NCMAP_REGADDR_RREG 0x00000060
  390. #define NCMAP_PROTOCOL (0x00008000 | 0x00040000 | 0x00800000)
  391. static __inline__ void newport_cmap_setaddr(struct newport_regs *regs,
  392. unsigned short addr)
  393. {
  394. regs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL |
  395. NPORT_DMODE_SENDIAN | NPORT_DMODE_ECINC |
  396. NCMAP_REGADDR_AREG | NPORT_DMODE_W2);
  397. regs->set.dcbdata0.byshort.s1 = addr;
  398. regs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL |
  399. NCMAP_REGADDR_PBUF | NPORT_DMODE_W3);
  400. }
  401. static __inline__ void newport_cmap_setrgb(struct newport_regs *regs,
  402. unsigned char red,
  403. unsigned char green,
  404. unsigned char blue)
  405. {
  406. regs->set.dcbdata0.byword =
  407. (red << 24) |
  408. (green << 16) |
  409. (blue << 8);
  410. }
  411. /* Miscellaneous NEWPORT routines. */
  412. #define BUSY_TIMEOUT 100000
  413. static __inline__ int newport_wait(struct newport_regs *regs)
  414. {
  415. int t = BUSY_TIMEOUT;
  416. while (--t)
  417. if (!(regs->cset.status & NPORT_STAT_GBUSY))
  418. break;
  419. return !t;
  420. }
  421. static __inline__ int newport_bfwait(struct newport_regs *regs)
  422. {
  423. int t = BUSY_TIMEOUT;
  424. while (--t)
  425. if(!(regs->cset.status & NPORT_STAT_BBUSY))
  426. break;
  427. return !t;
  428. }
  429. /*
  430. * DCBMODE register defines:
  431. */
  432. /* Width of the data being transferred for each DCBDATA[01] word */
  433. #define DCB_DATAWIDTH_4 0x0
  434. #define DCB_DATAWIDTH_1 0x1
  435. #define DCB_DATAWIDTH_2 0x2
  436. #define DCB_DATAWIDTH_3 0x3
  437. /* If set, all of DCBDATA will be moved, otherwise only DATAWIDTH bytes */
  438. #define DCB_ENDATAPACK (1 << 2)
  439. /* Enables DCBCRS auto increment after each DCB transfer */
  440. #define DCB_ENCRSINC (1 << 3)
  441. /* shift for accessing the control register select address (DBCCRS, 3 bits) */
  442. #define DCB_CRS_SHIFT 4
  443. /* DCBADDR (4 bits): display bus slave address */
  444. #define DCB_ADDR_SHIFT 7
  445. #define DCB_VC2 (0 << DCB_ADDR_SHIFT)
  446. #define DCB_CMAP_ALL (1 << DCB_ADDR_SHIFT)
  447. #define DCB_CMAP0 (2 << DCB_ADDR_SHIFT)
  448. #define DCB_CMAP1 (3 << DCB_ADDR_SHIFT)
  449. #define DCB_XMAP_ALL (4 << DCB_ADDR_SHIFT)
  450. #define DCB_XMAP0 (5 << DCB_ADDR_SHIFT)
  451. #define DCB_XMAP1 (6 << DCB_ADDR_SHIFT)
  452. #define DCB_BT445 (7 << DCB_ADDR_SHIFT)
  453. #define DCB_VCC1 (8 << DCB_ADDR_SHIFT)
  454. #define DCB_VAB1 (9 << DCB_ADDR_SHIFT)
  455. #define DCB_LG3_BDVERS0 (10 << DCB_ADDR_SHIFT)
  456. #define DCB_LG3_ICS1562 (11 << DCB_ADDR_SHIFT)
  457. #define DCB_RESERVED (15 << DCB_ADDR_SHIFT)
  458. /* DCB protocol ack types */
  459. #define DCB_ENSYNCACK (1 << 11)
  460. #define DCB_ENASYNCACK (1 << 12)
  461. #define DCB_CSWIDTH_SHIFT 13
  462. #define DCB_CSHOLD_SHIFT 18
  463. #define DCB_CSSETUP_SHIFT 23
  464. /* XMAP9 specific defines */
  465. /* XMAP9 -- registers as seen on the DCBMODE register*/
  466. # define XM9_CRS_CONFIG (0 << DCB_CRS_SHIFT)
  467. # define XM9_PUPMODE (1 << 0)
  468. # define XM9_ODD_PIXEL (1 << 1)
  469. # define XM9_8_BITPLANES (1 << 2)
  470. # define XM9_SLOW_DCB (1 << 3)
  471. # define XM9_VIDEO_RGBMAP_MASK (3 << 4)
  472. # define XM9_EXPRESS_VIDEO (1 << 6)
  473. # define XM9_VIDEO_OPTION (1 << 7)
  474. # define XM9_CRS_REVISION (1 << DCB_CRS_SHIFT)
  475. # define XM9_CRS_FIFO_AVAIL (2 << DCB_CRS_SHIFT)
  476. # define XM9_FIFO_0_AVAIL 0
  477. # define XM9_FIFO_1_AVAIL 1
  478. # define XM9_FIFO_2_AVAIL 3
  479. # define XM9_FIFO_3_AVAIL 2
  480. # define XM9_FIFO_FULL XM9_FIFO_0_AVAIL
  481. # define XM9_FIFO_EMPTY XM9_FIFO_3_AVAIL
  482. # define XM9_CRS_CURS_CMAP_MSB (3 << DCB_CRS_SHIFT)
  483. # define XM9_CRS_PUP_CMAP_MSB (4 << DCB_CRS_SHIFT)
  484. # define XM9_CRS_MODE_REG_DATA (5 << DCB_CRS_SHIFT)
  485. # define XM9_CRS_MODE_REG_INDEX (7 << DCB_CRS_SHIFT)
  486. #define DCB_CYCLES(setup,hold,width) \
  487. ((hold << DCB_CSHOLD_SHIFT) | \
  488. (setup << DCB_CSSETUP_SHIFT)| \
  489. (width << DCB_CSWIDTH_SHIFT))
  490. #define W_DCB_XMAP9_PROTOCOL DCB_CYCLES (2, 1, 0)
  491. #define WSLOW_DCB_XMAP9_PROTOCOL DCB_CYCLES (5, 5, 0)
  492. #define WAYSLOW_DCB_XMAP9_PROTOCOL DCB_CYCLES (12, 12, 0)
  493. #define R_DCB_XMAP9_PROTOCOL DCB_CYCLES (2, 1, 3)
  494. static __inline__ void
  495. xmap9FIFOWait (struct newport_regs *rex)
  496. {
  497. rex->set.dcbmode = DCB_XMAP0 | XM9_CRS_FIFO_AVAIL |
  498. DCB_DATAWIDTH_1 | R_DCB_XMAP9_PROTOCOL;
  499. newport_bfwait (rex);
  500. while ((rex->set.dcbdata0.bybytes.b3 & 3) != XM9_FIFO_EMPTY)
  501. ;
  502. }
  503. static __inline__ void
  504. xmap9SetModeReg (struct newport_regs *rex, unsigned int modereg, unsigned int data24, int cfreq)
  505. {
  506. if (cfreq > 119)
  507. rex->set.dcbmode = DCB_XMAP_ALL | XM9_CRS_MODE_REG_DATA |
  508. DCB_DATAWIDTH_4 | W_DCB_XMAP9_PROTOCOL;
  509. else if (cfreq > 59)
  510. rex->set.dcbmode = DCB_XMAP_ALL | XM9_CRS_MODE_REG_DATA |
  511. DCB_DATAWIDTH_4 | WSLOW_DCB_XMAP9_PROTOCOL;
  512. else
  513. rex->set.dcbmode = DCB_XMAP_ALL | XM9_CRS_MODE_REG_DATA |
  514. DCB_DATAWIDTH_4 | WAYSLOW_DCB_XMAP9_PROTOCOL;
  515. rex->set.dcbdata0.byword = ((modereg) << 24) | (data24 & 0xffffff);
  516. }
  517. #define BT445_PROTOCOL DCB_CYCLES(1,1,3)
  518. #define BT445_CSR_ADDR_REG (0 << DCB_CRS_SHIFT)
  519. #define BT445_CSR_REVISION (2 << DCB_CRS_SHIFT)
  520. #define BT445_REVISION_REG 0x01
  521. #endif /* !(_SGI_NEWPORT_H) */