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