vermilion.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * Copyright (c) Intel Corp. 2007.
  3. * All Rights Reserved.
  4. *
  5. * Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
  6. * develop this driver.
  7. *
  8. * This file is part of the Vermilion Range fb driver.
  9. * The Vermilion Range fb driver is free software;
  10. * you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * The Vermilion Range fb driver is distributed
  16. * in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this driver; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Authors:
  26. * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
  27. */
  28. #ifndef _VERMILION_H_
  29. #define _VERMILION_H_
  30. #include <linux/kernel.h>
  31. #include <linux/pci.h>
  32. #include <linux/atomic.h>
  33. #include <linux/mutex.h>
  34. #define VML_DEVICE_GPU 0x5002
  35. #define VML_DEVICE_VDC 0x5009
  36. #define VML_VRAM_AREAS 3
  37. #define VML_MAX_XRES 1024
  38. #define VML_MAX_YRES 768
  39. #define VML_MAX_XRES_VIRTUAL 1040
  40. /*
  41. * Display controller registers:
  42. */
  43. /* Display controller 10-bit color representation */
  44. #define VML_R_MASK 0x3FF00000
  45. #define VML_R_SHIFT 20
  46. #define VML_G_MASK 0x000FFC00
  47. #define VML_G_SHIFT 10
  48. #define VML_B_MASK 0x000003FF
  49. #define VML_B_SHIFT 0
  50. /* Graphics plane control */
  51. #define VML_DSPCCNTR 0x00072180
  52. #define VML_GFX_ENABLE 0x80000000
  53. #define VML_GFX_GAMMABYPASS 0x40000000
  54. #define VML_GFX_ARGB1555 0x0C000000
  55. #define VML_GFX_RGB0888 0x18000000
  56. #define VML_GFX_ARGB8888 0x1C000000
  57. #define VML_GFX_ALPHACONST 0x02000000
  58. #define VML_GFX_ALPHAMULT 0x01000000
  59. #define VML_GFX_CONST_ALPHA 0x000000FF
  60. /* Graphics plane start address. Pixel aligned. */
  61. #define VML_DSPCADDR 0x00072184
  62. /* Graphics plane stride register. */
  63. #define VML_DSPCSTRIDE 0x00072188
  64. /* Graphics plane position register. */
  65. #define VML_DSPCPOS 0x0007218C
  66. #define VML_POS_YMASK 0x0FFF0000
  67. #define VML_POS_YSHIFT 16
  68. #define VML_POS_XMASK 0x00000FFF
  69. #define VML_POS_XSHIFT 0
  70. /* Graphics plane height and width */
  71. #define VML_DSPCSIZE 0x00072190
  72. #define VML_SIZE_HMASK 0x0FFF0000
  73. #define VML_SIZE_HSHIFT 16
  74. #define VML_SISE_WMASK 0x00000FFF
  75. #define VML_SIZE_WSHIFT 0
  76. /* Graphics plane gamma correction lookup table registers (129 * 32 bits) */
  77. #define VML_DSPCGAMLUT 0x00072200
  78. /* Pixel video output configuration register */
  79. #define VML_PVOCONFIG 0x00061140
  80. #define VML_CONFIG_BASE 0x80000000
  81. #define VML_CONFIG_PIXEL_SWAP 0x04000000
  82. #define VML_CONFIG_DE_INV 0x01000000
  83. #define VML_CONFIG_HREF_INV 0x00400000
  84. #define VML_CONFIG_VREF_INV 0x00100000
  85. #define VML_CONFIG_CLK_INV 0x00040000
  86. #define VML_CONFIG_CLK_DIV2 0x00010000
  87. #define VML_CONFIG_ESTRB_INV 0x00008000
  88. /* Pipe A Horizontal total register */
  89. #define VML_HTOTAL_A 0x00060000
  90. #define VML_HTOTAL_MASK 0x1FFF0000
  91. #define VML_HTOTAL_SHIFT 16
  92. #define VML_HTOTAL_VAL 8192
  93. #define VML_HACTIVE_MASK 0x000007FF
  94. #define VML_HACTIVE_SHIFT 0
  95. #define VML_HACTIVE_VAL 4096
  96. /* Pipe A Horizontal Blank register */
  97. #define VML_HBLANK_A 0x00060004
  98. #define VML_HBLANK_END_MASK 0x1FFF0000
  99. #define VML_HBLANK_END_SHIFT 16
  100. #define VML_HBLANK_END_VAL 8192
  101. #define VML_HBLANK_START_MASK 0x00001FFF
  102. #define VML_HBLANK_START_SHIFT 0
  103. #define VML_HBLANK_START_VAL 8192
  104. /* Pipe A Horizontal Sync register */
  105. #define VML_HSYNC_A 0x00060008
  106. #define VML_HSYNC_END_MASK 0x1FFF0000
  107. #define VML_HSYNC_END_SHIFT 16
  108. #define VML_HSYNC_END_VAL 8192
  109. #define VML_HSYNC_START_MASK 0x00001FFF
  110. #define VML_HSYNC_START_SHIFT 0
  111. #define VML_HSYNC_START_VAL 8192
  112. /* Pipe A Vertical total register */
  113. #define VML_VTOTAL_A 0x0006000C
  114. #define VML_VTOTAL_MASK 0x1FFF0000
  115. #define VML_VTOTAL_SHIFT 16
  116. #define VML_VTOTAL_VAL 8192
  117. #define VML_VACTIVE_MASK 0x000007FF
  118. #define VML_VACTIVE_SHIFT 0
  119. #define VML_VACTIVE_VAL 4096
  120. /* Pipe A Vertical Blank register */
  121. #define VML_VBLANK_A 0x00060010
  122. #define VML_VBLANK_END_MASK 0x1FFF0000
  123. #define VML_VBLANK_END_SHIFT 16
  124. #define VML_VBLANK_END_VAL 8192
  125. #define VML_VBLANK_START_MASK 0x00001FFF
  126. #define VML_VBLANK_START_SHIFT 0
  127. #define VML_VBLANK_START_VAL 8192
  128. /* Pipe A Vertical Sync register */
  129. #define VML_VSYNC_A 0x00060014
  130. #define VML_VSYNC_END_MASK 0x1FFF0000
  131. #define VML_VSYNC_END_SHIFT 16
  132. #define VML_VSYNC_END_VAL 8192
  133. #define VML_VSYNC_START_MASK 0x00001FFF
  134. #define VML_VSYNC_START_SHIFT 0
  135. #define VML_VSYNC_START_VAL 8192
  136. /* Pipe A Source Image size (minus one - equal to active size)
  137. * Programmable while pipe is enabled.
  138. */
  139. #define VML_PIPEASRC 0x0006001C
  140. #define VML_PIPEASRC_HMASK 0x0FFF0000
  141. #define VML_PIPEASRC_HSHIFT 16
  142. #define VML_PIPEASRC_VMASK 0x00000FFF
  143. #define VML_PIPEASRC_VSHIFT 0
  144. /* Pipe A Border Color Pattern register (10 bit color) */
  145. #define VML_BCLRPAT_A 0x00060020
  146. /* Pipe A Canvas Color register (10 bit color) */
  147. #define VML_CANVSCLR_A 0x00060024
  148. /* Pipe A Configuration register */
  149. #define VML_PIPEACONF 0x00070008
  150. #define VML_PIPE_BASE 0x00000000
  151. #define VML_PIPE_ENABLE 0x80000000
  152. #define VML_PIPE_FORCE_BORDER 0x02000000
  153. #define VML_PIPE_PLANES_OFF 0x00080000
  154. #define VML_PIPE_ARGB_OUTPUT_MODE 0x00040000
  155. /* Pipe A FIFO setting */
  156. #define VML_DSPARB 0x00070030
  157. #define VML_FIFO_DEFAULT 0x00001D9C
  158. /* MDVO rcomp status & pads control register */
  159. #define VML_RCOMPSTAT 0x00070048
  160. #define VML_MDVO_VDC_I_RCOMP 0x80000000
  161. #define VML_MDVO_POWERSAVE_OFF 0x00000008
  162. #define VML_MDVO_PAD_ENABLE 0x00000004
  163. #define VML_MDVO_PULLDOWN_ENABLE 0x00000001
  164. struct vml_par {
  165. struct pci_dev *vdc;
  166. u64 vdc_mem_base;
  167. u64 vdc_mem_size;
  168. char __iomem *vdc_mem;
  169. struct pci_dev *gpu;
  170. u64 gpu_mem_base;
  171. u64 gpu_mem_size;
  172. char __iomem *gpu_mem;
  173. atomic_t refcount;
  174. };
  175. struct vram_area {
  176. unsigned long logical;
  177. unsigned long phys;
  178. unsigned long size;
  179. unsigned order;
  180. };
  181. struct vml_info {
  182. struct fb_info info;
  183. struct vml_par *par;
  184. struct list_head head;
  185. struct vram_area vram[VML_VRAM_AREAS];
  186. u64 vram_start;
  187. u64 vram_contig_size;
  188. u32 num_areas;
  189. void __iomem *vram_logical;
  190. u32 pseudo_palette[16];
  191. u32 stride;
  192. u32 bytes_per_pixel;
  193. atomic_t vmas;
  194. int cur_blank_mode;
  195. int pipe_disabled;
  196. };
  197. /*
  198. * Subsystem
  199. */
  200. struct vml_sys {
  201. char *name;
  202. /*
  203. * Save / Restore;
  204. */
  205. int (*save) (struct vml_sys * sys);
  206. int (*restore) (struct vml_sys * sys);
  207. /*
  208. * PLL programming;
  209. */
  210. int (*set_clock) (struct vml_sys * sys, int clock);
  211. int (*nearest_clock) (const struct vml_sys * sys, int clock);
  212. };
  213. extern int vmlfb_register_subsys(struct vml_sys *sys);
  214. extern void vmlfb_unregister_subsys(struct vml_sys *sys);
  215. #define VML_READ32(_par, _offset) \
  216. (ioread32((_par)->vdc_mem + (_offset)))
  217. #define VML_WRITE32(_par, _offset, _value) \
  218. iowrite32(_value, (_par)->vdc_mem + (_offset))
  219. #endif