lxfb.h 8.8 KB

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