162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 262306a36Sopenharmony_ci/* Copyright 2018 IBM Corporation */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#include <drm/drm_device.h> 562306a36Sopenharmony_ci#include <drm/drm_simple_kms_helper.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_cistruct aspeed_gfx { 862306a36Sopenharmony_ci struct drm_device drm; 962306a36Sopenharmony_ci void __iomem *base; 1062306a36Sopenharmony_ci struct clk *clk; 1162306a36Sopenharmony_ci struct reset_control *rst; 1262306a36Sopenharmony_ci struct regmap *scu; 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci u32 dac_reg; 1562306a36Sopenharmony_ci u32 int_clr_reg; 1662306a36Sopenharmony_ci u32 vga_scratch_reg; 1762306a36Sopenharmony_ci u32 throd_val; 1862306a36Sopenharmony_ci u32 scan_line_max; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci struct drm_simple_display_pipe pipe; 2162306a36Sopenharmony_ci struct drm_connector connector; 2262306a36Sopenharmony_ci}; 2362306a36Sopenharmony_ci#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm) 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciint aspeed_gfx_create_pipe(struct drm_device *drm); 2662306a36Sopenharmony_ciint aspeed_gfx_create_output(struct drm_device *drm); 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define CRT_CTRL1 0x60 /* CRT Control I */ 2962306a36Sopenharmony_ci#define CRT_CTRL2 0x64 /* CRT Control II */ 3062306a36Sopenharmony_ci#define CRT_STATUS 0x68 /* CRT Status */ 3162306a36Sopenharmony_ci#define CRT_MISC 0x6c /* CRT Misc Setting */ 3262306a36Sopenharmony_ci#define CRT_HORIZ0 0x70 /* CRT Horizontal Total & Display Enable End */ 3362306a36Sopenharmony_ci#define CRT_HORIZ1 0x74 /* CRT Horizontal Retrace Start & End */ 3462306a36Sopenharmony_ci#define CRT_VERT0 0x78 /* CRT Vertical Total & Display Enable End */ 3562306a36Sopenharmony_ci#define CRT_VERT1 0x7C /* CRT Vertical Retrace Start & End */ 3662306a36Sopenharmony_ci#define CRT_ADDR 0x80 /* CRT Display Starting Address */ 3762306a36Sopenharmony_ci#define CRT_OFFSET 0x84 /* CRT Display Offset & Terminal Count */ 3862306a36Sopenharmony_ci#define CRT_THROD 0x88 /* CRT Threshold */ 3962306a36Sopenharmony_ci#define CRT_XSCALE 0x8C /* CRT Scaling-Up Factor */ 4062306a36Sopenharmony_ci#define CRT_CURSOR0 0x90 /* CRT Hardware Cursor X & Y Offset */ 4162306a36Sopenharmony_ci#define CRT_CURSOR1 0x94 /* CRT Hardware Cursor X & Y Position */ 4262306a36Sopenharmony_ci#define CRT_CURSOR2 0x98 /* CRT Hardware Cursor Pattern Address */ 4362306a36Sopenharmony_ci#define CRT_9C 0x9C 4462306a36Sopenharmony_ci#define CRT_OSD_H 0xA0 /* CRT OSD Horizontal Start/End */ 4562306a36Sopenharmony_ci#define CRT_OSD_V 0xA4 /* CRT OSD Vertical Start/End */ 4662306a36Sopenharmony_ci#define CRT_OSD_ADDR 0xA8 /* CRT OSD Pattern Address */ 4762306a36Sopenharmony_ci#define CRT_OSD_DISP 0xAC /* CRT OSD Offset */ 4862306a36Sopenharmony_ci#define CRT_OSD_THRESH 0xB0 /* CRT OSD Threshold & Alpha */ 4962306a36Sopenharmony_ci#define CRT_B4 0xB4 5062306a36Sopenharmony_ci#define CRT_STS_V 0xB8 /* CRT Status V */ 5162306a36Sopenharmony_ci#define CRT_SCRATCH 0xBC /* Scratchpad */ 5262306a36Sopenharmony_ci#define CRT_BB0_ADDR 0xD0 /* CRT Display BB0 Starting Address */ 5362306a36Sopenharmony_ci#define CRT_BB1_ADDR 0xD4 /* CRT Display BB1 Starting Address */ 5462306a36Sopenharmony_ci#define CRT_BB_COUNT 0xD8 /* CRT Display BB Terminal Count */ 5562306a36Sopenharmony_ci#define OSD_COLOR1 0xE0 /* OSD Color Palette Index 1 & 0 */ 5662306a36Sopenharmony_ci#define OSD_COLOR2 0xE4 /* OSD Color Palette Index 3 & 2 */ 5762306a36Sopenharmony_ci#define OSD_COLOR3 0xE8 /* OSD Color Palette Index 5 & 4 */ 5862306a36Sopenharmony_ci#define OSD_COLOR4 0xEC /* OSD Color Palette Index 7 & 6 */ 5962306a36Sopenharmony_ci#define OSD_COLOR5 0xF0 /* OSD Color Palette Index 9 & 8 */ 6062306a36Sopenharmony_ci#define OSD_COLOR6 0xF4 /* OSD Color Palette Index 11 & 10 */ 6162306a36Sopenharmony_ci#define OSD_COLOR7 0xF8 /* OSD Color Palette Index 13 & 12 */ 6262306a36Sopenharmony_ci#define OSD_COLOR8 0xFC /* OSD Color Palette Index 15 & 14 */ 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* CTRL1 */ 6562306a36Sopenharmony_ci#define CRT_CTRL_EN BIT(0) 6662306a36Sopenharmony_ci#define CRT_CTRL_HW_CURSOR_EN BIT(1) 6762306a36Sopenharmony_ci#define CRT_CTRL_OSD_EN BIT(2) 6862306a36Sopenharmony_ci#define CRT_CTRL_INTERLACED BIT(3) 6962306a36Sopenharmony_ci#define CRT_CTRL_COLOR_RGB565 (0 << 7) 7062306a36Sopenharmony_ci#define CRT_CTRL_COLOR_YUV444 (1 << 7) 7162306a36Sopenharmony_ci#define CRT_CTRL_COLOR_XRGB8888 (2 << 7) 7262306a36Sopenharmony_ci#define CRT_CTRL_COLOR_RGB888 (3 << 7) 7362306a36Sopenharmony_ci#define CRT_CTRL_COLOR_YUV444_2RGB (5 << 7) 7462306a36Sopenharmony_ci#define CRT_CTRL_COLOR_YUV422 (7 << 7) 7562306a36Sopenharmony_ci#define CRT_CTRL_COLOR_MASK GENMASK(9, 7) 7662306a36Sopenharmony_ci#define CRT_CTRL_HSYNC_NEGATIVE BIT(16) 7762306a36Sopenharmony_ci#define CRT_CTRL_VSYNC_NEGATIVE BIT(17) 7862306a36Sopenharmony_ci#define CRT_CTRL_VERTICAL_INTR_EN BIT(30) 7962306a36Sopenharmony_ci#define CRT_CTRL_VERTICAL_INTR_STS BIT(31) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* CTRL2 */ 8262306a36Sopenharmony_ci#define CRT_CTRL_DAC_EN BIT(0) 8362306a36Sopenharmony_ci#define CRT_CTRL_VBLANK_LINE(x) (((x) << 20) & CRT_CTRL_VBLANK_LINE_MASK) 8462306a36Sopenharmony_ci#define CRT_CTRL_VBLANK_LINE_MASK GENMASK(31, 20) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* CRT_HORIZ0 */ 8762306a36Sopenharmony_ci#define CRT_H_TOTAL(x) (x) 8862306a36Sopenharmony_ci#define CRT_H_DE(x) ((x) << 16) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* CRT_HORIZ1 */ 9162306a36Sopenharmony_ci#define CRT_H_RS_START(x) (x) 9262306a36Sopenharmony_ci#define CRT_H_RS_END(x) ((x) << 16) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* CRT_VIRT0 */ 9562306a36Sopenharmony_ci#define CRT_V_TOTAL(x) (x) 9662306a36Sopenharmony_ci#define CRT_V_DE(x) ((x) << 16) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci/* CRT_VIRT1 */ 9962306a36Sopenharmony_ci#define CRT_V_RS_START(x) (x) 10062306a36Sopenharmony_ci#define CRT_V_RS_END(x) ((x) << 16) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci/* CRT_OFFSET */ 10362306a36Sopenharmony_ci#define CRT_DISP_OFFSET(x) (x) 10462306a36Sopenharmony_ci#define CRT_TERM_COUNT(x) ((x) << 16) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* CRT_THROD */ 10762306a36Sopenharmony_ci#define CRT_THROD_LOW(x) (x) 10862306a36Sopenharmony_ci#define CRT_THROD_HIGH(x) ((x) << 8) 109