lxfb.h 9.0 KB

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