aspeed_gfx.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* Copyright 2018 IBM Corporation */
  3. #include <drm/drm_device.h>
  4. #include <drm/drm_simple_kms_helper.h>
  5. struct aspeed_gfx {
  6. struct drm_device drm;
  7. void __iomem *base;
  8. struct clk *clk;
  9. struct reset_control *rst;
  10. struct regmap *scu;
  11. u32 dac_reg;
  12. u32 int_clr_reg;
  13. u32 vga_scratch_reg;
  14. u32 throd_val;
  15. u32 scan_line_max;
  16. struct drm_simple_display_pipe pipe;
  17. struct drm_connector connector;
  18. };
  19. #define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
  20. int aspeed_gfx_create_pipe(struct drm_device *drm);
  21. int aspeed_gfx_create_output(struct drm_device *drm);
  22. #define CRT_CTRL1 0x60 /* CRT Control I */
  23. #define CRT_CTRL2 0x64 /* CRT Control II */
  24. #define CRT_STATUS 0x68 /* CRT Status */
  25. #define CRT_MISC 0x6c /* CRT Misc Setting */
  26. #define CRT_HORIZ0 0x70 /* CRT Horizontal Total & Display Enable End */
  27. #define CRT_HORIZ1 0x74 /* CRT Horizontal Retrace Start & End */
  28. #define CRT_VERT0 0x78 /* CRT Vertical Total & Display Enable End */
  29. #define CRT_VERT1 0x7C /* CRT Vertical Retrace Start & End */
  30. #define CRT_ADDR 0x80 /* CRT Display Starting Address */
  31. #define CRT_OFFSET 0x84 /* CRT Display Offset & Terminal Count */
  32. #define CRT_THROD 0x88 /* CRT Threshold */
  33. #define CRT_XSCALE 0x8C /* CRT Scaling-Up Factor */
  34. #define CRT_CURSOR0 0x90 /* CRT Hardware Cursor X & Y Offset */
  35. #define CRT_CURSOR1 0x94 /* CRT Hardware Cursor X & Y Position */
  36. #define CRT_CURSOR2 0x98 /* CRT Hardware Cursor Pattern Address */
  37. #define CRT_9C 0x9C
  38. #define CRT_OSD_H 0xA0 /* CRT OSD Horizontal Start/End */
  39. #define CRT_OSD_V 0xA4 /* CRT OSD Vertical Start/End */
  40. #define CRT_OSD_ADDR 0xA8 /* CRT OSD Pattern Address */
  41. #define CRT_OSD_DISP 0xAC /* CRT OSD Offset */
  42. #define CRT_OSD_THRESH 0xB0 /* CRT OSD Threshold & Alpha */
  43. #define CRT_B4 0xB4
  44. #define CRT_STS_V 0xB8 /* CRT Status V */
  45. #define CRT_SCRATCH 0xBC /* Scratchpad */
  46. #define CRT_BB0_ADDR 0xD0 /* CRT Display BB0 Starting Address */
  47. #define CRT_BB1_ADDR 0xD4 /* CRT Display BB1 Starting Address */
  48. #define CRT_BB_COUNT 0xD8 /* CRT Display BB Terminal Count */
  49. #define OSD_COLOR1 0xE0 /* OSD Color Palette Index 1 & 0 */
  50. #define OSD_COLOR2 0xE4 /* OSD Color Palette Index 3 & 2 */
  51. #define OSD_COLOR3 0xE8 /* OSD Color Palette Index 5 & 4 */
  52. #define OSD_COLOR4 0xEC /* OSD Color Palette Index 7 & 6 */
  53. #define OSD_COLOR5 0xF0 /* OSD Color Palette Index 9 & 8 */
  54. #define OSD_COLOR6 0xF4 /* OSD Color Palette Index 11 & 10 */
  55. #define OSD_COLOR7 0xF8 /* OSD Color Palette Index 13 & 12 */
  56. #define OSD_COLOR8 0xFC /* OSD Color Palette Index 15 & 14 */
  57. /* CTRL1 */
  58. #define CRT_CTRL_EN BIT(0)
  59. #define CRT_CTRL_HW_CURSOR_EN BIT(1)
  60. #define CRT_CTRL_OSD_EN BIT(2)
  61. #define CRT_CTRL_INTERLACED BIT(3)
  62. #define CRT_CTRL_COLOR_RGB565 (0 << 7)
  63. #define CRT_CTRL_COLOR_YUV444 (1 << 7)
  64. #define CRT_CTRL_COLOR_XRGB8888 (2 << 7)
  65. #define CRT_CTRL_COLOR_RGB888 (3 << 7)
  66. #define CRT_CTRL_COLOR_YUV444_2RGB (5 << 7)
  67. #define CRT_CTRL_COLOR_YUV422 (7 << 7)
  68. #define CRT_CTRL_COLOR_MASK GENMASK(9, 7)
  69. #define CRT_CTRL_HSYNC_NEGATIVE BIT(16)
  70. #define CRT_CTRL_VSYNC_NEGATIVE BIT(17)
  71. #define CRT_CTRL_VERTICAL_INTR_EN BIT(30)
  72. #define CRT_CTRL_VERTICAL_INTR_STS BIT(31)
  73. /* CTRL2 */
  74. #define CRT_CTRL_DAC_EN BIT(0)
  75. #define CRT_CTRL_VBLANK_LINE(x) (((x) << 20) & CRT_CTRL_VBLANK_LINE_MASK)
  76. #define CRT_CTRL_VBLANK_LINE_MASK GENMASK(31, 20)
  77. /* CRT_HORIZ0 */
  78. #define CRT_H_TOTAL(x) (x)
  79. #define CRT_H_DE(x) ((x) << 16)
  80. /* CRT_HORIZ1 */
  81. #define CRT_H_RS_START(x) (x)
  82. #define CRT_H_RS_END(x) ((x) << 16)
  83. /* CRT_VIRT0 */
  84. #define CRT_V_TOTAL(x) (x)
  85. #define CRT_V_DE(x) ((x) << 16)
  86. /* CRT_VIRT1 */
  87. #define CRT_V_RS_START(x) (x)
  88. #define CRT_V_RS_END(x) ((x) << 16)
  89. /* CRT_OFFSET */
  90. #define CRT_DISP_OFFSET(x) (x)
  91. #define CRT_TERM_COUNT(x) ((x) << 16)
  92. /* CRT_THROD */
  93. #define CRT_THROD_LOW(x) (x)
  94. #define CRT_THROD_HIGH(x) ((x) << 8)