tgafb.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * linux/drivers/video/tgafb.h -- DEC 21030 TGA frame buffer device
  3. *
  4. * Copyright (C) 1999,2000 Martin Lucina, Tom Zerucha
  5. *
  6. * $Id: tgafb.h,v 1.4.2.3 2000/04/04 06:44:56 mato Exp $
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file COPYING in the main directory of this archive for
  10. * more details.
  11. */
  12. #ifndef TGAFB_H
  13. #define TGAFB_H
  14. /*
  15. * TGA hardware description (minimal)
  16. */
  17. #define TGA_TYPE_8PLANE 0
  18. #define TGA_TYPE_24PLANE 1
  19. #define TGA_TYPE_24PLUSZ 3
  20. /*
  21. * Offsets within Memory Space
  22. */
  23. #define TGA_ROM_OFFSET 0x0000000
  24. #define TGA_REGS_OFFSET 0x0100000
  25. #define TGA_8PLANE_FB_OFFSET 0x0200000
  26. #define TGA_24PLANE_FB_OFFSET 0x0804000
  27. #define TGA_24PLUSZ_FB_OFFSET 0x1004000
  28. #define TGA_FOREGROUND_REG 0x0020
  29. #define TGA_BACKGROUND_REG 0x0024
  30. #define TGA_PLANEMASK_REG 0x0028
  31. #define TGA_PIXELMASK_ONESHOT_REG 0x002c
  32. #define TGA_MODE_REG 0x0030
  33. #define TGA_RASTEROP_REG 0x0034
  34. #define TGA_PIXELSHIFT_REG 0x0038
  35. #define TGA_DEEP_REG 0x0050
  36. #define TGA_START_REG 0x0054
  37. #define TGA_PIXELMASK_REG 0x005c
  38. #define TGA_CURSOR_BASE_REG 0x0060
  39. #define TGA_HORIZ_REG 0x0064
  40. #define TGA_VERT_REG 0x0068
  41. #define TGA_BASE_ADDR_REG 0x006c
  42. #define TGA_VALID_REG 0x0070
  43. #define TGA_CURSOR_XY_REG 0x0074
  44. #define TGA_INTR_STAT_REG 0x007c
  45. #define TGA_DATA_REG 0x0080
  46. #define TGA_RAMDAC_SETUP_REG 0x00c0
  47. #define TGA_BLOCK_COLOR0_REG 0x0140
  48. #define TGA_BLOCK_COLOR1_REG 0x0144
  49. #define TGA_BLOCK_COLOR2_REG 0x0148
  50. #define TGA_BLOCK_COLOR3_REG 0x014c
  51. #define TGA_BLOCK_COLOR4_REG 0x0150
  52. #define TGA_BLOCK_COLOR5_REG 0x0154
  53. #define TGA_BLOCK_COLOR6_REG 0x0158
  54. #define TGA_BLOCK_COLOR7_REG 0x015c
  55. #define TGA_COPY64_SRC 0x0160
  56. #define TGA_COPY64_DST 0x0164
  57. #define TGA_CLOCK_REG 0x01e8
  58. #define TGA_RAMDAC_REG 0x01f0
  59. #define TGA_CMD_STAT_REG 0x01f8
  60. /*
  61. * Useful defines for managing the registers
  62. */
  63. #define TGA_HORIZ_ODD 0x80000000
  64. #define TGA_HORIZ_POLARITY 0x40000000
  65. #define TGA_HORIZ_ACT_MSB 0x30000000
  66. #define TGA_HORIZ_BP 0x0fe00000
  67. #define TGA_HORIZ_SYNC 0x001fc000
  68. #define TGA_HORIZ_FP 0x00007c00
  69. #define TGA_HORIZ_ACT_LSB 0x000001ff
  70. #define TGA_VERT_SE 0x80000000
  71. #define TGA_VERT_POLARITY 0x40000000
  72. #define TGA_VERT_RESERVED 0x30000000
  73. #define TGA_VERT_BP 0x0fc00000
  74. #define TGA_VERT_SYNC 0x003f0000
  75. #define TGA_VERT_FP 0x0000f800
  76. #define TGA_VERT_ACTIVE 0x000007ff
  77. #define TGA_VALID_VIDEO 0x01
  78. #define TGA_VALID_BLANK 0x02
  79. #define TGA_VALID_CURSOR 0x04
  80. #define TGA_MODE_SBM_8BPP 0x000
  81. #define TGA_MODE_SBM_24BPP 0x300
  82. #define TGA_MODE_SIMPLE 0x00
  83. #define TGA_MODE_SIMPLEZ 0x10
  84. #define TGA_MODE_OPAQUE_STIPPLE 0x01
  85. #define TGA_MODE_OPAQUE_FILL 0x21
  86. #define TGA_MODE_TRANSPARENT_STIPPLE 0x03
  87. #define TGA_MODE_TRANSPARENT_FILL 0x23
  88. #define TGA_MODE_BLOCK_STIPPLE 0x0d
  89. #define TGA_MODE_BLOCK_FILL 0x2d
  90. #define TGA_MODE_COPY 0x07
  91. #define TGA_MODE_DMA_READ_COPY_ND 0x17
  92. #define TGA_MODE_DMA_READ_COPY_D 0x37
  93. #define TGA_MODE_DMA_WRITE_COPY 0x1f
  94. /*
  95. * Useful defines for managing the ICS1562 PLL clock
  96. */
  97. #define TGA_PLL_BASE_FREQ 14318 /* .18 */
  98. #define TGA_PLL_MAX_FREQ 230000
  99. /*
  100. * Useful defines for managing the BT485 on the 8-plane TGA
  101. */
  102. #define BT485_READ_BIT 0x01
  103. #define BT485_WRITE_BIT 0x00
  104. #define BT485_ADDR_PAL_WRITE 0x00
  105. #define BT485_DATA_PAL 0x02
  106. #define BT485_PIXEL_MASK 0x04
  107. #define BT485_ADDR_PAL_READ 0x06
  108. #define BT485_ADDR_CUR_WRITE 0x08
  109. #define BT485_DATA_CUR 0x0a
  110. #define BT485_CMD_0 0x0c
  111. #define BT485_ADDR_CUR_READ 0x0e
  112. #define BT485_CMD_1 0x10
  113. #define BT485_CMD_2 0x12
  114. #define BT485_STATUS 0x14
  115. #define BT485_CMD_3 0x14
  116. #define BT485_CUR_RAM 0x16
  117. #define BT485_CUR_LOW_X 0x18
  118. #define BT485_CUR_HIGH_X 0x1a
  119. #define BT485_CUR_LOW_Y 0x1c
  120. #define BT485_CUR_HIGH_Y 0x1e
  121. /*
  122. * Useful defines for managing the BT463 on the 24-plane TGAs/SFB+s
  123. */
  124. #define BT463_ADDR_LO 0x0
  125. #define BT463_ADDR_HI 0x1
  126. #define BT463_REG_ACC 0x2
  127. #define BT463_PALETTE 0x3
  128. #define BT463_CUR_CLR_0 0x0100
  129. #define BT463_CUR_CLR_1 0x0101
  130. #define BT463_CMD_REG_0 0x0201
  131. #define BT463_CMD_REG_1 0x0202
  132. #define BT463_CMD_REG_2 0x0203
  133. #define BT463_READ_MASK_0 0x0205
  134. #define BT463_READ_MASK_1 0x0206
  135. #define BT463_READ_MASK_2 0x0207
  136. #define BT463_READ_MASK_3 0x0208
  137. #define BT463_BLINK_MASK_0 0x0209
  138. #define BT463_BLINK_MASK_1 0x020a
  139. #define BT463_BLINK_MASK_2 0x020b
  140. #define BT463_BLINK_MASK_3 0x020c
  141. #define BT463_WINDOW_TYPE_BASE 0x0300
  142. /*
  143. * Useful defines for managing the BT459 on the 8-plane SFB+s
  144. */
  145. #define BT459_ADDR_LO 0x0
  146. #define BT459_ADDR_HI 0x1
  147. #define BT459_REG_ACC 0x2
  148. #define BT459_PALETTE 0x3
  149. #define BT459_CUR_CLR_1 0x0181
  150. #define BT459_CUR_CLR_2 0x0182
  151. #define BT459_CUR_CLR_3 0x0183
  152. #define BT459_CMD_REG_0 0x0201
  153. #define BT459_CMD_REG_1 0x0202
  154. #define BT459_CMD_REG_2 0x0203
  155. #define BT459_READ_MASK 0x0204
  156. #define BT459_BLINK_MASK 0x0206
  157. #define BT459_CUR_CMD_REG 0x0300
  158. /*
  159. * The framebuffer driver private data.
  160. */
  161. struct tga_par {
  162. /* PCI/TC device. */
  163. struct device *dev;
  164. /* Device dependent information. */
  165. void __iomem *tga_mem_base;
  166. void __iomem *tga_fb_base;
  167. void __iomem *tga_regs_base;
  168. u8 tga_type; /* TGA_TYPE_XXX */
  169. u8 tga_chip_rev; /* dc21030 revision */
  170. /* Remember blank mode. */
  171. u8 vesa_blanked;
  172. /* Define the video mode. */
  173. u32 xres, yres; /* resolution in pixels */
  174. u32 htimings; /* horizontal timing register */
  175. u32 vtimings; /* vertical timing register */
  176. u32 pll_freq; /* pixclock in mhz */
  177. u32 bits_per_pixel; /* bits per pixel */
  178. u32 sync_on_green; /* set if sync is on green */
  179. u32 palette[16];
  180. };
  181. /*
  182. * Macros for reading/writing TGA and RAMDAC registers
  183. */
  184. static inline void
  185. TGA_WRITE_REG(struct tga_par *par, u32 v, u32 r)
  186. {
  187. writel(v, par->tga_regs_base +r);
  188. }
  189. static inline u32
  190. TGA_READ_REG(struct tga_par *par, u32 r)
  191. {
  192. return readl(par->tga_regs_base +r);
  193. }
  194. static inline void
  195. BT485_WRITE(struct tga_par *par, u8 v, u8 r)
  196. {
  197. TGA_WRITE_REG(par, r, TGA_RAMDAC_SETUP_REG);
  198. TGA_WRITE_REG(par, v | (r << 8), TGA_RAMDAC_REG);
  199. }
  200. static inline void
  201. BT463_LOAD_ADDR(struct tga_par *par, u16 a)
  202. {
  203. TGA_WRITE_REG(par, BT463_ADDR_LO<<2, TGA_RAMDAC_SETUP_REG);
  204. TGA_WRITE_REG(par, (BT463_ADDR_LO<<10) | (a & 0xff), TGA_RAMDAC_REG);
  205. TGA_WRITE_REG(par, BT463_ADDR_HI<<2, TGA_RAMDAC_SETUP_REG);
  206. TGA_WRITE_REG(par, (BT463_ADDR_HI<<10) | (a >> 8), TGA_RAMDAC_REG);
  207. }
  208. static inline void
  209. BT463_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
  210. {
  211. BT463_LOAD_ADDR(par, a);
  212. TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
  213. TGA_WRITE_REG(par, m << 10 | v, TGA_RAMDAC_REG);
  214. }
  215. static inline void
  216. BT459_LOAD_ADDR(struct tga_par *par, u16 a)
  217. {
  218. TGA_WRITE_REG(par, BT459_ADDR_LO << 2, TGA_RAMDAC_SETUP_REG);
  219. TGA_WRITE_REG(par, a & 0xff, TGA_RAMDAC_REG);
  220. TGA_WRITE_REG(par, BT459_ADDR_HI << 2, TGA_RAMDAC_SETUP_REG);
  221. TGA_WRITE_REG(par, a >> 8, TGA_RAMDAC_REG);
  222. }
  223. static inline void
  224. BT459_WRITE(struct tga_par *par, u32 m, u16 a, u8 v)
  225. {
  226. BT459_LOAD_ADDR(par, a);
  227. TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
  228. TGA_WRITE_REG(par, v, TGA_RAMDAC_REG);
  229. }
  230. #endif /* TGAFB_H */