lxfb.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. #ifndef _LXFB_H_
  2. #define _LXFB_H_
  3. #include <linux/fb.h>
  4. #define OUTPUT_CRT 0x01
  5. #define OUTPUT_PANEL 0x02
  6. struct lxfb_par {
  7. int output;
  8. void __iomem *gp_regs;
  9. void __iomem *dc_regs;
  10. void __iomem *vp_regs;
  11. };
  12. static inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
  13. {
  14. return (((xres * (bpp >> 3)) + 7) & ~7);
  15. }
  16. void lx_set_mode(struct fb_info *);
  17. void lx_get_gamma(struct fb_info *, unsigned int *, int);
  18. void lx_set_gamma(struct fb_info *, unsigned int *, int);
  19. unsigned int lx_framebuffer_size(void);
  20. int lx_blank_display(struct fb_info *, int);
  21. void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
  22. unsigned int, unsigned int);
  23. /* MSRS */
  24. #define GLCP_DOTPLL_RESET (1 << 0)
  25. #define GLCP_DOTPLL_BYPASS (1 << 15)
  26. #define GLCP_DOTPLL_HALFPIX (1 << 24)
  27. #define GLCP_DOTPLL_LOCK (1 << 25)
  28. #define DF_CONFIG_OUTPUT_MASK 0x38
  29. #define DF_OUTPUT_PANEL 0x08
  30. #define DF_OUTPUT_CRT 0x00
  31. #define DF_SIMULTANEOUS_CRT_AND_FP (1 << 15)
  32. #define DF_DEFAULT_TFT_PAD_SEL_LOW 0xDFFFFFFF
  33. #define DF_DEFAULT_TFT_PAD_SEL_HIGH 0x0000003F
  34. #define DC_SPARE_DISABLE_CFIFO_HGO 0x00000800
  35. #define DC_SPARE_VFIFO_ARB_SELECT 0x00000400
  36. #define DC_SPARE_WM_LPEN_OVRD 0x00000200
  37. #define DC_SPARE_LOAD_WM_LPEN_MASK 0x00000100
  38. #define DC_SPARE_DISABLE_INIT_VID_PRI 0x00000080
  39. #define DC_SPARE_DISABLE_VFIFO_WM 0x00000040
  40. #define DC_SPARE_DISABLE_CWD_CHECK 0x00000020
  41. #define DC_SPARE_PIX8_PAN_FIX 0x00000010
  42. #define DC_SPARE_FIRST_REQ_MASK 0x00000002
  43. /* Graphics Processor registers (table 6-29 from the data book) */
  44. enum gp_registers {
  45. GP_DST_OFFSET = 0,
  46. GP_SRC_OFFSET,
  47. GP_STRIDE,
  48. GP_WID_HEIGHT,
  49. GP_SRC_COLOR_FG,
  50. GP_SRC_COLOR_BG,
  51. GP_PAT_COLOR_0,
  52. GP_PAT_COLOR_1,
  53. GP_PAT_COLOR_2,
  54. GP_PAT_COLOR_3,
  55. GP_PAT_COLOR_4,
  56. GP_PAT_COLOR_5,
  57. GP_PAT_DATA_0,
  58. GP_PAT_DATA_1,
  59. GP_RASTER_MODE,
  60. GP_VECTOR_MODE,
  61. GP_BLT_MODE,
  62. GP_BLT_STATUS,
  63. GP_HST_SRC,
  64. GP_BASE_OFFSET,
  65. GP_CMD_TOP,
  66. GP_CMD_BOT,
  67. GP_CMD_READ,
  68. GP_CMD_WRITE,
  69. GP_CH3_OFFSET,
  70. GP_CH3_MODE_STR,
  71. GP_CH3_WIDHI,
  72. GP_CH3_HSRC,
  73. GP_LUT_INDEX,
  74. GP_LUT_DATA,
  75. GP_INT_CNTRL, /* 0x78 */
  76. };
  77. #define GP_BLT_STATUS_CE (1 << 4) /* cmd buf empty */
  78. #define GP_BLT_STATUS_PB (1 << 0) /* primative busy */
  79. /* Display Controller registers (table 6-47 from the data book) */
  80. enum dc_registers {
  81. DC_UNLOCK = 0,
  82. DC_GENERAL_CFG,
  83. DC_DISPLAY_CFG,
  84. DC_ARB_CFG,
  85. DC_FB_ST_OFFSET,
  86. DC_CB_ST_OFFSET,
  87. DC_CURS_ST_OFFSET,
  88. DC_RSVD_0,
  89. DC_VID_Y_ST_OFFSET,
  90. DC_VID_U_ST_OFFSET,
  91. DC_VID_V_ST_OFFSET,
  92. DC_DV_TOP,
  93. DC_LINE_SIZE,
  94. DC_GFX_PITCH,
  95. DC_VID_YUV_PITCH,
  96. DC_RSVD_1,
  97. DC_H_ACTIVE_TIMING,
  98. DC_H_BLANK_TIMING,
  99. DC_H_SYNC_TIMING,
  100. DC_RSVD_2,
  101. DC_V_ACTIVE_TIMING,
  102. DC_V_BLANK_TIMING,
  103. DC_V_SYNC_TIMING,
  104. DC_FB_ACTIVE,
  105. DC_CURSOR_X,
  106. DC_CURSOR_Y,
  107. DC_RSVD_3,
  108. DC_LINE_CNT,
  109. DC_PAL_ADDRESS,
  110. DC_PAL_DATA,
  111. DC_DFIFO_DIAG,
  112. DC_CFIFO_DIAG,
  113. DC_VID_DS_DELTA,
  114. DC_GLIU0_MEM_OFFSET,
  115. DC_DV_CTL,
  116. DC_DV_ACCESS,
  117. DC_GFX_SCALE,
  118. DC_IRQ_FILT_CTL,
  119. DC_FILT_COEFF1,
  120. DC_FILT_COEFF2,
  121. DC_VBI_EVEN_CTL,
  122. DC_VBI_ODD_CTL,
  123. DC_VBI_HOR,
  124. DC_VBI_LN_ODD,
  125. DC_VBI_LN_EVEN,
  126. DC_VBI_PITCH,
  127. DC_CLR_KEY,
  128. DC_CLR_KEY_MASK,
  129. DC_CLR_KEY_X,
  130. DC_CLR_KEY_Y,
  131. DC_IRQ,
  132. DC_RSVD_4,
  133. DC_RSVD_5,
  134. DC_GENLK_CTL,
  135. DC_VID_EVEN_Y_ST_OFFSET,
  136. DC_VID_EVEN_U_ST_OFFSET,
  137. DC_VID_EVEN_V_ST_OFFSET,
  138. DC_V_ACTIVE_EVEN_TIMING,
  139. DC_V_BLANK_EVEN_TIMING,
  140. DC_V_SYNC_EVEN_TIMING, /* 0xec */
  141. };
  142. #define DC_UNLOCK_LOCK 0x00000000
  143. #define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
  144. #define DC_GENERAL_CFG_FDTY (1 << 17)
  145. #define DC_GENERAL_CFG_DFHPEL_SHIFT (12)
  146. #define DC_GENERAL_CFG_DFHPSL_SHIFT (8)
  147. #define DC_GENERAL_CFG_VGAE (1 << 7)
  148. #define DC_GENERAL_CFG_DECE (1 << 6)
  149. #define DC_GENERAL_CFG_CMPE (1 << 5)
  150. #define DC_GENERAL_CFG_VIDE (1 << 3)
  151. #define DC_GENERAL_CFG_DFLE (1 << 0)
  152. #define DC_DISPLAY_CFG_VISL (1 << 27)
  153. #define DC_DISPLAY_CFG_PALB (1 << 25)
  154. #define DC_DISPLAY_CFG_DCEN (1 << 24)
  155. #define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
  156. #define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
  157. #define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
  158. #define DC_DISPLAY_CFG_TRUP (1 << 6)
  159. #define DC_DISPLAY_CFG_VDEN (1 << 4)
  160. #define DC_DISPLAY_CFG_GDEN (1 << 3)
  161. #define DC_DISPLAY_CFG_TGEN (1 << 0)
  162. #define DC_DV_TOP_DV_TOP_EN (1 << 0)
  163. #define DC_DV_CTL_DV_LINE_SIZE ((1 << 10) | (1 << 11))
  164. #define DC_DV_CTL_DV_LINE_SIZE_1K (0)
  165. #define DC_DV_CTL_DV_LINE_SIZE_2K (1 << 10)
  166. #define DC_DV_CTL_DV_LINE_SIZE_4K (1 << 11)
  167. #define DC_DV_CTL_DV_LINE_SIZE_8K ((1 << 10) | (1 << 11))
  168. #define DC_CLR_KEY_CLR_KEY_EN (1 << 24)
  169. #define DC_IRQ_VIP_VSYNC_IRQ_STATUS (1 << 21) /* undocumented? */
  170. #define DC_IRQ_STATUS (1 << 20) /* undocumented? */
  171. #define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK (1 << 1)
  172. #define DC_IRQ_MASK (1 << 0)
  173. #define DC_GENLK_CTL_FLICK_SEL_MASK (0x0F << 28)
  174. #define DC_GENLK_CTL_ALPHA_FLICK_EN (1 << 25)
  175. #define DC_GENLK_CTL_FLICK_EN (1 << 24)
  176. #define DC_GENLK_CTL_GENLK_EN (1 << 18)
  177. /*
  178. * Video Processor registers (table 6-71).
  179. * There is space for 64 bit values, but we never use more than the
  180. * lower 32 bits. The actual register save/restore code only bothers
  181. * to restore those 32 bits.
  182. */
  183. enum vp_registers {
  184. VP_VCFG = 0,
  185. VP_DCFG,
  186. VP_VX,
  187. VP_VY,
  188. VP_SCL,
  189. VP_VCK,
  190. VP_VCM,
  191. VP_PAR,
  192. VP_PDR,
  193. VP_SLR,
  194. VP_MISC,
  195. VP_CCS,
  196. VP_VYS,
  197. VP_VXS,
  198. VP_RSVD_0,
  199. VP_VDC,
  200. VP_RSVD_1,
  201. VP_CRC,
  202. VP_CRC32,
  203. VP_VDE,
  204. VP_CCK,
  205. VP_CCM,
  206. VP_CC1,
  207. VP_CC2,
  208. VP_A1X,
  209. VP_A1Y,
  210. VP_A1C,
  211. VP_A1T,
  212. VP_A2X,
  213. VP_A2Y,
  214. VP_A2C,
  215. VP_A2T,
  216. VP_A3X,
  217. VP_A3Y,
  218. VP_A3C,
  219. VP_A3T,
  220. VP_VRR,
  221. VP_AWT,
  222. VP_VTM,
  223. VP_VYE,
  224. VP_A1YE,
  225. VP_A2YE,
  226. VP_A3YE, /* 0x150 */
  227. };
  228. #define VP_VCFG_VID_EN (1 << 0)
  229. #define VP_DCFG_GV_GAM (1 << 21)
  230. #define VP_DCFG_PWR_SEQ_DELAY ((1 << 17) | (1 << 18) | (1 << 19))
  231. #define VP_DCFG_PWR_SEQ_DELAY_DEFAULT (1 << 19) /* undocumented */
  232. #define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
  233. #define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
  234. #define VP_DCFG_CRT_VSYNC_POL (1 << 9)
  235. #define VP_DCFG_CRT_HSYNC_POL (1 << 8)
  236. #define VP_DCFG_DAC_BL_EN (1 << 3)
  237. #define VP_DCFG_VSYNC_EN (1 << 2)
  238. #define VP_DCFG_HSYNC_EN (1 << 1)
  239. #define VP_DCFG_CRT_EN (1 << 0)
  240. #define VP_MISC_APWRDN (1 << 11)
  241. #define VP_MISC_DACPWRDN (1 << 10)
  242. #define VP_MISC_BYP_BOTH (1 << 0)
  243. /*
  244. * Flat Panel registers (table 6-71).
  245. * Also 64 bit registers; see above note about 32-bit handling.
  246. */
  247. /* we're actually in the VP register space, starting at address 0x400 */
  248. #define VP_FP_START 0x400
  249. enum fp_registers {
  250. FP_PT1 = 0,
  251. FP_PT2,
  252. FP_PM,
  253. FP_DFC,
  254. FP_RSVD_0,
  255. FP_RSVD_1,
  256. FP_RSVD_2,
  257. FP_RSVD_3,
  258. FP_RSVD_4,
  259. FP_DCA,
  260. FP_DMD,
  261. FP_CRC, /* 0x458 */
  262. };
  263. #define FP_PT2_SCRC (1 << 27) /* shfclk free */
  264. #define FP_PM_P (1 << 24) /* panel power ctl */
  265. #define FP_DFC_BC ((1 << 4) | (1 << 5) | (1 << 6))
  266. /* register access functions */
  267. static inline uint32_t read_gp(struct lxfb_par *par, int reg)
  268. {
  269. return readl(par->gp_regs + 4*reg);
  270. }
  271. static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
  272. {
  273. writel(val, par->gp_regs + 4*reg);
  274. }
  275. static inline uint32_t read_dc(struct lxfb_par *par, int reg)
  276. {
  277. return readl(par->dc_regs + 4*reg);
  278. }
  279. static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
  280. {
  281. writel(val, par->dc_regs + 4*reg);
  282. }
  283. static inline uint32_t read_vp(struct lxfb_par *par, int reg)
  284. {
  285. return readl(par->vp_regs + 8*reg);
  286. }
  287. static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
  288. {
  289. writel(val, par->vp_regs + 8*reg);
  290. }
  291. static inline uint32_t read_fp(struct lxfb_par *par, int reg)
  292. {
  293. return readl(par->vp_regs + 8*reg + VP_FP_START);
  294. }
  295. static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
  296. {
  297. writel(val, par->vp_regs + 8*reg + VP_FP_START);
  298. }
  299. #endif