gxfb.h 7.1 KB

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