gxfb.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2008 Andres Salomon <dilinger@debian.org>
  4. *
  5. * Geode GX2 header information
  6. */
  7. #ifndef _GXFB_H_
  8. #define _GXFB_H_
  9. #include <linux/io.h>
  10. #define GP_REG_COUNT (0x50 / 4)
  11. #define DC_REG_COUNT (0x90 / 4)
  12. #define VP_REG_COUNT (0x138 / 8)
  13. #define FP_REG_COUNT (0x68 / 8)
  14. #define DC_PAL_COUNT 0x104
  15. struct gxfb_par {
  16. int enable_crt;
  17. void __iomem *dc_regs;
  18. void __iomem *vid_regs;
  19. void __iomem *gp_regs;
  20. int powered_down;
  21. /* register state, for power management functionality */
  22. struct {
  23. uint64_t padsel;
  24. uint64_t dotpll;
  25. } msr;
  26. uint32_t gp[GP_REG_COUNT];
  27. uint32_t dc[DC_REG_COUNT];
  28. uint64_t vp[VP_REG_COUNT];
  29. uint64_t fp[FP_REG_COUNT];
  30. uint32_t pal[DC_PAL_COUNT];
  31. };
  32. unsigned int gx_frame_buffer_size(void);
  33. int gx_line_delta(int xres, int bpp);
  34. void gx_set_mode(struct fb_info *info);
  35. void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
  36. unsigned red, unsigned green, unsigned blue);
  37. void gx_set_dclk_frequency(struct fb_info *info);
  38. void gx_configure_display(struct fb_info *info);
  39. int gx_blank_display(struct fb_info *info, int blank_mode);
  40. int gx_powerdown(struct fb_info *info);
  41. int gx_powerup(struct fb_info *info);
  42. /* Graphics Processor registers (table 6-23 from the data book) */
  43. enum gp_registers {
  44. GP_DST_OFFSET = 0,
  45. GP_SRC_OFFSET,
  46. GP_STRIDE,
  47. GP_WID_HEIGHT,
  48. GP_SRC_COLOR_FG,
  49. GP_SRC_COLOR_BG,
  50. GP_PAT_COLOR_0,
  51. GP_PAT_COLOR_1,
  52. GP_PAT_COLOR_2,
  53. GP_PAT_COLOR_3,
  54. GP_PAT_COLOR_4,
  55. GP_PAT_COLOR_5,
  56. GP_PAT_DATA_0,
  57. GP_PAT_DATA_1,
  58. GP_RASTER_MODE,
  59. GP_VECTOR_MODE,
  60. GP_BLT_MODE,
  61. GP_BLT_STATUS,
  62. GP_HST_SRC,
  63. GP_BASE_OFFSET, /* 0x4c */
  64. };
  65. #define GP_BLT_STATUS_BLT_PENDING (1 << 2)
  66. #define GP_BLT_STATUS_BLT_BUSY (1 << 0)
  67. /* Display Controller registers (table 6-38 from the data book) */
  68. enum dc_registers {
  69. DC_UNLOCK = 0,
  70. DC_GENERAL_CFG,
  71. DC_DISPLAY_CFG,
  72. DC_RSVD_0,
  73. DC_FB_ST_OFFSET,
  74. DC_CB_ST_OFFSET,
  75. DC_CURS_ST_OFFSET,
  76. DC_ICON_ST_OFFSET,
  77. DC_VID_Y_ST_OFFSET,
  78. DC_VID_U_ST_OFFSET,
  79. DC_VID_V_ST_OFFSET,
  80. DC_RSVD_1,
  81. DC_LINE_SIZE,
  82. DC_GFX_PITCH,
  83. DC_VID_YUV_PITCH,
  84. DC_RSVD_2,
  85. DC_H_ACTIVE_TIMING,
  86. DC_H_BLANK_TIMING,
  87. DC_H_SYNC_TIMING,
  88. DC_RSVD_3,
  89. DC_V_ACTIVE_TIMING,
  90. DC_V_BLANK_TIMING,
  91. DC_V_SYNC_TIMING,
  92. DC_RSVD_4,
  93. DC_CURSOR_X,
  94. DC_CURSOR_Y,
  95. DC_ICON_X,
  96. DC_LINE_CNT,
  97. DC_PAL_ADDRESS,
  98. DC_PAL_DATA,
  99. DC_DFIFO_DIAG,
  100. DC_CFIFO_DIAG,
  101. DC_VID_DS_DELTA,
  102. DC_GLIU0_MEM_OFFSET,
  103. DC_RSVD_5,
  104. DC_DV_ACC, /* 0x8c */
  105. };
  106. #define DC_UNLOCK_LOCK 0x00000000
  107. #define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
  108. #define DC_GENERAL_CFG_YUVM (1 << 20)
  109. #define DC_GENERAL_CFG_VDSE (1 << 19)
  110. #define DC_GENERAL_CFG_DFHPEL_SHIFT 12
  111. #define DC_GENERAL_CFG_DFHPSL_SHIFT 8
  112. #define DC_GENERAL_CFG_DECE (1 << 6)
  113. #define DC_GENERAL_CFG_CMPE (1 << 5)
  114. #define DC_GENERAL_CFG_VIDE (1 << 3)
  115. #define DC_GENERAL_CFG_ICNE (1 << 2)
  116. #define DC_GENERAL_CFG_CURE (1 << 1)
  117. #define DC_GENERAL_CFG_DFLE (1 << 0)
  118. #define DC_DISPLAY_CFG_A20M (1 << 31)
  119. #define DC_DISPLAY_CFG_A18M (1 << 30)
  120. #define DC_DISPLAY_CFG_PALB (1 << 25)
  121. #define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
  122. #define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
  123. #define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
  124. #define DC_DISPLAY_CFG_VDEN (1 << 4)
  125. #define DC_DISPLAY_CFG_GDEN (1 << 3)
  126. #define DC_DISPLAY_CFG_TGEN (1 << 0)
  127. /*
  128. * Video Processor registers (table 6-54).
  129. * There is space for 64 bit values, but we never use more than the
  130. * lower 32 bits. The actual register save/restore code only bothers
  131. * to restore those 32 bits.
  132. */
  133. enum vp_registers {
  134. VP_VCFG = 0,
  135. VP_DCFG,
  136. VP_VX,
  137. VP_VY,
  138. VP_VS,
  139. VP_VCK,
  140. VP_VCM,
  141. VP_GAR,
  142. VP_GDR,
  143. VP_RSVD_0,
  144. VP_MISC,
  145. VP_CCS,
  146. VP_RSVD_1,
  147. VP_RSVD_2,
  148. VP_RSVD_3,
  149. VP_VDC,
  150. VP_VCO,
  151. VP_CRC,
  152. VP_CRC32,
  153. VP_VDE,
  154. VP_CCK,
  155. VP_CCM,
  156. VP_CC1,
  157. VP_CC2,
  158. VP_A1X,
  159. VP_A1Y,
  160. VP_A1C,
  161. VP_A1T,
  162. VP_A2X,
  163. VP_A2Y,
  164. VP_A2C,
  165. VP_A2T,
  166. VP_A3X,
  167. VP_A3Y,
  168. VP_A3C,
  169. VP_A3T,
  170. VP_VRR,
  171. VP_AWT,
  172. VP_VTM, /* 0x130 */
  173. };
  174. #define VP_VCFG_VID_EN (1 << 0)
  175. #define VP_DCFG_DAC_VREF (1 << 26)
  176. #define VP_DCFG_GV_GAM (1 << 21)
  177. #define VP_DCFG_VG_CK (1 << 20)
  178. #define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
  179. #define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
  180. #define VP_DCFG_CRT_VSYNC_POL (1 << 9)
  181. #define VP_DCFG_CRT_HSYNC_POL (1 << 8)
  182. #define VP_DCFG_FP_DATA_EN (1 << 7) /* undocumented */
  183. #define VP_DCFG_FP_PWR_EN (1 << 6) /* undocumented */
  184. #define VP_DCFG_DAC_BL_EN (1 << 3)
  185. #define VP_DCFG_VSYNC_EN (1 << 2)
  186. #define VP_DCFG_HSYNC_EN (1 << 1)
  187. #define VP_DCFG_CRT_EN (1 << 0)
  188. #define VP_MISC_GAM_EN (1 << 0)
  189. #define VP_MISC_DACPWRDN (1 << 10)
  190. #define VP_MISC_APWRDN (1 << 11)
  191. /*
  192. * Flat Panel registers (table 6-55).
  193. * Also 64 bit registers; see above note about 32-bit handling.
  194. */
  195. /* we're actually in the VP register space, starting at address 0x400 */
  196. #define VP_FP_START 0x400
  197. enum fp_registers {
  198. FP_PT1 = 0,
  199. FP_PT2,
  200. FP_PM,
  201. FP_DFC,
  202. FP_BLFSR,
  203. FP_RLFSR,
  204. FP_FMI,
  205. FP_FMD,
  206. FP_RSVD_0,
  207. FP_DCA,
  208. FP_DMD,
  209. FP_CRC,
  210. FP_FBB, /* 0x460 */
  211. };
  212. #define FP_PT1_VSIZE_SHIFT 16 /* undocumented? */
  213. #define FP_PT1_VSIZE_MASK 0x7FF0000 /* undocumented? */
  214. #define FP_PT2_HSP (1 << 22)
  215. #define FP_PT2_VSP (1 << 23)
  216. #define FP_PM_P (1 << 24) /* panel power on */
  217. #define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
  218. #define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
  219. #define FP_PM_PANEL_OFF (1 << 1) /* r/o */
  220. #define FP_PM_PANEL_ON (1 << 0) /* r/o */
  221. #define FP_DFC_NFI ((1 << 4) | (1 << 5) | (1 << 6))
  222. /* register access functions */
  223. static inline uint32_t read_gp(struct gxfb_par *par, int reg)
  224. {
  225. return readl(par->gp_regs + 4*reg);
  226. }
  227. static inline void write_gp(struct gxfb_par *par, int reg, uint32_t val)
  228. {
  229. writel(val, par->gp_regs + 4*reg);
  230. }
  231. static inline uint32_t read_dc(struct gxfb_par *par, int reg)
  232. {
  233. return readl(par->dc_regs + 4*reg);
  234. }
  235. static inline void write_dc(struct gxfb_par *par, int reg, uint32_t val)
  236. {
  237. writel(val, par->dc_regs + 4*reg);
  238. }
  239. static inline uint32_t read_vp(struct gxfb_par *par, int reg)
  240. {
  241. return readl(par->vid_regs + 8*reg);
  242. }
  243. static inline void write_vp(struct gxfb_par *par, int reg, uint32_t val)
  244. {
  245. writel(val, par->vid_regs + 8*reg);
  246. }
  247. static inline uint32_t read_fp(struct gxfb_par *par, int reg)
  248. {
  249. return readl(par->vid_regs + 8*reg + VP_FP_START);
  250. }
  251. static inline void write_fp(struct gxfb_par *par, int reg, uint32_t val)
  252. {
  253. writel(val, par->vid_regs + 8*reg + VP_FP_START);
  254. }
  255. /* MSRs are defined in linux/cs5535.h; their bitfields are here */
  256. #define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 (1 << 3)
  257. #define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 (1 << 2)
  258. #define MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 (1 << 1)
  259. #define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
  260. #define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
  261. #define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
  262. #define MSR_GX_MSR_PADSEL_MASK 0x3FFFFFFF /* undocumented? */
  263. #define MSR_GX_MSR_PADSEL_TFT 0x1FFFFFFF /* undocumented? */
  264. #define MSR_GX_GLD_MSR_CONFIG_FP (1 << 3)
  265. #endif