1*77d9e1e6SNeil Armstrong /* SPDX-License-Identifier: GPL-2.0-or-later */
2*77d9e1e6SNeil Armstrong /*
3*77d9e1e6SNeil Armstrong  * Copyright (C) 2020 BayLibre, SAS
4*77d9e1e6SNeil Armstrong  * Author: Neil Armstrong <narmstrong@baylibre.com>
5*77d9e1e6SNeil Armstrong  * Copyright (C) 2018 Amlogic, Inc. All rights reserved.
6*77d9e1e6SNeil Armstrong  */
7*77d9e1e6SNeil Armstrong 
8*77d9e1e6SNeil Armstrong #ifndef __MESON_DW_MIPI_DSI_H
9*77d9e1e6SNeil Armstrong #define __MESON_DW_MIPI_DSI_H
10*77d9e1e6SNeil Armstrong 
11*77d9e1e6SNeil Armstrong /* Top-level registers */
12*77d9e1e6SNeil Armstrong /* [31: 4]    Reserved.     Default 0.
13*77d9e1e6SNeil Armstrong  *     [3] RW timing_rst_n: Default 1.
14*77d9e1e6SNeil Armstrong  *		1=Assert SW reset of timing feature.   0=Release reset.
15*77d9e1e6SNeil Armstrong  *     [2] RW dpi_rst_n: Default 1.
16*77d9e1e6SNeil Armstrong  *		1=Assert SW reset on mipi_dsi_host_dpi block.   0=Release reset.
17*77d9e1e6SNeil Armstrong  *     [1] RW intr_rst_n: Default 1.
18*77d9e1e6SNeil Armstrong  *		1=Assert SW reset on mipi_dsi_host_intr block.  0=Release reset.
19*77d9e1e6SNeil Armstrong  *     [0] RW dwc_rst_n:  Default 1.
20*77d9e1e6SNeil Armstrong  *		1=Assert SW reset on IP core.   0=Release reset.
21*77d9e1e6SNeil Armstrong  */
22*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SW_RESET                      0x3c0
23*77d9e1e6SNeil Armstrong 
24*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SW_RESET_DWC	BIT(0)
25*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SW_RESET_INTR	BIT(1)
26*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SW_RESET_DPI	BIT(2)
27*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SW_RESET_TIMING	BIT(3)
28*77d9e1e6SNeil Armstrong 
29*77d9e1e6SNeil Armstrong /* [31: 5] Reserved.   Default 0.
30*77d9e1e6SNeil Armstrong  *     [4] RW manual_edpihalt: Default 0.
31*77d9e1e6SNeil Armstrong  *		1=Manual suspend VencL; 0=do not suspend VencL.
32*77d9e1e6SNeil Armstrong  *     [3] RW auto_edpihalt_en: Default 0.
33*77d9e1e6SNeil Armstrong  *		1=Enable IP's edpihalt signal to suspend VencL;
34*77d9e1e6SNeil Armstrong  *		0=IP's edpihalt signal does not affect VencL.
35*77d9e1e6SNeil Armstrong  *     [2] RW clock_freerun: Apply to auto-clock gate only. Default 0.
36*77d9e1e6SNeil Armstrong  *		0=Default, use auto-clock gating to save power;
37*77d9e1e6SNeil Armstrong  *		1=use free-run clock, disable auto-clock gating, for debug mode.
38*77d9e1e6SNeil Armstrong  *     [1] RW enable_pixclk: A manual clock gate option, due to DWC IP does not
39*77d9e1e6SNeil Armstrong  *		have auto-clock gating. 1=Enable pixclk.      Default 0.
40*77d9e1e6SNeil Armstrong  *     [0] RW enable_sysclk: A manual clock gate option, due to DWC IP does not
41*77d9e1e6SNeil Armstrong  *		have auto-clock gating. 1=Enable sysclk.      Default 0.
42*77d9e1e6SNeil Armstrong  */
43*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_CLK_CNTL                      0x3c4
44*77d9e1e6SNeil Armstrong 
45*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_CLK_SYSCLK_EN	BIT(0)
46*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_CLK_PIXCLK_EN	BIT(1)
47*77d9e1e6SNeil Armstrong 
48*77d9e1e6SNeil Armstrong /* [31:24]    Reserved. Default 0.
49*77d9e1e6SNeil Armstrong  * [23:20] RW dpi_color_mode: Define DPI pixel format. Default 0.
50*77d9e1e6SNeil Armstrong  *		0=16-bit RGB565 config 1;
51*77d9e1e6SNeil Armstrong  *		1=16-bit RGB565 config 2;
52*77d9e1e6SNeil Armstrong  *		2=16-bit RGB565 config 3;
53*77d9e1e6SNeil Armstrong  *		3=18-bit RGB666 config 1;
54*77d9e1e6SNeil Armstrong  *		4=18-bit RGB666 config 2;
55*77d9e1e6SNeil Armstrong  *		5=24-bit RGB888;
56*77d9e1e6SNeil Armstrong  *		6=20-bit YCbCr 4:2:2;
57*77d9e1e6SNeil Armstrong  *		7=24-bit YCbCr 4:2:2;
58*77d9e1e6SNeil Armstrong  *		8=16-bit YCbCr 4:2:2;
59*77d9e1e6SNeil Armstrong  *		9=30-bit RGB;
60*77d9e1e6SNeil Armstrong  *		10=36-bit RGB;
61*77d9e1e6SNeil Armstrong  *		11=12-bit YCbCr 4:2:0.
62*77d9e1e6SNeil Armstrong  *    [19] Reserved. Default 0.
63*77d9e1e6SNeil Armstrong  * [18:16] RW in_color_mode:  Define VENC data width. Default 0.
64*77d9e1e6SNeil Armstrong  *		0=30-bit pixel;
65*77d9e1e6SNeil Armstrong  *		1=24-bit pixel;
66*77d9e1e6SNeil Armstrong  *		2=18-bit pixel, RGB666;
67*77d9e1e6SNeil Armstrong  *		3=16-bit pixel, RGB565.
68*77d9e1e6SNeil Armstrong  * [15:14] RW chroma_subsample: Define method of chroma subsampling. Default 0.
69*77d9e1e6SNeil Armstrong  *		Applicable to YUV422 or YUV420 only.
70*77d9e1e6SNeil Armstrong  *		0=Use even pixel's chroma;
71*77d9e1e6SNeil Armstrong  *		1=Use odd pixel's chroma;
72*77d9e1e6SNeil Armstrong  *		2=Use averaged value between even and odd pair.
73*77d9e1e6SNeil Armstrong  * [13:12] RW comp2_sel:  Select which component to be Cr or B: Default 2.
74*77d9e1e6SNeil Armstrong  *		0=comp0; 1=comp1; 2=comp2.
75*77d9e1e6SNeil Armstrong  * [11:10] RW comp1_sel:  Select which component to be Cb or G: Default 1.
76*77d9e1e6SNeil Armstrong  *		0=comp0; 1=comp1; 2=comp2.
77*77d9e1e6SNeil Armstrong  *  [9: 8] RW comp0_sel:  Select which component to be Y  or R: Default 0.
78*77d9e1e6SNeil Armstrong  *		0=comp0; 1=comp1; 2=comp2.
79*77d9e1e6SNeil Armstrong  *     [7]    Reserved. Default 0.
80*77d9e1e6SNeil Armstrong  *     [6] RW de_pol:  Default 0.
81*77d9e1e6SNeil Armstrong  *		If DE input is active low, set to 1 to invert to active high.
82*77d9e1e6SNeil Armstrong  *     [5] RW hsync_pol: Default 0.
83*77d9e1e6SNeil Armstrong  *		If HS input is active low, set to 1 to invert to active high.
84*77d9e1e6SNeil Armstrong  *     [4] RW vsync_pol: Default 0.
85*77d9e1e6SNeil Armstrong  *		If VS input is active low, set to 1 to invert to active high.
86*77d9e1e6SNeil Armstrong  *     [3] RW dpicolorm: Signal to IP.   Default 0.
87*77d9e1e6SNeil Armstrong  *     [2] RW dpishutdn: Signal to IP.   Default 0.
88*77d9e1e6SNeil Armstrong  *     [1]    Reserved.  Default 0.
89*77d9e1e6SNeil Armstrong  *     [0]    Reserved.  Default 0.
90*77d9e1e6SNeil Armstrong  */
91*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_CNTL                          0x3c8
92*77d9e1e6SNeil Armstrong 
93*77d9e1e6SNeil Armstrong /* VENC data width */
94*77d9e1e6SNeil Armstrong #define VENC_IN_COLOR_30B   0x0
95*77d9e1e6SNeil Armstrong #define VENC_IN_COLOR_24B   0x1
96*77d9e1e6SNeil Armstrong #define VENC_IN_COLOR_18B   0x2
97*77d9e1e6SNeil Armstrong #define VENC_IN_COLOR_16B   0x3
98*77d9e1e6SNeil Armstrong 
99*77d9e1e6SNeil Armstrong /* DPI pixel format */
100*77d9e1e6SNeil Armstrong #define DPI_COLOR_16BIT_CFG_1		0
101*77d9e1e6SNeil Armstrong #define DPI_COLOR_16BIT_CFG_2		1
102*77d9e1e6SNeil Armstrong #define DPI_COLOR_16BIT_CFG_3		2
103*77d9e1e6SNeil Armstrong #define DPI_COLOR_18BIT_CFG_1		3
104*77d9e1e6SNeil Armstrong #define DPI_COLOR_18BIT_CFG_2		4
105*77d9e1e6SNeil Armstrong #define DPI_COLOR_24BIT			5
106*77d9e1e6SNeil Armstrong #define DPI_COLOR_20BIT_YCBCR_422	6
107*77d9e1e6SNeil Armstrong #define DPI_COLOR_24BIT_YCBCR_422	7
108*77d9e1e6SNeil Armstrong #define DPI_COLOR_16BIT_YCBCR_422	8
109*77d9e1e6SNeil Armstrong #define DPI_COLOR_30BIT			9
110*77d9e1e6SNeil Armstrong #define DPI_COLOR_36BIT			10
111*77d9e1e6SNeil Armstrong #define DPI_COLOR_12BIT_YCBCR_420	11
112*77d9e1e6SNeil Armstrong 
113*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_DPI_COLOR_MODE	GENMASK(23, 20)
114*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_IN_COLOR_MODE	GENMASK(18, 16)
115*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_CHROMA_SUBSAMPLE	GENMASK(15, 14)
116*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_COMP2_SEL		GENMASK(13, 12)
117*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_COMP1_SEL		GENMASK(11, 10)
118*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_COMP0_SEL		GENMASK(9, 8)
119*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_DE_INVERT		BIT(6)
120*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_HSYNC_INVERT	BIT(5)
121*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_VSYNC_INVERT	BIT(4)
122*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_DPICOLORM		BIT(3)
123*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_DPISHUTDN		BIT(2)
124*77d9e1e6SNeil Armstrong 
125*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SUSPEND_CNTL                  0x3cc
126*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SUSPEND_LINE                  0x3d0
127*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_SUSPEND_PIX                   0x3d4
128*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEAS_CNTL                     0x3d8
129*77d9e1e6SNeil Armstrong /* [0] R  stat_edpihalt:  edpihalt signal from IP.    Default 0. */
130*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_STAT                          0x3dc
131*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEAS_STAT_TE0                 0x3e0
132*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEAS_STAT_TE1                 0x3e4
133*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEAS_STAT_VS0                 0x3e8
134*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEAS_STAT_VS1                 0x3ec
135*77d9e1e6SNeil Armstrong /* [31:16] RW intr_stat/clr. Default 0.
136*77d9e1e6SNeil Armstrong  *		For each bit, read as this interrupt level status,
137*77d9e1e6SNeil Armstrong  *		write 1 to clear.
138*77d9e1e6SNeil Armstrong  * [31:22] Reserved
139*77d9e1e6SNeil Armstrong  * [   21] stat/clr of eof interrupt
140*77d9e1e6SNeil Armstrong  * [   21] vde_fall interrupt
141*77d9e1e6SNeil Armstrong  * [   19] stat/clr of de_rise interrupt
142*77d9e1e6SNeil Armstrong  * [   18] stat/clr of vs_fall interrupt
143*77d9e1e6SNeil Armstrong  * [   17] stat/clr of vs_rise interrupt
144*77d9e1e6SNeil Armstrong  * [   16] stat/clr of dwc_edpite interrupt
145*77d9e1e6SNeil Armstrong  * [15: 0] RW intr_enable. Default 0.
146*77d9e1e6SNeil Armstrong  *		For each bit, 1=enable this interrupt, 0=disable.
147*77d9e1e6SNeil Armstrong  *	[15: 6] Reserved
148*77d9e1e6SNeil Armstrong  *	[    5] eof interrupt
149*77d9e1e6SNeil Armstrong  *	[    4] de_fall interrupt
150*77d9e1e6SNeil Armstrong  *	[    3] de_rise interrupt
151*77d9e1e6SNeil Armstrong  *	[    2] vs_fall interrupt
152*77d9e1e6SNeil Armstrong  *	[    1] vs_rise interrupt
153*77d9e1e6SNeil Armstrong  *	[    0] dwc_edpite interrupt
154*77d9e1e6SNeil Armstrong  */
155*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_INTR_CNTL_STAT                0x3f0
156*77d9e1e6SNeil Armstrong // 31: 2    Reserved.   Default 0.
157*77d9e1e6SNeil Armstrong //  1: 0 RW mem_pd.     Default 3.
158*77d9e1e6SNeil Armstrong #define MIPI_DSI_TOP_MEM_PD                        0x3f4
159*77d9e1e6SNeil Armstrong 
160*77d9e1e6SNeil Armstrong #endif /* __MESON_DW_MIPI_DSI_H */
161