18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
48c2ecf20Sopenharmony_ci * Author:Mark Yao <mark.yao@rock-chips.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/component.h>
88c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h>
98c2ecf20Sopenharmony_ci#include <linux/module.h>
108c2ecf20Sopenharmony_ci#include <linux/of.h>
118c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <drm/drm_fourcc.h>
148c2ecf20Sopenharmony_ci#include <drm/drm_plane.h>
158c2ecf20Sopenharmony_ci#include <drm/drm_print.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "rockchip_drm_vop.h"
188c2ecf20Sopenharmony_ci#include "rockchip_vop_reg.h"
198c2ecf20Sopenharmony_ci#include "rockchip_drm_drv.h"
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define _VOP_REG(off, _mask, _shift, _write_mask, _relaxed) \
228c2ecf20Sopenharmony_ci		{ \
238c2ecf20Sopenharmony_ci		 .offset = off, \
248c2ecf20Sopenharmony_ci		 .mask = _mask, \
258c2ecf20Sopenharmony_ci		 .shift = _shift, \
268c2ecf20Sopenharmony_ci		 .write_mask = _write_mask, \
278c2ecf20Sopenharmony_ci		 .relaxed = _relaxed, \
288c2ecf20Sopenharmony_ci		}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define VOP_REG(off, _mask, _shift) \
318c2ecf20Sopenharmony_ci		_VOP_REG(off, _mask, _shift, false, true)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define VOP_REG_SYNC(off, _mask, _shift) \
348c2ecf20Sopenharmony_ci		_VOP_REG(off, _mask, _shift, false, false)
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define VOP_REG_MASK_SYNC(off, _mask, _shift) \
378c2ecf20Sopenharmony_ci		_VOP_REG(off, _mask, _shift, true, false)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistatic const uint32_t formats_win_full[] = {
408c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB8888,
418c2ecf20Sopenharmony_ci	DRM_FORMAT_ARGB8888,
428c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR8888,
438c2ecf20Sopenharmony_ci	DRM_FORMAT_ABGR8888,
448c2ecf20Sopenharmony_ci	DRM_FORMAT_RGB888,
458c2ecf20Sopenharmony_ci	DRM_FORMAT_BGR888,
468c2ecf20Sopenharmony_ci	DRM_FORMAT_RGB565,
478c2ecf20Sopenharmony_ci	DRM_FORMAT_BGR565,
488c2ecf20Sopenharmony_ci	DRM_FORMAT_NV12,
498c2ecf20Sopenharmony_ci	DRM_FORMAT_NV16,
508c2ecf20Sopenharmony_ci	DRM_FORMAT_NV24,
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic const uint64_t format_modifiers_win_full[] = {
548c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_LINEAR,
558c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_INVALID,
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic const uint64_t format_modifiers_win_full_afbc[] = {
598c2ecf20Sopenharmony_ci	ROCKCHIP_AFBC_MOD,
608c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_LINEAR,
618c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_INVALID,
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic const uint32_t formats_win_lite[] = {
658c2ecf20Sopenharmony_ci	DRM_FORMAT_XRGB8888,
668c2ecf20Sopenharmony_ci	DRM_FORMAT_ARGB8888,
678c2ecf20Sopenharmony_ci	DRM_FORMAT_XBGR8888,
688c2ecf20Sopenharmony_ci	DRM_FORMAT_ABGR8888,
698c2ecf20Sopenharmony_ci	DRM_FORMAT_RGB888,
708c2ecf20Sopenharmony_ci	DRM_FORMAT_BGR888,
718c2ecf20Sopenharmony_ci	DRM_FORMAT_RGB565,
728c2ecf20Sopenharmony_ci	DRM_FORMAT_BGR565,
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic const uint64_t format_modifiers_win_lite[] = {
768c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_LINEAR,
778c2ecf20Sopenharmony_ci	DRM_FORMAT_MOD_INVALID,
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic const struct vop_scl_regs rk3036_win_scl = {
818c2ecf20Sopenharmony_ci	.scale_yrgb_x = VOP_REG(RK3036_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0),
828c2ecf20Sopenharmony_ci	.scale_yrgb_y = VOP_REG(RK3036_WIN0_SCL_FACTOR_YRGB, 0xffff, 16),
838c2ecf20Sopenharmony_ci	.scale_cbcr_x = VOP_REG(RK3036_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0),
848c2ecf20Sopenharmony_ci	.scale_cbcr_y = VOP_REG(RK3036_WIN0_SCL_FACTOR_CBR, 0xffff, 16),
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3036_win0_data = {
888c2ecf20Sopenharmony_ci	.scl = &rk3036_win_scl,
898c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
908c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
918c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
928c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 0),
938c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3036_SYS_CTRL, 0x7, 3),
948c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 15),
958c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3036_WIN0_ACT_INFO, 0x1fff1fff, 0),
968c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3036_WIN0_DSP_INFO, 0x0fff0fff, 0),
978c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3036_WIN0_DSP_ST, 0x1fff1fff, 0),
988c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3036_WIN0_YRGB_MST, 0xffffffff, 0),
998c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3036_WIN0_CBR_MST, 0xffffffff, 0),
1008c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3036_WIN0_VIR, 0xffff, 0),
1018c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3036_WIN0_VIR, 0x1fff, 16),
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3036_win1_data = {
1058c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
1068c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
1078c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
1088c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 1),
1098c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3036_SYS_CTRL, 0x7, 6),
1108c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 19),
1118c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3036_WIN1_ACT_INFO, 0x1fff1fff, 0),
1128c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3036_WIN1_DSP_INFO, 0x0fff0fff, 0),
1138c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3036_WIN1_DSP_ST, 0x1fff1fff, 0),
1148c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3036_WIN1_MST, 0xffffffff, 0),
1158c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3036_WIN1_VIR, 0xffff, 0),
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3036_vop_win_data[] = {
1198c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3036_win0_data,
1208c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
1218c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3036_win1_data,
1228c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_cistatic const int rk3036_vop_intrs[] = {
1268c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
1278c2ecf20Sopenharmony_ci	FS_INTR,
1288c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
1298c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistatic const struct vop_intr rk3036_intr = {
1338c2ecf20Sopenharmony_ci	.intrs = rk3036_vop_intrs,
1348c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3036_vop_intrs),
1358c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3036_INT_STATUS, 0xfff, 12),
1368c2ecf20Sopenharmony_ci	.status = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 0),
1378c2ecf20Sopenharmony_ci	.enable = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 4),
1388c2ecf20Sopenharmony_ci	.clear = VOP_REG_SYNC(RK3036_INT_STATUS, 0xf, 8),
1398c2ecf20Sopenharmony_ci};
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cistatic const struct vop_modeset rk3036_modeset = {
1428c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(RK3036_DSP_HTOTAL_HS_END, 0x1fff1fff, 0),
1438c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(RK3036_DSP_HACT_ST_END, 0x1fff1fff, 0),
1448c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(RK3036_DSP_VTOTAL_VS_END, 0x1fff1fff, 0),
1458c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(RK3036_DSP_VACT_ST_END, 0x1fff1fff, 0),
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic const struct vop_output rk3036_output = {
1498c2ecf20Sopenharmony_ci	.pin_pol = VOP_REG(RK3036_DSP_CTRL0, 0xf, 4),
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic const struct vop_common rk3036_common = {
1538c2ecf20Sopenharmony_ci	.standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30),
1548c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0),
1558c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24),
1568c2ecf20Sopenharmony_ci	.dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27),
1578c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11),
1588c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10),
1598c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0),
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic const struct vop_data rk3036_vop = {
1638c2ecf20Sopenharmony_ci	.intr = &rk3036_intr,
1648c2ecf20Sopenharmony_ci	.common = &rk3036_common,
1658c2ecf20Sopenharmony_ci	.modeset = &rk3036_modeset,
1668c2ecf20Sopenharmony_ci	.output = &rk3036_output,
1678c2ecf20Sopenharmony_ci	.win = rk3036_vop_win_data,
1688c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3036_vop_win_data),
1698c2ecf20Sopenharmony_ci};
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3126_win1_data = {
1728c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
1738c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
1748c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
1758c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3036_SYS_CTRL, 0x1, 1),
1768c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3036_SYS_CTRL, 0x7, 6),
1778c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3036_SYS_CTRL, 0x1, 19),
1788c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3126_WIN1_DSP_INFO, 0x0fff0fff, 0),
1798c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3126_WIN1_DSP_ST, 0x1fff1fff, 0),
1808c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3126_WIN1_MST, 0xffffffff, 0),
1818c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3036_WIN1_VIR, 0xffff, 0),
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3126_vop_win_data[] = {
1858c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3036_win0_data,
1868c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
1878c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3126_win1_data,
1888c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic const struct vop_data rk3126_vop = {
1928c2ecf20Sopenharmony_ci	.intr = &rk3036_intr,
1938c2ecf20Sopenharmony_ci	.common = &rk3036_common,
1948c2ecf20Sopenharmony_ci	.modeset = &rk3036_modeset,
1958c2ecf20Sopenharmony_ci	.output = &rk3036_output,
1968c2ecf20Sopenharmony_ci	.win = rk3126_vop_win_data,
1978c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3126_vop_win_data),
1988c2ecf20Sopenharmony_ci};
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_cistatic const int px30_vop_intrs[] = {
2018c2ecf20Sopenharmony_ci	FS_INTR,
2028c2ecf20Sopenharmony_ci	0, 0,
2038c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
2048c2ecf20Sopenharmony_ci	0,
2058c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
2068c2ecf20Sopenharmony_ci	0, 0,
2078c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
2088c2ecf20Sopenharmony_ci};
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_cistatic const struct vop_intr px30_intr = {
2118c2ecf20Sopenharmony_ci	.intrs = px30_vop_intrs,
2128c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(px30_vop_intrs),
2138c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(PX30_LINE_FLAG, 0xfff, 0),
2148c2ecf20Sopenharmony_ci	.status = VOP_REG_MASK_SYNC(PX30_INTR_STATUS, 0xffff, 0),
2158c2ecf20Sopenharmony_ci	.enable = VOP_REG_MASK_SYNC(PX30_INTR_EN, 0xffff, 0),
2168c2ecf20Sopenharmony_ci	.clear = VOP_REG_MASK_SYNC(PX30_INTR_CLEAR, 0xffff, 0),
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistatic const struct vop_common px30_common = {
2208c2ecf20Sopenharmony_ci	.standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1),
2218c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16),
2228c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14),
2238c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8),
2248c2ecf20Sopenharmony_ci	.dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7),
2258c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6),
2268c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0),
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistatic const struct vop_modeset px30_modeset = {
2308c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(PX30_DSP_HTOTAL_HS_END, 0x0fff0fff, 0),
2318c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(PX30_DSP_HACT_ST_END, 0x0fff0fff, 0),
2328c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(PX30_DSP_VTOTAL_VS_END, 0x0fff0fff, 0),
2338c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(PX30_DSP_VACT_ST_END, 0x0fff0fff, 0),
2348c2ecf20Sopenharmony_ci};
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cistatic const struct vop_output px30_output = {
2378c2ecf20Sopenharmony_ci	.rgb_dclk_pol = VOP_REG(PX30_DSP_CTRL0, 0x1, 1),
2388c2ecf20Sopenharmony_ci	.rgb_pin_pol = VOP_REG(PX30_DSP_CTRL0, 0x7, 2),
2398c2ecf20Sopenharmony_ci	.rgb_en = VOP_REG(PX30_DSP_CTRL0, 0x1, 0),
2408c2ecf20Sopenharmony_ci	.mipi_dclk_pol = VOP_REG(PX30_DSP_CTRL0, 0x1, 25),
2418c2ecf20Sopenharmony_ci	.mipi_pin_pol = VOP_REG(PX30_DSP_CTRL0, 0x7, 26),
2428c2ecf20Sopenharmony_ci	.mipi_en = VOP_REG(PX30_DSP_CTRL0, 0x1, 24),
2438c2ecf20Sopenharmony_ci};
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistatic const struct vop_scl_regs px30_win_scl = {
2468c2ecf20Sopenharmony_ci	.scale_yrgb_x = VOP_REG(PX30_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0),
2478c2ecf20Sopenharmony_ci	.scale_yrgb_y = VOP_REG(PX30_WIN0_SCL_FACTOR_YRGB, 0xffff, 16),
2488c2ecf20Sopenharmony_ci	.scale_cbcr_x = VOP_REG(PX30_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0),
2498c2ecf20Sopenharmony_ci	.scale_cbcr_y = VOP_REG(PX30_WIN0_SCL_FACTOR_CBR, 0xffff, 16),
2508c2ecf20Sopenharmony_ci};
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_cistatic const struct vop_win_phy px30_win0_data = {
2538c2ecf20Sopenharmony_ci	.scl = &px30_win_scl,
2548c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
2558c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
2568c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
2578c2ecf20Sopenharmony_ci	.enable = VOP_REG(PX30_WIN0_CTRL0, 0x1, 0),
2588c2ecf20Sopenharmony_ci	.format = VOP_REG(PX30_WIN0_CTRL0, 0x7, 1),
2598c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(PX30_WIN0_CTRL0, 0x1, 12),
2608c2ecf20Sopenharmony_ci	.act_info = VOP_REG(PX30_WIN0_ACT_INFO, 0xffffffff, 0),
2618c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(PX30_WIN0_DSP_INFO, 0xffffffff, 0),
2628c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(PX30_WIN0_DSP_ST, 0xffffffff, 0),
2638c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(PX30_WIN0_YRGB_MST0, 0xffffffff, 0),
2648c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(PX30_WIN0_CBR_MST0, 0xffffffff, 0),
2658c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(PX30_WIN0_VIR, 0x1fff, 0),
2668c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(PX30_WIN0_VIR, 0x1fff, 16),
2678c2ecf20Sopenharmony_ci	.alpha_pre_mul = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 2),
2688c2ecf20Sopenharmony_ci	.alpha_mode = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 1),
2698c2ecf20Sopenharmony_ci	.alpha_en = VOP_REG(PX30_WIN0_ALPHA_CTRL, 0x1, 0),
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic const struct vop_win_phy px30_win1_data = {
2738c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
2748c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
2758c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
2768c2ecf20Sopenharmony_ci	.enable = VOP_REG(PX30_WIN1_CTRL0, 0x1, 0),
2778c2ecf20Sopenharmony_ci	.format = VOP_REG(PX30_WIN1_CTRL0, 0x7, 4),
2788c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(PX30_WIN1_CTRL0, 0x1, 12),
2798c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(PX30_WIN1_DSP_INFO, 0xffffffff, 0),
2808c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(PX30_WIN1_DSP_ST, 0xffffffff, 0),
2818c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(PX30_WIN1_MST, 0xffffffff, 0),
2828c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(PX30_WIN1_VIR, 0x1fff, 0),
2838c2ecf20Sopenharmony_ci	.alpha_pre_mul = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 2),
2848c2ecf20Sopenharmony_ci	.alpha_mode = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 1),
2858c2ecf20Sopenharmony_ci	.alpha_en = VOP_REG(PX30_WIN1_ALPHA_CTRL, 0x1, 0),
2868c2ecf20Sopenharmony_ci};
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_cistatic const struct vop_win_phy px30_win2_data = {
2898c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
2908c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
2918c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
2928c2ecf20Sopenharmony_ci	.gate = VOP_REG(PX30_WIN2_CTRL0, 0x1, 4),
2938c2ecf20Sopenharmony_ci	.enable = VOP_REG(PX30_WIN2_CTRL0, 0x1, 0),
2948c2ecf20Sopenharmony_ci	.format = VOP_REG(PX30_WIN2_CTRL0, 0x3, 5),
2958c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(PX30_WIN2_CTRL0, 0x1, 20),
2968c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(PX30_WIN2_DSP_INFO0, 0x0fff0fff, 0),
2978c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(PX30_WIN2_DSP_ST0, 0x1fff1fff, 0),
2988c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(PX30_WIN2_MST0, 0xffffffff, 0),
2998c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(PX30_WIN2_VIR0_1, 0x1fff, 0),
3008c2ecf20Sopenharmony_ci	.alpha_pre_mul = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 2),
3018c2ecf20Sopenharmony_ci	.alpha_mode = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 1),
3028c2ecf20Sopenharmony_ci	.alpha_en = VOP_REG(PX30_WIN2_ALPHA_CTRL, 0x1, 0),
3038c2ecf20Sopenharmony_ci};
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_cistatic const struct vop_win_data px30_vop_big_win_data[] = {
3068c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &px30_win0_data,
3078c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
3088c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &px30_win1_data,
3098c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
3108c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &px30_win2_data,
3118c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
3128c2ecf20Sopenharmony_ci};
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistatic const struct vop_data px30_vop_big = {
3158c2ecf20Sopenharmony_ci	.intr = &px30_intr,
3168c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_INTERNAL_RGB,
3178c2ecf20Sopenharmony_ci	.common = &px30_common,
3188c2ecf20Sopenharmony_ci	.modeset = &px30_modeset,
3198c2ecf20Sopenharmony_ci	.output = &px30_output,
3208c2ecf20Sopenharmony_ci	.win = px30_vop_big_win_data,
3218c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(px30_vop_big_win_data),
3228c2ecf20Sopenharmony_ci};
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_cistatic const struct vop_win_data px30_vop_lit_win_data[] = {
3258c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &px30_win1_data,
3268c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
3278c2ecf20Sopenharmony_ci};
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_cistatic const struct vop_data px30_vop_lit = {
3308c2ecf20Sopenharmony_ci	.intr = &px30_intr,
3318c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_INTERNAL_RGB,
3328c2ecf20Sopenharmony_ci	.common = &px30_common,
3338c2ecf20Sopenharmony_ci	.modeset = &px30_modeset,
3348c2ecf20Sopenharmony_ci	.output = &px30_output,
3358c2ecf20Sopenharmony_ci	.win = px30_vop_lit_win_data,
3368c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(px30_vop_lit_win_data),
3378c2ecf20Sopenharmony_ci};
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cistatic const struct vop_scl_regs rk3066_win_scl = {
3408c2ecf20Sopenharmony_ci	.scale_yrgb_x = VOP_REG(RK3066_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0),
3418c2ecf20Sopenharmony_ci	.scale_yrgb_y = VOP_REG(RK3066_WIN0_SCL_FACTOR_YRGB, 0xffff, 16),
3428c2ecf20Sopenharmony_ci	.scale_cbcr_x = VOP_REG(RK3066_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0),
3438c2ecf20Sopenharmony_ci	.scale_cbcr_y = VOP_REG(RK3066_WIN0_SCL_FACTOR_CBR, 0xffff, 16),
3448c2ecf20Sopenharmony_ci};
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3066_win0_data = {
3478c2ecf20Sopenharmony_ci	.scl = &rk3066_win_scl,
3488c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
3498c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
3508c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
3518c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 0),
3528c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 4),
3538c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 19),
3548c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3066_WIN0_ACT_INFO, 0x1fff1fff, 0),
3558c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3066_WIN0_DSP_INFO, 0x0fff0fff, 0),
3568c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3066_WIN0_DSP_ST, 0x1fff1fff, 0),
3578c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3066_WIN0_YRGB_MST0, 0xffffffff, 0),
3588c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3066_WIN0_CBR_MST0, 0xffffffff, 0),
3598c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3066_WIN0_VIR, 0xffff, 0),
3608c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3066_WIN0_VIR, 0x1fff, 16),
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3066_win1_data = {
3648c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
3658c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
3668c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
3678c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 1),
3688c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 7),
3698c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 23),
3708c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3066_WIN1_ACT_INFO, 0x1fff1fff, 0),
3718c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3066_WIN1_DSP_INFO, 0x0fff0fff, 0),
3728c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3066_WIN1_DSP_ST, 0x1fff1fff, 0),
3738c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3066_WIN1_YRGB_MST, 0xffffffff, 0),
3748c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3066_WIN1_CBR_MST, 0xffffffff, 0),
3758c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3066_WIN1_VIR, 0xffff, 0),
3768c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3066_WIN1_VIR, 0x1fff, 16),
3778c2ecf20Sopenharmony_ci};
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3066_win2_data = {
3808c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
3818c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
3828c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
3838c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3066_SYS_CTRL1, 0x1, 2),
3848c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3066_SYS_CTRL1, 0x7, 10),
3858c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3066_SYS_CTRL1, 0x1, 27),
3868c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3066_WIN2_DSP_INFO, 0x0fff0fff, 0),
3878c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3066_WIN2_DSP_ST, 0x1fff1fff, 0),
3888c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3066_WIN2_MST, 0xffffffff, 0),
3898c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3066_WIN2_VIR, 0xffff, 0),
3908c2ecf20Sopenharmony_ci};
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic const struct vop_modeset rk3066_modeset = {
3938c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(RK3066_DSP_HTOTAL_HS_END, 0x1fff1fff, 0),
3948c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(RK3066_DSP_HACT_ST_END, 0x1fff1fff, 0),
3958c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(RK3066_DSP_VTOTAL_VS_END, 0x1fff1fff, 0),
3968c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(RK3066_DSP_VACT_ST_END, 0x1fff1fff, 0),
3978c2ecf20Sopenharmony_ci};
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_cistatic const struct vop_output rk3066_output = {
4008c2ecf20Sopenharmony_ci	.pin_pol = VOP_REG(RK3066_DSP_CTRL0, 0x7, 4),
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistatic const struct vop_common rk3066_common = {
4048c2ecf20Sopenharmony_ci	.standby = VOP_REG(RK3066_SYS_CTRL0, 0x1, 1),
4058c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(RK3066_DSP_CTRL0, 0xf, 0),
4068c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG(RK3066_REG_CFG_DONE, 0x1, 0),
4078c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(RK3066_DSP_CTRL0, 0x1, 11),
4088c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 10),
4098c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 24),
4108c2ecf20Sopenharmony_ci	.dither_up = VOP_REG(RK3066_DSP_CTRL0, 0x1, 9),
4118c2ecf20Sopenharmony_ci	.dsp_lut_en = VOP_REG(RK3066_SYS_CTRL1, 0x1, 31),
4128c2ecf20Sopenharmony_ci	.data_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 25),
4138c2ecf20Sopenharmony_ci};
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3066_vop_win_data[] = {
4168c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3066_win0_data,
4178c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
4188c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3066_win1_data,
4198c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
4208c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3066_win2_data,
4218c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
4228c2ecf20Sopenharmony_ci};
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistatic const int rk3066_vop_intrs[] = {
4258c2ecf20Sopenharmony_ci	/*
4268c2ecf20Sopenharmony_ci	 * hs_start interrupt fires at frame-start, so serves
4278c2ecf20Sopenharmony_ci	 * the same purpose as dsp_hold in the driver.
4288c2ecf20Sopenharmony_ci	 */
4298c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
4308c2ecf20Sopenharmony_ci	FS_INTR,
4318c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
4328c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
4338c2ecf20Sopenharmony_ci};
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_cistatic const struct vop_intr rk3066_intr = {
4368c2ecf20Sopenharmony_ci	.intrs = rk3066_vop_intrs,
4378c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3066_vop_intrs),
4388c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3066_INT_STATUS, 0xfff, 12),
4398c2ecf20Sopenharmony_ci	.status = VOP_REG(RK3066_INT_STATUS, 0xf, 0),
4408c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3066_INT_STATUS, 0xf, 4),
4418c2ecf20Sopenharmony_ci	.clear = VOP_REG(RK3066_INT_STATUS, 0xf, 8),
4428c2ecf20Sopenharmony_ci};
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_cistatic const struct vop_data rk3066_vop = {
4458c2ecf20Sopenharmony_ci	.version = VOP_VERSION(2, 1),
4468c2ecf20Sopenharmony_ci	.intr = &rk3066_intr,
4478c2ecf20Sopenharmony_ci	.common = &rk3066_common,
4488c2ecf20Sopenharmony_ci	.modeset = &rk3066_modeset,
4498c2ecf20Sopenharmony_ci	.output = &rk3066_output,
4508c2ecf20Sopenharmony_ci	.win = rk3066_vop_win_data,
4518c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3066_vop_win_data),
4528c2ecf20Sopenharmony_ci};
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic const struct vop_scl_regs rk3188_win_scl = {
4558c2ecf20Sopenharmony_ci	.scale_yrgb_x = VOP_REG(RK3188_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0),
4568c2ecf20Sopenharmony_ci	.scale_yrgb_y = VOP_REG(RK3188_WIN0_SCL_FACTOR_YRGB, 0xffff, 16),
4578c2ecf20Sopenharmony_ci	.scale_cbcr_x = VOP_REG(RK3188_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0),
4588c2ecf20Sopenharmony_ci	.scale_cbcr_y = VOP_REG(RK3188_WIN0_SCL_FACTOR_CBR, 0xffff, 16),
4598c2ecf20Sopenharmony_ci};
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3188_win0_data = {
4628c2ecf20Sopenharmony_ci	.scl = &rk3188_win_scl,
4638c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
4648c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
4658c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
4668c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3188_SYS_CTRL, 0x1, 0),
4678c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3188_SYS_CTRL, 0x7, 3),
4688c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3188_SYS_CTRL, 0x1, 15),
4698c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3188_WIN0_ACT_INFO, 0x1fff1fff, 0),
4708c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3188_WIN0_DSP_INFO, 0x0fff0fff, 0),
4718c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3188_WIN0_DSP_ST, 0x1fff1fff, 0),
4728c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3188_WIN0_YRGB_MST0, 0xffffffff, 0),
4738c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3188_WIN0_CBR_MST0, 0xffffffff, 0),
4748c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3188_WIN_VIR, 0x1fff, 0),
4758c2ecf20Sopenharmony_ci};
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3188_win1_data = {
4788c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
4798c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
4808c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
4818c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3188_SYS_CTRL, 0x1, 1),
4828c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3188_SYS_CTRL, 0x7, 6),
4838c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3188_SYS_CTRL, 0x1, 19),
4848c2ecf20Sopenharmony_ci	/* no act_info on window1 */
4858c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3188_WIN1_DSP_INFO, 0x07ff07ff, 0),
4868c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3188_WIN1_DSP_ST, 0x0fff0fff, 0),
4878c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3188_WIN1_MST, 0xffffffff, 0),
4888c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3188_WIN_VIR, 0x1fff, 16),
4898c2ecf20Sopenharmony_ci};
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic const struct vop_modeset rk3188_modeset = {
4928c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(RK3188_DSP_HTOTAL_HS_END, 0x0fff0fff, 0),
4938c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(RK3188_DSP_HACT_ST_END, 0x0fff0fff, 0),
4948c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(RK3188_DSP_VTOTAL_VS_END, 0x0fff0fff, 0),
4958c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(RK3188_DSP_VACT_ST_END, 0x0fff0fff, 0),
4968c2ecf20Sopenharmony_ci};
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_cistatic const struct vop_output rk3188_output = {
4998c2ecf20Sopenharmony_ci	.pin_pol = VOP_REG(RK3188_DSP_CTRL0, 0xf, 4),
5008c2ecf20Sopenharmony_ci};
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_cistatic const struct vop_common rk3188_common = {
5038c2ecf20Sopenharmony_ci	.gate_en = VOP_REG(RK3188_SYS_CTRL, 0x1, 31),
5048c2ecf20Sopenharmony_ci	.standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30),
5058c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0),
5068c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0),
5078c2ecf20Sopenharmony_ci	.dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27),
5088c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11),
5098c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10),
5108c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x1, 24),
5118c2ecf20Sopenharmony_ci	.dither_up = VOP_REG(RK3188_DSP_CTRL0, 0x1, 9),
5128c2ecf20Sopenharmony_ci	.dsp_lut_en = VOP_REG(RK3188_SYS_CTRL, 0x1, 28),
5138c2ecf20Sopenharmony_ci	.data_blank = VOP_REG(RK3188_DSP_CTRL1, 0x1, 25),
5148c2ecf20Sopenharmony_ci};
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3188_vop_win_data[] = {
5178c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3188_win0_data,
5188c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
5198c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3188_win1_data,
5208c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
5218c2ecf20Sopenharmony_ci};
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_cistatic const int rk3188_vop_intrs[] = {
5248c2ecf20Sopenharmony_ci	/*
5258c2ecf20Sopenharmony_ci	 * hs_start interrupt fires at frame-start, so serves
5268c2ecf20Sopenharmony_ci	 * the same purpose as dsp_hold in the driver.
5278c2ecf20Sopenharmony_ci	 */
5288c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
5298c2ecf20Sopenharmony_ci	FS_INTR,
5308c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
5318c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
5328c2ecf20Sopenharmony_ci};
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_cistatic const struct vop_intr rk3188_vop_intr = {
5358c2ecf20Sopenharmony_ci	.intrs = rk3188_vop_intrs,
5368c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3188_vop_intrs),
5378c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3188_INT_STATUS, 0xfff, 12),
5388c2ecf20Sopenharmony_ci	.status = VOP_REG(RK3188_INT_STATUS, 0xf, 0),
5398c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3188_INT_STATUS, 0xf, 4),
5408c2ecf20Sopenharmony_ci	.clear = VOP_REG(RK3188_INT_STATUS, 0xf, 8),
5418c2ecf20Sopenharmony_ci};
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_cistatic const struct vop_data rk3188_vop = {
5448c2ecf20Sopenharmony_ci	.intr = &rk3188_vop_intr,
5458c2ecf20Sopenharmony_ci	.common = &rk3188_common,
5468c2ecf20Sopenharmony_ci	.modeset = &rk3188_modeset,
5478c2ecf20Sopenharmony_ci	.output = &rk3188_output,
5488c2ecf20Sopenharmony_ci	.win = rk3188_vop_win_data,
5498c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3188_vop_win_data),
5508c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_INTERNAL_RGB,
5518c2ecf20Sopenharmony_ci};
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_cistatic const struct vop_scl_extension rk3288_win_full_scl_ext = {
5548c2ecf20Sopenharmony_ci	.cbcr_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 31),
5558c2ecf20Sopenharmony_ci	.cbcr_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 30),
5568c2ecf20Sopenharmony_ci	.cbcr_hsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 28),
5578c2ecf20Sopenharmony_ci	.cbcr_ver_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 26),
5588c2ecf20Sopenharmony_ci	.cbcr_hor_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 24),
5598c2ecf20Sopenharmony_ci	.yrgb_vsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 23),
5608c2ecf20Sopenharmony_ci	.yrgb_vsu_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 22),
5618c2ecf20Sopenharmony_ci	.yrgb_hsd_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 20),
5628c2ecf20Sopenharmony_ci	.yrgb_ver_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 18),
5638c2ecf20Sopenharmony_ci	.yrgb_hor_scl_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 16),
5648c2ecf20Sopenharmony_ci	.line_load_mode = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 15),
5658c2ecf20Sopenharmony_ci	.cbcr_axi_gather_num = VOP_REG(RK3288_WIN0_CTRL1, 0x7, 12),
5668c2ecf20Sopenharmony_ci	.yrgb_axi_gather_num = VOP_REG(RK3288_WIN0_CTRL1, 0xf, 8),
5678c2ecf20Sopenharmony_ci	.vsd_cbcr_gt2 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 7),
5688c2ecf20Sopenharmony_ci	.vsd_cbcr_gt4 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 6),
5698c2ecf20Sopenharmony_ci	.vsd_yrgb_gt2 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 5),
5708c2ecf20Sopenharmony_ci	.vsd_yrgb_gt4 = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 4),
5718c2ecf20Sopenharmony_ci	.bic_coe_sel = VOP_REG(RK3288_WIN0_CTRL1, 0x3, 2),
5728c2ecf20Sopenharmony_ci	.cbcr_axi_gather_en = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 1),
5738c2ecf20Sopenharmony_ci	.yrgb_axi_gather_en = VOP_REG(RK3288_WIN0_CTRL1, 0x1, 0),
5748c2ecf20Sopenharmony_ci	.lb_mode = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 5),
5758c2ecf20Sopenharmony_ci};
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_cistatic const struct vop_scl_regs rk3288_win_full_scl = {
5788c2ecf20Sopenharmony_ci	.ext = &rk3288_win_full_scl_ext,
5798c2ecf20Sopenharmony_ci	.scale_yrgb_x = VOP_REG(RK3288_WIN0_SCL_FACTOR_YRGB, 0xffff, 0x0),
5808c2ecf20Sopenharmony_ci	.scale_yrgb_y = VOP_REG(RK3288_WIN0_SCL_FACTOR_YRGB, 0xffff, 16),
5818c2ecf20Sopenharmony_ci	.scale_cbcr_x = VOP_REG(RK3288_WIN0_SCL_FACTOR_CBR, 0xffff, 0x0),
5828c2ecf20Sopenharmony_ci	.scale_cbcr_y = VOP_REG(RK3288_WIN0_SCL_FACTOR_CBR, 0xffff, 16),
5838c2ecf20Sopenharmony_ci};
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3288_win01_data = {
5868c2ecf20Sopenharmony_ci	.scl = &rk3288_win_full_scl,
5878c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
5888c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
5898c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
5908c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 0),
5918c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 1),
5928c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 12),
5938c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3288_WIN0_ACT_INFO, 0x1fff1fff, 0),
5948c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3288_WIN0_DSP_INFO, 0x0fff0fff, 0),
5958c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3288_WIN0_DSP_ST, 0x1fff1fff, 0),
5968c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3288_WIN0_YRGB_MST, 0xffffffff, 0),
5978c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3288_WIN0_CBR_MST, 0xffffffff, 0),
5988c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 0),
5998c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 16),
6008c2ecf20Sopenharmony_ci	.src_alpha_ctl = VOP_REG(RK3288_WIN0_SRC_ALPHA_CTRL, 0xff, 0),
6018c2ecf20Sopenharmony_ci	.dst_alpha_ctl = VOP_REG(RK3288_WIN0_DST_ALPHA_CTRL, 0xff, 0),
6028c2ecf20Sopenharmony_ci	.channel = VOP_REG(RK3288_WIN0_CTRL2, 0xff, 0),
6038c2ecf20Sopenharmony_ci};
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3288_win23_data = {
6068c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
6078c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
6088c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
6098c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 4),
6108c2ecf20Sopenharmony_ci	.gate = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 0),
6118c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3288_WIN2_CTRL0, 0x7, 1),
6128c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3288_WIN2_CTRL0, 0x1, 12),
6138c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3288_WIN2_DSP_INFO0, 0x0fff0fff, 0),
6148c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3288_WIN2_DSP_ST0, 0x1fff1fff, 0),
6158c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3288_WIN2_MST0, 0xffffffff, 0),
6168c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3288_WIN2_VIR0_1, 0x1fff, 0),
6178c2ecf20Sopenharmony_ci	.src_alpha_ctl = VOP_REG(RK3288_WIN2_SRC_ALPHA_CTRL, 0xff, 0),
6188c2ecf20Sopenharmony_ci	.dst_alpha_ctl = VOP_REG(RK3288_WIN2_DST_ALPHA_CTRL, 0xff, 0),
6198c2ecf20Sopenharmony_ci};
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_cistatic const struct vop_modeset rk3288_modeset = {
6228c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(RK3288_DSP_HTOTAL_HS_END, 0x1fff1fff, 0),
6238c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(RK3288_DSP_HACT_ST_END, 0x1fff1fff, 0),
6248c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(RK3288_DSP_VTOTAL_VS_END, 0x1fff1fff, 0),
6258c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(RK3288_DSP_VACT_ST_END, 0x1fff1fff, 0),
6268c2ecf20Sopenharmony_ci	.hpost_st_end = VOP_REG(RK3288_POST_DSP_HACT_INFO, 0x1fff1fff, 0),
6278c2ecf20Sopenharmony_ci	.vpost_st_end = VOP_REG(RK3288_POST_DSP_VACT_INFO, 0x1fff1fff, 0),
6288c2ecf20Sopenharmony_ci};
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_cistatic const struct vop_output rk3288_output = {
6318c2ecf20Sopenharmony_ci	.pin_pol = VOP_REG(RK3288_DSP_CTRL0, 0xf, 4),
6328c2ecf20Sopenharmony_ci	.rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12),
6338c2ecf20Sopenharmony_ci	.hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13),
6348c2ecf20Sopenharmony_ci	.edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14),
6358c2ecf20Sopenharmony_ci	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
6368c2ecf20Sopenharmony_ci};
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_cistatic const struct vop_common rk3288_common = {
6398c2ecf20Sopenharmony_ci	.standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22),
6408c2ecf20Sopenharmony_ci	.gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23),
6418c2ecf20Sopenharmony_ci	.mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20),
6428c2ecf20Sopenharmony_ci	.dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4),
6438c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3),
6448c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2),
6458c2ecf20Sopenharmony_ci	.pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1),
6468c2ecf20Sopenharmony_ci	.dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6),
6478c2ecf20Sopenharmony_ci	.dsp_lut_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 0),
6488c2ecf20Sopenharmony_ci	.data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19),
6498c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18),
6508c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(RK3288_DSP_CTRL0, 0xf, 0),
6518c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG_SYNC(RK3288_REG_CFG_DONE, 0x1, 0),
6528c2ecf20Sopenharmony_ci};
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci/*
6558c2ecf20Sopenharmony_ci * Note: rk3288 has a dedicated 'cursor' window, however, that window requires
6568c2ecf20Sopenharmony_ci * special support to get alpha blending working.  For now, just use overlay
6578c2ecf20Sopenharmony_ci * window 3 for the drm cursor.
6588c2ecf20Sopenharmony_ci *
6598c2ecf20Sopenharmony_ci */
6608c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3288_vop_win_data[] = {
6618c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3288_win01_data,
6628c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
6638c2ecf20Sopenharmony_ci	{ .base = 0x40, .phy = &rk3288_win01_data,
6648c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
6658c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3288_win23_data,
6668c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
6678c2ecf20Sopenharmony_ci	{ .base = 0x50, .phy = &rk3288_win23_data,
6688c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
6698c2ecf20Sopenharmony_ci};
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_cistatic const int rk3288_vop_intrs[] = {
6728c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
6738c2ecf20Sopenharmony_ci	FS_INTR,
6748c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
6758c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
6768c2ecf20Sopenharmony_ci};
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_cistatic const struct vop_intr rk3288_vop_intr = {
6798c2ecf20Sopenharmony_ci	.intrs = rk3288_vop_intrs,
6808c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3288_vop_intrs),
6818c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3288_INTR_CTRL0, 0x1fff, 12),
6828c2ecf20Sopenharmony_ci	.status = VOP_REG(RK3288_INTR_CTRL0, 0xf, 0),
6838c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3288_INTR_CTRL0, 0xf, 4),
6848c2ecf20Sopenharmony_ci	.clear = VOP_REG(RK3288_INTR_CTRL0, 0xf, 8),
6858c2ecf20Sopenharmony_ci};
6868c2ecf20Sopenharmony_ci
6878c2ecf20Sopenharmony_cistatic const struct vop_data rk3288_vop = {
6888c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 1),
6898c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_OUTPUT_RGB10,
6908c2ecf20Sopenharmony_ci	.intr = &rk3288_vop_intr,
6918c2ecf20Sopenharmony_ci	.common = &rk3288_common,
6928c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
6938c2ecf20Sopenharmony_ci	.output = &rk3288_output,
6948c2ecf20Sopenharmony_ci	.win = rk3288_vop_win_data,
6958c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3288_vop_win_data),
6968c2ecf20Sopenharmony_ci	.lut_size = 1024,
6978c2ecf20Sopenharmony_ci};
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_cistatic const int rk3368_vop_intrs[] = {
7008c2ecf20Sopenharmony_ci	FS_INTR,
7018c2ecf20Sopenharmony_ci	0, 0,
7028c2ecf20Sopenharmony_ci	LINE_FLAG_INTR,
7038c2ecf20Sopenharmony_ci	0,
7048c2ecf20Sopenharmony_ci	BUS_ERROR_INTR,
7058c2ecf20Sopenharmony_ci	0, 0, 0, 0, 0, 0, 0,
7068c2ecf20Sopenharmony_ci	DSP_HOLD_VALID_INTR,
7078c2ecf20Sopenharmony_ci};
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_cistatic const struct vop_intr rk3368_vop_intr = {
7108c2ecf20Sopenharmony_ci	.intrs = rk3368_vop_intrs,
7118c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3368_vop_intrs),
7128c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3368_LINE_FLAG, 0xffff, 0),
7138c2ecf20Sopenharmony_ci	.line_flag_num[1] = VOP_REG(RK3368_LINE_FLAG, 0xffff, 16),
7148c2ecf20Sopenharmony_ci	.status = VOP_REG_MASK_SYNC(RK3368_INTR_STATUS, 0x3fff, 0),
7158c2ecf20Sopenharmony_ci	.enable = VOP_REG_MASK_SYNC(RK3368_INTR_EN, 0x3fff, 0),
7168c2ecf20Sopenharmony_ci	.clear = VOP_REG_MASK_SYNC(RK3368_INTR_CLEAR, 0x3fff, 0),
7178c2ecf20Sopenharmony_ci};
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3368_win01_data = {
7208c2ecf20Sopenharmony_ci	.scl = &rk3288_win_full_scl,
7218c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
7228c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
7238c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full,
7248c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 0),
7258c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3368_WIN0_CTRL0, 0x7, 1),
7268c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 12),
7278c2ecf20Sopenharmony_ci	.x_mir_en = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 21),
7288c2ecf20Sopenharmony_ci	.y_mir_en = VOP_REG(RK3368_WIN0_CTRL0, 0x1, 22),
7298c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3368_WIN0_ACT_INFO, 0x1fff1fff, 0),
7308c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3368_WIN0_DSP_INFO, 0x0fff0fff, 0),
7318c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3368_WIN0_DSP_ST, 0x1fff1fff, 0),
7328c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3368_WIN0_YRGB_MST, 0xffffffff, 0),
7338c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3368_WIN0_CBR_MST, 0xffffffff, 0),
7348c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3368_WIN0_VIR, 0x3fff, 0),
7358c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3368_WIN0_VIR, 0x3fff, 16),
7368c2ecf20Sopenharmony_ci	.src_alpha_ctl = VOP_REG(RK3368_WIN0_SRC_ALPHA_CTRL, 0xff, 0),
7378c2ecf20Sopenharmony_ci	.dst_alpha_ctl = VOP_REG(RK3368_WIN0_DST_ALPHA_CTRL, 0xff, 0),
7388c2ecf20Sopenharmony_ci	.channel = VOP_REG(RK3368_WIN0_CTRL2, 0xff, 0),
7398c2ecf20Sopenharmony_ci};
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3368_win23_data = {
7428c2ecf20Sopenharmony_ci	.data_formats = formats_win_lite,
7438c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_lite),
7448c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_lite,
7458c2ecf20Sopenharmony_ci	.gate = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 0),
7468c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 4),
7478c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3368_WIN2_CTRL0, 0x3, 5),
7488c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3368_WIN2_CTRL0, 0x1, 20),
7498c2ecf20Sopenharmony_ci	.y_mir_en = VOP_REG(RK3368_WIN2_CTRL1, 0x1, 15),
7508c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3368_WIN2_DSP_INFO0, 0x0fff0fff, 0),
7518c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3368_WIN2_DSP_ST0, 0x1fff1fff, 0),
7528c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3368_WIN2_MST0, 0xffffffff, 0),
7538c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3368_WIN2_VIR0_1, 0x1fff, 0),
7548c2ecf20Sopenharmony_ci	.src_alpha_ctl = VOP_REG(RK3368_WIN2_SRC_ALPHA_CTRL, 0xff, 0),
7558c2ecf20Sopenharmony_ci	.dst_alpha_ctl = VOP_REG(RK3368_WIN2_DST_ALPHA_CTRL, 0xff, 0),
7568c2ecf20Sopenharmony_ci};
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3368_vop_win_data[] = {
7598c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3368_win01_data,
7608c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
7618c2ecf20Sopenharmony_ci	{ .base = 0x40, .phy = &rk3368_win01_data,
7628c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
7638c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3368_win23_data,
7648c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
7658c2ecf20Sopenharmony_ci	{ .base = 0x50, .phy = &rk3368_win23_data,
7668c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
7678c2ecf20Sopenharmony_ci};
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_cistatic const struct vop_output rk3368_output = {
7708c2ecf20Sopenharmony_ci	.rgb_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 19),
7718c2ecf20Sopenharmony_ci	.hdmi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 23),
7728c2ecf20Sopenharmony_ci	.edp_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 27),
7738c2ecf20Sopenharmony_ci	.mipi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 31),
7748c2ecf20Sopenharmony_ci	.rgb_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 16),
7758c2ecf20Sopenharmony_ci	.hdmi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 20),
7768c2ecf20Sopenharmony_ci	.edp_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 24),
7778c2ecf20Sopenharmony_ci	.mipi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 28),
7788c2ecf20Sopenharmony_ci	.rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12),
7798c2ecf20Sopenharmony_ci	.hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13),
7808c2ecf20Sopenharmony_ci	.edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14),
7818c2ecf20Sopenharmony_ci	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
7828c2ecf20Sopenharmony_ci};
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_cistatic const struct vop_misc rk3368_misc = {
7858c2ecf20Sopenharmony_ci	.global_regdone_en = VOP_REG(RK3368_SYS_CTRL, 0x1, 11),
7868c2ecf20Sopenharmony_ci};
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_cistatic const struct vop_data rk3368_vop = {
7898c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 2),
7908c2ecf20Sopenharmony_ci	.intr = &rk3368_vop_intr,
7918c2ecf20Sopenharmony_ci	.common = &rk3288_common,
7928c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
7938c2ecf20Sopenharmony_ci	.output = &rk3368_output,
7948c2ecf20Sopenharmony_ci	.misc = &rk3368_misc,
7958c2ecf20Sopenharmony_ci	.win = rk3368_vop_win_data,
7968c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
7978c2ecf20Sopenharmony_ci};
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_cistatic const struct vop_intr rk3366_vop_intr = {
8008c2ecf20Sopenharmony_ci	.intrs = rk3368_vop_intrs,
8018c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3368_vop_intrs),
8028c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3366_LINE_FLAG, 0xffff, 0),
8038c2ecf20Sopenharmony_ci	.line_flag_num[1] = VOP_REG(RK3366_LINE_FLAG, 0xffff, 16),
8048c2ecf20Sopenharmony_ci	.status = VOP_REG_MASK_SYNC(RK3366_INTR_STATUS0, 0xffff, 0),
8058c2ecf20Sopenharmony_ci	.enable = VOP_REG_MASK_SYNC(RK3366_INTR_EN0, 0xffff, 0),
8068c2ecf20Sopenharmony_ci	.clear = VOP_REG_MASK_SYNC(RK3366_INTR_CLEAR0, 0xffff, 0),
8078c2ecf20Sopenharmony_ci};
8088c2ecf20Sopenharmony_ci
8098c2ecf20Sopenharmony_cistatic const struct vop_data rk3366_vop = {
8108c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 4),
8118c2ecf20Sopenharmony_ci	.intr = &rk3366_vop_intr,
8128c2ecf20Sopenharmony_ci	.common = &rk3288_common,
8138c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
8148c2ecf20Sopenharmony_ci	.output = &rk3368_output,
8158c2ecf20Sopenharmony_ci	.misc = &rk3368_misc,
8168c2ecf20Sopenharmony_ci	.win = rk3368_vop_win_data,
8178c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
8188c2ecf20Sopenharmony_ci};
8198c2ecf20Sopenharmony_ci
8208c2ecf20Sopenharmony_cistatic const struct vop_output rk3399_output = {
8218c2ecf20Sopenharmony_ci	.dp_dclk_pol = VOP_REG(RK3399_DSP_CTRL1, 0x1, 19),
8228c2ecf20Sopenharmony_ci	.rgb_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 19),
8238c2ecf20Sopenharmony_ci	.hdmi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 23),
8248c2ecf20Sopenharmony_ci	.edp_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 27),
8258c2ecf20Sopenharmony_ci	.mipi_dclk_pol = VOP_REG(RK3368_DSP_CTRL1, 0x1, 31),
8268c2ecf20Sopenharmony_ci	.dp_pin_pol = VOP_REG(RK3399_DSP_CTRL1, 0x7, 16),
8278c2ecf20Sopenharmony_ci	.rgb_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 16),
8288c2ecf20Sopenharmony_ci	.hdmi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 20),
8298c2ecf20Sopenharmony_ci	.edp_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 24),
8308c2ecf20Sopenharmony_ci	.mipi_pin_pol = VOP_REG(RK3368_DSP_CTRL1, 0x7, 28),
8318c2ecf20Sopenharmony_ci	.dp_en = VOP_REG(RK3399_SYS_CTRL, 0x1, 11),
8328c2ecf20Sopenharmony_ci	.rgb_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 12),
8338c2ecf20Sopenharmony_ci	.hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13),
8348c2ecf20Sopenharmony_ci	.edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14),
8358c2ecf20Sopenharmony_ci	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
8368c2ecf20Sopenharmony_ci	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
8378c2ecf20Sopenharmony_ci};
8388c2ecf20Sopenharmony_ci
8398c2ecf20Sopenharmony_cistatic const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
8408c2ecf20Sopenharmony_ci	.y2r_coefficients = {
8418c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
8428c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
8438c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
8448c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
8458c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
8468c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
8478c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
8488c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
8498c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
8508c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
8518c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
8528c2ecf20Sopenharmony_ci		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
8538c2ecf20Sopenharmony_ci	},
8548c2ecf20Sopenharmony_ci};
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_cistatic const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
8578c2ecf20Sopenharmony_ci
8588c2ecf20Sopenharmony_cistatic const struct vop_win_yuv2yuv_data rk3399_vop_big_win_yuv2yuv_data[] = {
8598c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
8608c2ecf20Sopenharmony_ci	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1) },
8618c2ecf20Sopenharmony_ci	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win01_data,
8628c2ecf20Sopenharmony_ci	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9) },
8638c2ecf20Sopenharmony_ci	{ .base = 0xC0, .phy = &rk3399_yuv2yuv_win23_data },
8648c2ecf20Sopenharmony_ci	{ .base = 0x120, .phy = &rk3399_yuv2yuv_win23_data },
8658c2ecf20Sopenharmony_ci
8668c2ecf20Sopenharmony_ci};
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_cistatic const struct vop_win_phy rk3399_win01_data = {
8698c2ecf20Sopenharmony_ci	.scl = &rk3288_win_full_scl,
8708c2ecf20Sopenharmony_ci	.data_formats = formats_win_full,
8718c2ecf20Sopenharmony_ci	.nformats = ARRAY_SIZE(formats_win_full),
8728c2ecf20Sopenharmony_ci	.format_modifiers = format_modifiers_win_full_afbc,
8738c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 0),
8748c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3288_WIN0_CTRL0, 0x7, 1),
8758c2ecf20Sopenharmony_ci	.rb_swap = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 12),
8768c2ecf20Sopenharmony_ci	.x_mir_en = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 21),
8778c2ecf20Sopenharmony_ci	.y_mir_en = VOP_REG(RK3288_WIN0_CTRL0, 0x1, 22),
8788c2ecf20Sopenharmony_ci	.act_info = VOP_REG(RK3288_WIN0_ACT_INFO, 0x1fff1fff, 0),
8798c2ecf20Sopenharmony_ci	.dsp_info = VOP_REG(RK3288_WIN0_DSP_INFO, 0x0fff0fff, 0),
8808c2ecf20Sopenharmony_ci	.dsp_st = VOP_REG(RK3288_WIN0_DSP_ST, 0x1fff1fff, 0),
8818c2ecf20Sopenharmony_ci	.yrgb_mst = VOP_REG(RK3288_WIN0_YRGB_MST, 0xffffffff, 0),
8828c2ecf20Sopenharmony_ci	.uv_mst = VOP_REG(RK3288_WIN0_CBR_MST, 0xffffffff, 0),
8838c2ecf20Sopenharmony_ci	.yrgb_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 0),
8848c2ecf20Sopenharmony_ci	.uv_vir = VOP_REG(RK3288_WIN0_VIR, 0x3fff, 16),
8858c2ecf20Sopenharmony_ci	.src_alpha_ctl = VOP_REG(RK3288_WIN0_SRC_ALPHA_CTRL, 0xff, 0),
8868c2ecf20Sopenharmony_ci	.dst_alpha_ctl = VOP_REG(RK3288_WIN0_DST_ALPHA_CTRL, 0xff, 0),
8878c2ecf20Sopenharmony_ci	.channel = VOP_REG(RK3288_WIN0_CTRL2, 0xff, 0),
8888c2ecf20Sopenharmony_ci};
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci/*
8918c2ecf20Sopenharmony_ci * rk3399 vop big windows register layout is same as rk3288, but we
8928c2ecf20Sopenharmony_ci * have a separate rk3399 win data array here so that we can advertise
8938c2ecf20Sopenharmony_ci * AFBC on the primary plane.
8948c2ecf20Sopenharmony_ci */
8958c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3399_vop_win_data[] = {
8968c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3399_win01_data,
8978c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
8988c2ecf20Sopenharmony_ci	{ .base = 0x40, .phy = &rk3368_win01_data,
8998c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
9008c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3368_win23_data,
9018c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
9028c2ecf20Sopenharmony_ci	{ .base = 0x50, .phy = &rk3368_win23_data,
9038c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
9048c2ecf20Sopenharmony_ci};
9058c2ecf20Sopenharmony_ci
9068c2ecf20Sopenharmony_cistatic const struct vop_afbc rk3399_vop_afbc = {
9078c2ecf20Sopenharmony_ci	.rstn = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 3),
9088c2ecf20Sopenharmony_ci	.enable = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 0),
9098c2ecf20Sopenharmony_ci	.win_sel = VOP_REG(RK3399_AFBCD0_CTRL, 0x3, 1),
9108c2ecf20Sopenharmony_ci	.format = VOP_REG(RK3399_AFBCD0_CTRL, 0x1f, 16),
9118c2ecf20Sopenharmony_ci	.hreg_block_split = VOP_REG(RK3399_AFBCD0_CTRL, 0x1, 21),
9128c2ecf20Sopenharmony_ci	.hdr_ptr = VOP_REG(RK3399_AFBCD0_HDR_PTR, 0xffffffff, 0),
9138c2ecf20Sopenharmony_ci	.pic_size = VOP_REG(RK3399_AFBCD0_PIC_SIZE, 0xffffffff, 0),
9148c2ecf20Sopenharmony_ci};
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_cistatic const struct vop_data rk3399_vop_big = {
9178c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 5),
9188c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_OUTPUT_RGB10,
9198c2ecf20Sopenharmony_ci	.intr = &rk3366_vop_intr,
9208c2ecf20Sopenharmony_ci	.common = &rk3288_common,
9218c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
9228c2ecf20Sopenharmony_ci	.output = &rk3399_output,
9238c2ecf20Sopenharmony_ci	.afbc = &rk3399_vop_afbc,
9248c2ecf20Sopenharmony_ci	.misc = &rk3368_misc,
9258c2ecf20Sopenharmony_ci	.win = rk3399_vop_win_data,
9268c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3399_vop_win_data),
9278c2ecf20Sopenharmony_ci	.win_yuv2yuv = rk3399_vop_big_win_yuv2yuv_data,
9288c2ecf20Sopenharmony_ci};
9298c2ecf20Sopenharmony_ci
9308c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3399_vop_lit_win_data[] = {
9318c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3368_win01_data,
9328c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
9338c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3368_win23_data,
9348c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR},
9358c2ecf20Sopenharmony_ci};
9368c2ecf20Sopenharmony_ci
9378c2ecf20Sopenharmony_cistatic const struct vop_win_yuv2yuv_data rk3399_vop_lit_win_yuv2yuv_data[] = {
9388c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
9398c2ecf20Sopenharmony_ci	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1)},
9408c2ecf20Sopenharmony_ci	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win23_data },
9418c2ecf20Sopenharmony_ci};
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_cistatic const struct vop_data rk3399_vop_lit = {
9448c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 6),
9458c2ecf20Sopenharmony_ci	.intr = &rk3366_vop_intr,
9468c2ecf20Sopenharmony_ci	.common = &rk3288_common,
9478c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
9488c2ecf20Sopenharmony_ci	.output = &rk3399_output,
9498c2ecf20Sopenharmony_ci	.misc = &rk3368_misc,
9508c2ecf20Sopenharmony_ci	.win = rk3399_vop_lit_win_data,
9518c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
9528c2ecf20Sopenharmony_ci	.win_yuv2yuv = rk3399_vop_lit_win_yuv2yuv_data,
9538c2ecf20Sopenharmony_ci};
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3228_vop_win_data[] = {
9568c2ecf20Sopenharmony_ci	{ .base = 0x00, .phy = &rk3288_win01_data,
9578c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
9588c2ecf20Sopenharmony_ci	{ .base = 0x40, .phy = &rk3288_win01_data,
9598c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
9608c2ecf20Sopenharmony_ci};
9618c2ecf20Sopenharmony_ci
9628c2ecf20Sopenharmony_cistatic const struct vop_data rk3228_vop = {
9638c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 7),
9648c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_OUTPUT_RGB10,
9658c2ecf20Sopenharmony_ci	.intr = &rk3366_vop_intr,
9668c2ecf20Sopenharmony_ci	.common = &rk3288_common,
9678c2ecf20Sopenharmony_ci	.modeset = &rk3288_modeset,
9688c2ecf20Sopenharmony_ci	.output = &rk3399_output,
9698c2ecf20Sopenharmony_ci	.misc = &rk3368_misc,
9708c2ecf20Sopenharmony_ci	.win = rk3228_vop_win_data,
9718c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3228_vop_win_data),
9728c2ecf20Sopenharmony_ci};
9738c2ecf20Sopenharmony_ci
9748c2ecf20Sopenharmony_cistatic const struct vop_modeset rk3328_modeset = {
9758c2ecf20Sopenharmony_ci	.htotal_pw = VOP_REG(RK3328_DSP_HTOTAL_HS_END, 0x1fff1fff, 0),
9768c2ecf20Sopenharmony_ci	.hact_st_end = VOP_REG(RK3328_DSP_HACT_ST_END, 0x1fff1fff, 0),
9778c2ecf20Sopenharmony_ci	.vtotal_pw = VOP_REG(RK3328_DSP_VTOTAL_VS_END, 0x1fff1fff, 0),
9788c2ecf20Sopenharmony_ci	.vact_st_end = VOP_REG(RK3328_DSP_VACT_ST_END, 0x1fff1fff, 0),
9798c2ecf20Sopenharmony_ci	.hpost_st_end = VOP_REG(RK3328_POST_DSP_HACT_INFO, 0x1fff1fff, 0),
9808c2ecf20Sopenharmony_ci	.vpost_st_end = VOP_REG(RK3328_POST_DSP_VACT_INFO, 0x1fff1fff, 0),
9818c2ecf20Sopenharmony_ci};
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_cistatic const struct vop_output rk3328_output = {
9848c2ecf20Sopenharmony_ci	.rgb_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 19),
9858c2ecf20Sopenharmony_ci	.hdmi_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 23),
9868c2ecf20Sopenharmony_ci	.edp_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 27),
9878c2ecf20Sopenharmony_ci	.mipi_dclk_pol = VOP_REG(RK3328_DSP_CTRL1, 0x1, 31),
9888c2ecf20Sopenharmony_ci	.rgb_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 12),
9898c2ecf20Sopenharmony_ci	.hdmi_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 13),
9908c2ecf20Sopenharmony_ci	.edp_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 14),
9918c2ecf20Sopenharmony_ci	.mipi_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 15),
9928c2ecf20Sopenharmony_ci	.rgb_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 16),
9938c2ecf20Sopenharmony_ci	.hdmi_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 20),
9948c2ecf20Sopenharmony_ci	.edp_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 24),
9958c2ecf20Sopenharmony_ci	.mipi_pin_pol = VOP_REG(RK3328_DSP_CTRL1, 0x7, 28),
9968c2ecf20Sopenharmony_ci};
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_cistatic const struct vop_misc rk3328_misc = {
9998c2ecf20Sopenharmony_ci	.global_regdone_en = VOP_REG(RK3328_SYS_CTRL, 0x1, 11),
10008c2ecf20Sopenharmony_ci};
10018c2ecf20Sopenharmony_ci
10028c2ecf20Sopenharmony_cistatic const struct vop_common rk3328_common = {
10038c2ecf20Sopenharmony_ci	.standby = VOP_REG_SYNC(RK3328_SYS_CTRL, 0x1, 22),
10048c2ecf20Sopenharmony_ci	.dither_down_sel = VOP_REG(RK3328_DSP_CTRL1, 0x1, 4),
10058c2ecf20Sopenharmony_ci	.dither_down_mode = VOP_REG(RK3328_DSP_CTRL1, 0x1, 3),
10068c2ecf20Sopenharmony_ci	.dither_down_en = VOP_REG(RK3328_DSP_CTRL1, 0x1, 2),
10078c2ecf20Sopenharmony_ci	.pre_dither_down = VOP_REG(RK3328_DSP_CTRL1, 0x1, 1),
10088c2ecf20Sopenharmony_ci	.dither_up = VOP_REG(RK3328_DSP_CTRL1, 0x1, 6),
10098c2ecf20Sopenharmony_ci	.dsp_blank = VOP_REG(RK3328_DSP_CTRL0, 0x3, 18),
10108c2ecf20Sopenharmony_ci	.out_mode = VOP_REG(RK3328_DSP_CTRL0, 0xf, 0),
10118c2ecf20Sopenharmony_ci	.cfg_done = VOP_REG_SYNC(RK3328_REG_CFG_DONE, 0x1, 0),
10128c2ecf20Sopenharmony_ci};
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_cistatic const struct vop_intr rk3328_vop_intr = {
10158c2ecf20Sopenharmony_ci	.intrs = rk3368_vop_intrs,
10168c2ecf20Sopenharmony_ci	.nintrs = ARRAY_SIZE(rk3368_vop_intrs),
10178c2ecf20Sopenharmony_ci	.line_flag_num[0] = VOP_REG(RK3328_LINE_FLAG, 0xffff, 0),
10188c2ecf20Sopenharmony_ci	.line_flag_num[1] = VOP_REG(RK3328_LINE_FLAG, 0xffff, 16),
10198c2ecf20Sopenharmony_ci	.status = VOP_REG_MASK_SYNC(RK3328_INTR_STATUS0, 0xffff, 0),
10208c2ecf20Sopenharmony_ci	.enable = VOP_REG_MASK_SYNC(RK3328_INTR_EN0, 0xffff, 0),
10218c2ecf20Sopenharmony_ci	.clear = VOP_REG_MASK_SYNC(RK3328_INTR_CLEAR0, 0xffff, 0),
10228c2ecf20Sopenharmony_ci};
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_cistatic const struct vop_win_data rk3328_vop_win_data[] = {
10258c2ecf20Sopenharmony_ci	{ .base = 0xd0, .phy = &rk3368_win01_data,
10268c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_PRIMARY },
10278c2ecf20Sopenharmony_ci	{ .base = 0x1d0, .phy = &rk3368_win01_data,
10288c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_OVERLAY },
10298c2ecf20Sopenharmony_ci	{ .base = 0x2d0, .phy = &rk3368_win01_data,
10308c2ecf20Sopenharmony_ci	  .type = DRM_PLANE_TYPE_CURSOR },
10318c2ecf20Sopenharmony_ci};
10328c2ecf20Sopenharmony_ci
10338c2ecf20Sopenharmony_cistatic const struct vop_data rk3328_vop = {
10348c2ecf20Sopenharmony_ci	.version = VOP_VERSION(3, 8),
10358c2ecf20Sopenharmony_ci	.feature = VOP_FEATURE_OUTPUT_RGB10,
10368c2ecf20Sopenharmony_ci	.intr = &rk3328_vop_intr,
10378c2ecf20Sopenharmony_ci	.common = &rk3328_common,
10388c2ecf20Sopenharmony_ci	.modeset = &rk3328_modeset,
10398c2ecf20Sopenharmony_ci	.output = &rk3328_output,
10408c2ecf20Sopenharmony_ci	.misc = &rk3328_misc,
10418c2ecf20Sopenharmony_ci	.win = rk3328_vop_win_data,
10428c2ecf20Sopenharmony_ci	.win_size = ARRAY_SIZE(rk3328_vop_win_data),
10438c2ecf20Sopenharmony_ci};
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_cistatic const struct of_device_id vop_driver_dt_match[] = {
10468c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3036-vop",
10478c2ecf20Sopenharmony_ci	  .data = &rk3036_vop },
10488c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3126-vop",
10498c2ecf20Sopenharmony_ci	  .data = &rk3126_vop },
10508c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,px30-vop-big",
10518c2ecf20Sopenharmony_ci	  .data = &px30_vop_big },
10528c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,px30-vop-lit",
10538c2ecf20Sopenharmony_ci	  .data = &px30_vop_lit },
10548c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3066-vop",
10558c2ecf20Sopenharmony_ci	  .data = &rk3066_vop },
10568c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3188-vop",
10578c2ecf20Sopenharmony_ci	  .data = &rk3188_vop },
10588c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3288-vop",
10598c2ecf20Sopenharmony_ci	  .data = &rk3288_vop },
10608c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3368-vop",
10618c2ecf20Sopenharmony_ci	  .data = &rk3368_vop },
10628c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3366-vop",
10638c2ecf20Sopenharmony_ci	  .data = &rk3366_vop },
10648c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3399-vop-big",
10658c2ecf20Sopenharmony_ci	  .data = &rk3399_vop_big },
10668c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3399-vop-lit",
10678c2ecf20Sopenharmony_ci	  .data = &rk3399_vop_lit },
10688c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3228-vop",
10698c2ecf20Sopenharmony_ci	  .data = &rk3228_vop },
10708c2ecf20Sopenharmony_ci	{ .compatible = "rockchip,rk3328-vop",
10718c2ecf20Sopenharmony_ci	  .data = &rk3328_vop },
10728c2ecf20Sopenharmony_ci	{},
10738c2ecf20Sopenharmony_ci};
10748c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, vop_driver_dt_match);
10758c2ecf20Sopenharmony_ci
10768c2ecf20Sopenharmony_cistatic int vop_probe(struct platform_device *pdev)
10778c2ecf20Sopenharmony_ci{
10788c2ecf20Sopenharmony_ci	struct device *dev = &pdev->dev;
10798c2ecf20Sopenharmony_ci
10808c2ecf20Sopenharmony_ci	if (!dev->of_node) {
10818c2ecf20Sopenharmony_ci		DRM_DEV_ERROR(dev, "can't find vop devices\n");
10828c2ecf20Sopenharmony_ci		return -ENODEV;
10838c2ecf20Sopenharmony_ci	}
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_ci	return component_add(dev, &vop_component_ops);
10868c2ecf20Sopenharmony_ci}
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_cistatic int vop_remove(struct platform_device *pdev)
10898c2ecf20Sopenharmony_ci{
10908c2ecf20Sopenharmony_ci	component_del(&pdev->dev, &vop_component_ops);
10918c2ecf20Sopenharmony_ci
10928c2ecf20Sopenharmony_ci	return 0;
10938c2ecf20Sopenharmony_ci}
10948c2ecf20Sopenharmony_ci
10958c2ecf20Sopenharmony_cistruct platform_driver vop_platform_driver = {
10968c2ecf20Sopenharmony_ci	.probe = vop_probe,
10978c2ecf20Sopenharmony_ci	.remove = vop_remove,
10988c2ecf20Sopenharmony_ci	.driver = {
10998c2ecf20Sopenharmony_ci		.name = "rockchip-vop",
11008c2ecf20Sopenharmony_ci		.of_match_table = of_match_ptr(vop_driver_dt_match),
11018c2ecf20Sopenharmony_ci	},
11028c2ecf20Sopenharmony_ci};
1103