lxfb.h 7.6 KB

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