lxfb.h 9.2 KB

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