lxfb.h 9.1 KB

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