xref: /openbmc/linux/drivers/gpu/drm/mediatek/mtk_dpi_regs.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
29e629c17SJie Qiu /*
39e629c17SJie Qiu  * Copyright (c) 2014 MediaTek Inc.
49e629c17SJie Qiu  * Author: Jie Qiu <jie.qiu@mediatek.com>
59e629c17SJie Qiu  */
69e629c17SJie Qiu #ifndef __MTK_DPI_REGS_H
79e629c17SJie Qiu #define __MTK_DPI_REGS_H
89e629c17SJie Qiu 
99e629c17SJie Qiu #define DPI_EN			0x00
109e629c17SJie Qiu #define EN				BIT(0)
119e629c17SJie Qiu 
129e629c17SJie Qiu #define DPI_RET			0x04
139e629c17SJie Qiu #define RST				BIT(0)
149e629c17SJie Qiu 
159e629c17SJie Qiu #define DPI_INTEN		0x08
169e629c17SJie Qiu #define INT_VSYNC_EN			BIT(0)
179e629c17SJie Qiu #define INT_VDE_EN			BIT(1)
189e629c17SJie Qiu #define INT_UNDERFLOW_EN		BIT(2)
199e629c17SJie Qiu 
209e629c17SJie Qiu #define DPI_INTSTA		0x0C
219e629c17SJie Qiu #define INT_VSYNC_STA			BIT(0)
229e629c17SJie Qiu #define INT_VDE_STA			BIT(1)
239e629c17SJie Qiu #define INT_UNDERFLOW_STA		BIT(2)
249e629c17SJie Qiu 
259e629c17SJie Qiu #define DPI_CON			0x10
269e629c17SJie Qiu #define BG_ENABLE			BIT(0)
279e629c17SJie Qiu #define IN_RB_SWAP			BIT(1)
289e629c17SJie Qiu #define INTL_EN				BIT(2)
299e629c17SJie Qiu #define TDFP_EN				BIT(3)
309e629c17SJie Qiu #define CLPF_EN				BIT(4)
319e629c17SJie Qiu #define YUV422_EN			BIT(5)
329e629c17SJie Qiu #define CSC_ENABLE			BIT(6)
339e629c17SJie Qiu #define R601_SEL			BIT(7)
349e629c17SJie Qiu #define EMBSYNC_EN			BIT(8)
359e629c17SJie Qiu #define VS_LODD_EN			BIT(16)
369e629c17SJie Qiu #define VS_LEVEN_EN			BIT(17)
379e629c17SJie Qiu #define VS_RODD_EN			BIT(18)
389e629c17SJie Qiu #define VS_REVEN			BIT(19)
399e629c17SJie Qiu #define FAKE_DE_LODD			BIT(20)
409e629c17SJie Qiu #define FAKE_DE_LEVEN			BIT(21)
419e629c17SJie Qiu #define FAKE_DE_RODD			BIT(22)
429e629c17SJie Qiu #define FAKE_DE_REVEN			BIT(23)
43*d86c1568SGuillaume Ranquet #define DPINTF_YUV422_EN		BIT(24)
44*d86c1568SGuillaume Ranquet #define DPINTF_CSC_ENABLE		BIT(26)
452587d895SBo-Chen Chen #define DPINTF_INPUT_2P_EN		BIT(29)
469e629c17SJie Qiu 
479e629c17SJie Qiu #define DPI_OUTPUT_SETTING	0x14
489e629c17SJie Qiu #define CH_SWAP				0
49*d86c1568SGuillaume Ranquet #define DPINTF_CH_SWAP			1
509e629c17SJie Qiu #define CH_SWAP_MASK			(0x7 << 0)
519e629c17SJie Qiu #define SWAP_RGB			0x00
529e629c17SJie Qiu #define SWAP_GBR			0x01
539e629c17SJie Qiu #define SWAP_BRG			0x02
549e629c17SJie Qiu #define SWAP_RBG			0x03
559e629c17SJie Qiu #define SWAP_GRB			0x04
569e629c17SJie Qiu #define SWAP_BGR			0x05
579e629c17SJie Qiu #define BIT_SWAP			BIT(3)
589e629c17SJie Qiu #define B_MASK				BIT(4)
599e629c17SJie Qiu #define G_MASK				BIT(5)
609e629c17SJie Qiu #define R_MASK				BIT(6)
619e629c17SJie Qiu #define DE_MASK				BIT(8)
629e629c17SJie Qiu #define HS_MASK				BIT(9)
639e629c17SJie Qiu #define VS_MASK				BIT(10)
649e629c17SJie Qiu #define DE_POL				BIT(12)
659e629c17SJie Qiu #define HSYNC_POL			BIT(13)
669e629c17SJie Qiu #define VSYNC_POL			BIT(14)
679e629c17SJie Qiu #define CK_POL				BIT(15)
689e629c17SJie Qiu #define OEN_OFF				BIT(16)
699e629c17SJie Qiu #define EDGE_SEL			BIT(17)
709e629c17SJie Qiu #define OUT_BIT				18
719e629c17SJie Qiu #define OUT_BIT_MASK			(0x3 << 18)
729e629c17SJie Qiu #define OUT_BIT_8			0x00
739e629c17SJie Qiu #define OUT_BIT_10			0x01
749e629c17SJie Qiu #define OUT_BIT_12			0x02
759e629c17SJie Qiu #define OUT_BIT_16			0x03
769e629c17SJie Qiu #define YC_MAP				20
779e629c17SJie Qiu #define YC_MAP_MASK			(0x7 << 20)
789e629c17SJie Qiu #define YC_MAP_RGB			0x00
799e629c17SJie Qiu #define YC_MAP_CYCY			0x04
809e629c17SJie Qiu #define YC_MAP_YCYC			0x05
819e629c17SJie Qiu #define YC_MAP_CY			0x06
829e629c17SJie Qiu #define YC_MAP_YC			0x07
839e629c17SJie Qiu 
849e629c17SJie Qiu #define DPI_SIZE		0x18
859e629c17SJie Qiu #define HSIZE				0
869e629c17SJie Qiu #define HSIZE_MASK			(0x1FFF << 0)
87*d86c1568SGuillaume Ranquet #define DPINTF_HSIZE_MASK		(0xFFFF << 0)
889e629c17SJie Qiu #define VSIZE				16
899e629c17SJie Qiu #define VSIZE_MASK			(0x1FFF << 16)
90*d86c1568SGuillaume Ranquet #define DPINTF_VSIZE_MASK		(0xFFFF << 16)
919e629c17SJie Qiu 
929e629c17SJie Qiu #define DPI_DDR_SETTING		0x1C
939e629c17SJie Qiu #define DDR_EN				BIT(0)
949e629c17SJie Qiu #define DDDR_SEL			BIT(1)
959e629c17SJie Qiu #define DDR_4PHASE			BIT(2)
969e629c17SJie Qiu #define DDR_WIDTH			(0x3 << 4)
979e629c17SJie Qiu #define DDR_PAD_MODE			(0x1 << 8)
989e629c17SJie Qiu 
999e629c17SJie Qiu #define DPI_TGEN_HWIDTH		0x20
1009e629c17SJie Qiu #define HPW				0
1019e629c17SJie Qiu #define HPW_MASK			(0xFFF << 0)
102*d86c1568SGuillaume Ranquet #define DPINTF_HPW_MASK			(0xFFFF << 0)
1039e629c17SJie Qiu 
1049e629c17SJie Qiu #define DPI_TGEN_HPORCH		0x24
1059e629c17SJie Qiu #define HBP				0
1069e629c17SJie Qiu #define HBP_MASK			(0xFFF << 0)
107*d86c1568SGuillaume Ranquet #define DPINTF_HBP_MASK			(0xFFFF << 0)
1089e629c17SJie Qiu #define HFP				16
1099e629c17SJie Qiu #define HFP_MASK			(0xFFF << 16)
110*d86c1568SGuillaume Ranquet #define DPINTF_HFP_MASK			(0xFFFF << 16)
1119e629c17SJie Qiu 
1129e629c17SJie Qiu #define DPI_TGEN_VWIDTH		0x28
1139e629c17SJie Qiu #define DPI_TGEN_VPORCH		0x2C
1149e629c17SJie Qiu 
1159e629c17SJie Qiu #define VSYNC_WIDTH_SHIFT		0
1169e629c17SJie Qiu #define VSYNC_WIDTH_MASK		(0xFFF << 0)
117*d86c1568SGuillaume Ranquet #define DPINTF_VSYNC_WIDTH_MASK		(0xFFFF << 0)
1189e629c17SJie Qiu #define VSYNC_HALF_LINE_SHIFT		16
1199e629c17SJie Qiu #define VSYNC_HALF_LINE_MASK		BIT(16)
1209e629c17SJie Qiu #define VSYNC_BACK_PORCH_SHIFT		0
1219e629c17SJie Qiu #define VSYNC_BACK_PORCH_MASK		(0xFFF << 0)
122*d86c1568SGuillaume Ranquet #define DPINTF_VSYNC_BACK_PORCH_MASK	(0xFFFF << 0)
1239e629c17SJie Qiu #define VSYNC_FRONT_PORCH_SHIFT		16
1249e629c17SJie Qiu #define VSYNC_FRONT_PORCH_MASK		(0xFFF << 16)
125*d86c1568SGuillaume Ranquet #define DPINTF_VSYNC_FRONT_PORCH_MASK	(0xFFFF << 16)
1269e629c17SJie Qiu 
1279e629c17SJie Qiu #define DPI_BG_HCNTL		0x30
1289e629c17SJie Qiu #define BG_RIGHT			(0x1FFF << 0)
1299e629c17SJie Qiu #define BG_LEFT				(0x1FFF << 16)
1309e629c17SJie Qiu 
1319e629c17SJie Qiu #define DPI_BG_VCNTL		0x34
1329e629c17SJie Qiu #define BG_BOT				(0x1FFF << 0)
1339e629c17SJie Qiu #define BG_TOP				(0x1FFF << 16)
1349e629c17SJie Qiu 
1359e629c17SJie Qiu #define DPI_BG_COLOR		0x38
1369e629c17SJie Qiu #define BG_B				(0xF << 0)
1379e629c17SJie Qiu #define BG_G				(0xF << 8)
1389e629c17SJie Qiu #define BG_R				(0xF << 16)
1399e629c17SJie Qiu 
1409e629c17SJie Qiu #define DPI_FIFO_CTL		0x3C
1419e629c17SJie Qiu #define FIFO_VALID_SET			(0x1F << 0)
1429e629c17SJie Qiu #define FIFO_RST_SEL			(0x1 << 8)
1439e629c17SJie Qiu 
1449e629c17SJie Qiu #define DPI_STATUS		0x40
1459e629c17SJie Qiu #define VCOUNTER			(0x1FFF << 0)
1469e629c17SJie Qiu #define DPI_BUSY			BIT(16)
1479e629c17SJie Qiu #define OUTEN				BIT(17)
1489e629c17SJie Qiu #define FIELD				BIT(20)
1499e629c17SJie Qiu #define TDLR				BIT(21)
1509e629c17SJie Qiu 
1519e629c17SJie Qiu #define DPI_TMODE		0x44
1529e629c17SJie Qiu #define DPI_OEN_ON			BIT(0)
1539e629c17SJie Qiu 
1549e629c17SJie Qiu #define DPI_CHECKSUM		0x48
1559e629c17SJie Qiu #define DPI_CHECKSUM_MASK		(0xFFFFFF << 0)
1569e629c17SJie Qiu #define DPI_CHECKSUM_READY		BIT(30)
1579e629c17SJie Qiu #define DPI_CHECKSUM_EN			BIT(31)
1589e629c17SJie Qiu 
1599e629c17SJie Qiu #define DPI_DUMMY		0x50
1609e629c17SJie Qiu #define DPI_DUMMY_MASK			(0xFFFFFFFF << 0)
1619e629c17SJie Qiu 
1629e629c17SJie Qiu #define DPI_TGEN_VWIDTH_LEVEN	0x68
1639e629c17SJie Qiu #define DPI_TGEN_VPORCH_LEVEN	0x6C
1649e629c17SJie Qiu #define DPI_TGEN_VWIDTH_RODD	0x70
1659e629c17SJie Qiu #define DPI_TGEN_VPORCH_RODD	0x74
1669e629c17SJie Qiu #define DPI_TGEN_VWIDTH_REVEN	0x78
1679e629c17SJie Qiu #define DPI_TGEN_VPORCH_REVEN	0x7C
1689e629c17SJie Qiu 
1699e629c17SJie Qiu #define DPI_ESAV_VTIMING_LODD	0x80
1709e629c17SJie Qiu #define ESAV_VOFST_LODD			(0xFFF << 0)
1719e629c17SJie Qiu #define ESAV_VWID_LODD			(0xFFF << 16)
1729e629c17SJie Qiu 
1739e629c17SJie Qiu #define DPI_ESAV_VTIMING_LEVEN	0x84
1749e629c17SJie Qiu #define ESAV_VOFST_LEVEN		(0xFFF << 0)
1759e629c17SJie Qiu #define ESAV_VWID_LEVEN			(0xFFF << 16)
1769e629c17SJie Qiu 
1779e629c17SJie Qiu #define DPI_ESAV_VTIMING_RODD	0x88
1789e629c17SJie Qiu #define ESAV_VOFST_RODD			(0xFFF << 0)
1799e629c17SJie Qiu #define ESAV_VWID_RODD			(0xFFF << 16)
1809e629c17SJie Qiu 
1819e629c17SJie Qiu #define DPI_ESAV_VTIMING_REVEN	0x8C
1829e629c17SJie Qiu #define ESAV_VOFST_REVEN		(0xFFF << 0)
1839e629c17SJie Qiu #define ESAV_VWID_REVEN			(0xFFF << 16)
1849e629c17SJie Qiu 
1859e629c17SJie Qiu #define DPI_ESAV_FTIMING	0x90
1869e629c17SJie Qiu #define ESAV_FOFST_ODD			(0xFFF << 0)
1879e629c17SJie Qiu #define ESAV_FOFST_EVEN			(0xFFF << 16)
1889e629c17SJie Qiu 
1899e629c17SJie Qiu #define DPI_CLPF_SETTING	0x94
1909e629c17SJie Qiu #define CLPF_TYPE			(0x3 << 0)
1919e629c17SJie Qiu #define ROUND_EN			BIT(4)
1929e629c17SJie Qiu 
1939e629c17SJie Qiu #define DPI_Y_LIMIT		0x98
1949e629c17SJie Qiu #define Y_LIMINT_BOT			0
1959e629c17SJie Qiu #define Y_LIMINT_BOT_MASK		(0xFFF << 0)
1969e629c17SJie Qiu #define Y_LIMINT_TOP			16
1979e629c17SJie Qiu #define Y_LIMINT_TOP_MASK		(0xFFF << 16)
1989e629c17SJie Qiu 
1999e629c17SJie Qiu #define DPI_C_LIMIT		0x9C
2009e629c17SJie Qiu #define C_LIMIT_BOT			0
2019e629c17SJie Qiu #define C_LIMIT_BOT_MASK		(0xFFF << 0)
2029e629c17SJie Qiu #define C_LIMIT_TOP			16
2039e629c17SJie Qiu #define C_LIMIT_TOP_MASK		(0xFFF << 16)
2049e629c17SJie Qiu 
2059e629c17SJie Qiu #define DPI_YUV422_SETTING	0xA0
2069e629c17SJie Qiu #define UV_SWAP				BIT(0)
2079e629c17SJie Qiu #define CR_DELSEL			BIT(4)
2089e629c17SJie Qiu #define CB_DELSEL			BIT(5)
2099e629c17SJie Qiu #define Y_DELSEL			BIT(6)
2109e629c17SJie Qiu #define DE_DELSEL			BIT(7)
2119e629c17SJie Qiu 
2129e629c17SJie Qiu #define DPI_EMBSYNC_SETTING	0xA4
2139e629c17SJie Qiu #define EMBSYNC_R_CR_EN			BIT(0)
2149e629c17SJie Qiu #define EMPSYNC_G_Y_EN			BIT(1)
2159e629c17SJie Qiu #define EMPSYNC_B_CB_EN			BIT(2)
2169e629c17SJie Qiu #define ESAV_F_INV			BIT(4)
2179e629c17SJie Qiu #define ESAV_V_INV			BIT(5)
2189e629c17SJie Qiu #define ESAV_H_INV			BIT(6)
2199e629c17SJie Qiu #define ESAV_CODE_MAN			BIT(8)
2209e629c17SJie Qiu #define VS_OUT_SEL			(0x7 << 12)
2219e629c17SJie Qiu 
2229e629c17SJie Qiu #define DPI_ESAV_CODE_SET0	0xA8
2239e629c17SJie Qiu #define ESAV_CODE0			(0xFFF << 0)
2249e629c17SJie Qiu #define ESAV_CODE1			(0xFFF << 16)
2259e629c17SJie Qiu 
2269e629c17SJie Qiu #define DPI_ESAV_CODE_SET1	0xAC
2279e629c17SJie Qiu #define ESAV_CODE2			(0xFFF << 0)
2289e629c17SJie Qiu #define ESAV_CODE3_MSB			BIT(16)
2299e629c17SJie Qiu 
23079080159Schunhui dai #define EDGE_SEL_EN			BIT(5)
2319e629c17SJie Qiu #define H_FRE_2N			BIT(25)
232b992131aSBo-Chen Chen 
233b992131aSBo-Chen Chen #define DPI_MATRIX_SET		0xB4
234b992131aSBo-Chen Chen #define INT_MATRIX_SEL_MASK		GENMASK(4, 0)
235b992131aSBo-Chen Chen #define MATRIX_SEL_RGB_TO_JPEG		0
236b992131aSBo-Chen Chen #define MATRIX_SEL_RGB_TO_BT601		2
237b992131aSBo-Chen Chen 
2389e629c17SJie Qiu #endif /* __MTK_DPI_REGS_H */
239