xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/sun4i/sun4i_tcon.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2015 Free Electrons
4*4882a593Smuzhiyun  * Copyright (C) 2015 NextThing Co
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Boris Brezillon <boris.brezillon@free-electrons.com>
7*4882a593Smuzhiyun  * Maxime Ripard <maxime.ripard@free-electrons.com>
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #ifndef __SUN4I_TCON_H__
11*4882a593Smuzhiyun #define __SUN4I_TCON_H__
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <drm/drm_crtc.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <linux/kernel.h>
16*4882a593Smuzhiyun #include <linux/list.h>
17*4882a593Smuzhiyun #include <linux/reset.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #define SUN4I_TCON_GCTL_REG			0x0
20*4882a593Smuzhiyun #define SUN4I_TCON_GCTL_TCON_ENABLE			BIT(31)
21*4882a593Smuzhiyun #define SUN4I_TCON_GCTL_IOMAP_MASK			BIT(0)
22*4882a593Smuzhiyun #define SUN4I_TCON_GCTL_IOMAP_TCON1			(1 << 0)
23*4882a593Smuzhiyun #define SUN4I_TCON_GCTL_IOMAP_TCON0			(0 << 0)
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_REG			0x4
26*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_VBLANK_ENABLE(pipe)		BIT(31 - (pipe))
27*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_ENABLE	BIT(27)
28*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_ENABLE	BIT(26)
29*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_VBLANK_INT(pipe)		BIT(15 - (pipe))
30*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_INT		BIT(11)
31*4882a593Smuzhiyun #define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_INT		BIT(10)
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #define SUN4I_TCON_GINT1_REG			0x8
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define SUN4I_TCON_FRM_CTL_REG			0x10
36*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_CTL_EN				BIT(31)
37*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_CTL_MODE_R			BIT(6)
38*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_CTL_MODE_G			BIT(5)
39*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_CTL_MODE_B			BIT(4)
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_PR_REG		0x14
42*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_PG_REG		0x18
43*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_PB_REG		0x1c
44*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_LR_REG		0x20
45*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_LG_REG		0x24
46*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_SEED_LB_REG		0x28
47*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_TBL0_REG		0x2c
48*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_TBL1_REG		0x30
49*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_TBL2_REG		0x34
50*4882a593Smuzhiyun #define SUN4I_TCON0_FRM_TBL3_REG		0x38
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_REG			0x40
53*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_TCON_ENABLE			BIT(31)
54*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_IF_MASK				GENMASK(25, 24)
55*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_IF_8080				(1 << 24)
56*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_CLK_DELAY_MASK			GENMASK(8, 4)
57*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_CLK_DELAY(delay)		((delay << 4) & SUN4I_TCON0_CTL_CLK_DELAY_MASK)
58*4882a593Smuzhiyun #define SUN4I_TCON0_CTL_SRC_SEL_MASK			GENMASK(2, 0)
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #define SUN4I_TCON0_DCLK_REG			0x44
61*4882a593Smuzhiyun #define SUN4I_TCON0_DCLK_GATE_BIT			(31)
62*4882a593Smuzhiyun #define SUN4I_TCON0_DCLK_DIV_SHIFT			(0)
63*4882a593Smuzhiyun #define SUN4I_TCON0_DCLK_DIV_WIDTH			(7)
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC0_REG			0x48
66*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC0_X(width)			((((width) - 1) & 0xfff) << 16)
67*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC0_Y(height)			(((height) - 1) & 0xfff)
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC1_REG			0x4c
70*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC1_H_TOTAL(total)		((((total) - 1) & 0x1fff) << 16)
71*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC1_H_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC2_REG			0x50
74*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC2_V_TOTAL(total)		(((total) & 0x1fff) << 16)
75*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC2_V_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC3_REG			0x54
78*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC3_H_SYNC(width)		((((width) - 1) & 0x7ff) << 16)
79*4882a593Smuzhiyun #define SUN4I_TCON0_BASIC3_V_SYNC(height)		(((height) - 1) & 0x7ff)
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #define SUN4I_TCON0_HV_IF_REG			0x58
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_REG			0x60
84*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_MODE_MASK			GENMASK(31, 28)
85*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_MODE_DSI			(1 << 28)
86*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_TRI_FIFO_FLUSH		BIT(16)
87*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_TRI_FIFO_EN			BIT(2)
88*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_IF_TRI_EN			BIT(0)
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_WR_REG			0x64
91*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_RD0_REG			0x68
92*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_RDA_REG			0x6c
93*4882a593Smuzhiyun #define SUN4I_TCON0_TTL0_REG			0x70
94*4882a593Smuzhiyun #define SUN4I_TCON0_TTL1_REG			0x74
95*4882a593Smuzhiyun #define SUN4I_TCON0_TTL2_REG			0x78
96*4882a593Smuzhiyun #define SUN4I_TCON0_TTL3_REG			0x7c
97*4882a593Smuzhiyun #define SUN4I_TCON0_TTL4_REG			0x80
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_REG			0x84
100*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_EN				BIT(31)
101*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK		BIT(26)
102*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS		(1 << 26)
103*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS		(0 << 26)
104*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_CLK_SEL_MASK		BIT(20)
105*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0		(1 << 20)
106*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_CLK_POL_MASK		BIT(4)
107*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_CLK_POL_NORMAL		(1 << 4)
108*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_CLK_POL_INV			(0 << 4)
109*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_DATA_POL_MASK		GENMASK(3, 0)
110*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL		(0xf)
111*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_IF_DATA_POL_INV		(0)
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_REG			0x88
114*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase)		((phase & 3) << 28)
115*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_DE_NEGATIVE			BIT(27)
116*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE		BIT(26)
117*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE		BIT(25)
118*4882a593Smuzhiyun #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE		BIT(24)
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun #define SUN4I_TCON0_IO_TRI_REG			0x8c
121*4882a593Smuzhiyun #define SUN4I_TCON0_IO_TRI_HSYNC_DISABLE		BIT(25)
122*4882a593Smuzhiyun #define SUN4I_TCON0_IO_TRI_VSYNC_DISABLE		BIT(24)
123*4882a593Smuzhiyun #define SUN4I_TCON0_IO_TRI_DATA_PINS_DISABLE(pins)	GENMASK(pins, 0)
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_REG			0x90
126*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_TCON_ENABLE			BIT(31)
127*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_INTERLACE_ENABLE		BIT(20)
128*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_CLK_DELAY_MASK			GENMASK(8, 4)
129*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_CLK_DELAY(delay)		((delay << 4) & SUN4I_TCON1_CTL_CLK_DELAY_MASK)
130*4882a593Smuzhiyun #define SUN4I_TCON1_CTL_SRC_SEL_MASK			GENMASK(1, 0)
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC0_REG			0x94
133*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC0_X(width)			((((width) - 1) & 0xfff) << 16)
134*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC0_Y(height)			(((height) - 1) & 0xfff)
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC1_REG			0x98
137*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC1_X(width)			((((width) - 1) & 0xfff) << 16)
138*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC1_Y(height)			(((height) - 1) & 0xfff)
139*4882a593Smuzhiyun 
140*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC2_REG			0x9c
141*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC2_X(width)			((((width) - 1) & 0xfff) << 16)
142*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC2_Y(height)			(((height) - 1) & 0xfff)
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC3_REG			0xa0
145*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC3_H_TOTAL(total)		((((total) - 1) & 0x1fff) << 16)
146*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC3_H_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC4_REG			0xa4
149*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC4_V_TOTAL(total)		(((total) & 0x1fff) << 16)
150*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC4_V_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC5_REG			0xa8
153*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC5_H_SYNC(width)		((((width) - 1) & 0x3ff) << 16)
154*4882a593Smuzhiyun #define SUN4I_TCON1_BASIC5_V_SYNC(height)		(((height) - 1) & 0x3ff)
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun #define SUN4I_TCON1_IO_POL_REG			0xf0
157*4882a593Smuzhiyun /* there is no documentation about this bit */
158*4882a593Smuzhiyun #define SUN4I_TCON1_IO_POL_UNKNOWN			BIT(26)
159*4882a593Smuzhiyun #define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE		BIT(25)
160*4882a593Smuzhiyun #define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE		BIT(24)
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun #define SUN4I_TCON1_IO_TRI_REG			0xf4
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun #define SUN4I_TCON_ECC_FIFO_REG			0xf8
165*4882a593Smuzhiyun #define SUN4I_TCON_ECC_FIFO_EN				BIT(3)
166*4882a593Smuzhiyun 
167*4882a593Smuzhiyun #define SUN4I_TCON_CEU_CTL_REG			0x100
168*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_RR_REG		0x110
169*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_RG_REG		0x114
170*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_RB_REG		0x118
171*4882a593Smuzhiyun #define SUN4I_TCON_CEU_ADD_RC_REG		0x11c
172*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_GR_REG		0x120
173*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_GG_REG		0x124
174*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_GB_REG		0x128
175*4882a593Smuzhiyun #define SUN4I_TCON_CEU_ADD_GC_REG		0x12c
176*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_BR_REG		0x130
177*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_BG_REG		0x134
178*4882a593Smuzhiyun #define SUN4I_TCON_CEU_MUL_BB_REG		0x138
179*4882a593Smuzhiyun #define SUN4I_TCON_CEU_ADD_BC_REG		0x13c
180*4882a593Smuzhiyun #define SUN4I_TCON_CEU_RANGE_R_REG		0x140
181*4882a593Smuzhiyun #define SUN4I_TCON_CEU_RANGE_G_REG		0x144
182*4882a593Smuzhiyun #define SUN4I_TCON_CEU_RANGE_B_REG		0x148
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI0_REG		0x160
185*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI0_BLOCK_SPACE(space)		((((space) - 1) & 0xfff) << 16)
186*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI0_BLOCK_SIZE(size)		(((size) - 1) & 0xfff)
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI1_REG		0x164
189*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI1_BLOCK_NUM(num)		(((num) - 1) & 0xffff)
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI2_REG		0x168
192*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI2_START_DELAY(delay)		(((delay) & 0xffff) << 16)
193*4882a593Smuzhiyun #define SUN4I_TCON0_CPU_TRI2_TRANS_START_SET(set)	((set) & 0xfff)
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun #define SUN4I_TCON_SAFE_PERIOD_REG		0x1f0
196*4882a593Smuzhiyun #define SUN4I_TCON_SAFE_PERIOD_NUM(num)			(((num) & 0xfff) << 16)
197*4882a593Smuzhiyun #define SUN4I_TCON_SAFE_PERIOD_MODE(mode)		((mode) & 0x3)
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun #define SUN4I_TCON_MUX_CTRL_REG			0x200
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_REG		0x220
202*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_DCHS			BIT(16)
203*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_PD			(BIT(20) | BIT(21))
204*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_EN_MB			BIT(22)
205*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_REG_C			(BIT(24) | BIT(25))
206*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_REG_V			(BIT(26) | BIT(27))
207*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA0_CK_EN			(BIT(29) | BIT(28))
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_EN_MB			BIT(31)
210*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_EN_LDO			BIT(30)
211*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_EN_DRVC			BIT(24)
212*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_EN_DRVD(x)		(((x) & 0xf) << 20)
213*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_C(x)			(((x) & 3) << 17)
214*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_V(x)			(((x) & 3) << 8)
215*4882a593Smuzhiyun #define SUN6I_TCON0_LVDS_ANA0_PD(x)			(((x) & 3) << 4)
216*4882a593Smuzhiyun 
217*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA1_REG		0x224
218*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA1_INIT			(0x1f << 26 | 0x1f << 10)
219*4882a593Smuzhiyun #define SUN4I_TCON0_LVDS_ANA1_UPDATE			(0x1f << 16 | 0x1f << 00)
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_CTL_REG		0x300
222*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_BEG0_REG		0x304
223*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_END0_REG		0x308
224*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_DATA0_REG		0x30c
225*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_BEG1_REG		0x310
226*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_END1_REG		0x314
227*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_DATA1_REG		0x318
228*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_BEG2_REG		0x31c
229*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_END2_REG		0x320
230*4882a593Smuzhiyun #define SUN4I_TCON1_FILL_DATA2_REG		0x324
231*4882a593Smuzhiyun #define SUN4I_TCON1_GAMMA_TABLE_REG		0x400
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun #define SUN4I_TCON_MAX_CHANNELS		2
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun struct sun4i_tcon;
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun struct sun4i_tcon_quirks {
238*4882a593Smuzhiyun 	bool	has_channel_0;	/* a83t does not have channel 0 on second TCON */
239*4882a593Smuzhiyun 	bool	has_channel_1;	/* a33 does not have channel 1 */
240*4882a593Smuzhiyun 	bool	has_lvds_alt;	/* Does the LVDS clock have a parent other than the TCON clock? */
241*4882a593Smuzhiyun 	bool	needs_de_be_mux; /* sun6i needs mux to select backend */
242*4882a593Smuzhiyun 	bool    needs_edp_reset; /* a80 edp reset needed for tcon0 access */
243*4882a593Smuzhiyun 	bool	supports_lvds;   /* Does the TCON support an LVDS output? */
244*4882a593Smuzhiyun 	bool	polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */
245*4882a593Smuzhiyun 	u8	dclk_min_div;	/* minimum divider for TCON0 DCLK */
246*4882a593Smuzhiyun 
247*4882a593Smuzhiyun 	/* callback to handle tcon muxing options */
248*4882a593Smuzhiyun 	int	(*set_mux)(struct sun4i_tcon *, const struct drm_encoder *);
249*4882a593Smuzhiyun 	/* handler for LVDS setup routine */
250*4882a593Smuzhiyun 	void	(*setup_lvds_phy)(struct sun4i_tcon *tcon,
251*4882a593Smuzhiyun 				  const struct drm_encoder *encoder);
252*4882a593Smuzhiyun };
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun struct sun4i_tcon {
255*4882a593Smuzhiyun 	struct device			*dev;
256*4882a593Smuzhiyun 	struct drm_device		*drm;
257*4882a593Smuzhiyun 	struct regmap			*regs;
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun 	/* Main bus clock */
260*4882a593Smuzhiyun 	struct clk			*clk;
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun 	/* Clocks for the TCON channels */
263*4882a593Smuzhiyun 	struct clk			*sclk0;
264*4882a593Smuzhiyun 	struct clk			*sclk1;
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun 	/* Possible mux for the LVDS clock */
267*4882a593Smuzhiyun 	struct clk			*lvds_pll;
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun 	/* Pixel clock */
270*4882a593Smuzhiyun 	struct clk			*dclk;
271*4882a593Smuzhiyun 	u8				dclk_max_div;
272*4882a593Smuzhiyun 	u8				dclk_min_div;
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	/* Reset control */
275*4882a593Smuzhiyun 	struct reset_control		*lcd_rst;
276*4882a593Smuzhiyun 	struct reset_control		*lvds_rst;
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun 	/* Platform adjustments */
279*4882a593Smuzhiyun 	const struct sun4i_tcon_quirks	*quirks;
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun 	/* Associated crtc */
282*4882a593Smuzhiyun 	struct sun4i_crtc		*crtc;
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun 	int				id;
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun 	/* TCON list management */
287*4882a593Smuzhiyun 	struct list_head		list;
288*4882a593Smuzhiyun };
289*4882a593Smuzhiyun 
290*4882a593Smuzhiyun struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node);
291*4882a593Smuzhiyun struct drm_panel *sun4i_tcon_find_panel(struct device_node *node);
292*4882a593Smuzhiyun 
293*4882a593Smuzhiyun void sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable);
294*4882a593Smuzhiyun void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
295*4882a593Smuzhiyun 			 const struct drm_encoder *encoder,
296*4882a593Smuzhiyun 			 const struct drm_display_mode *mode);
297*4882a593Smuzhiyun void sun4i_tcon_set_status(struct sun4i_tcon *crtc,
298*4882a593Smuzhiyun 			   const struct drm_encoder *encoder, bool enable);
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun extern const struct of_device_id sun4i_tcon_of_table[];
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun #endif /* __SUN4I_TCON_H__ */
303