162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2015 Free Electrons
462306a36Sopenharmony_ci * Copyright (C) 2015 NextThing Co
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Boris Brezillon <boris.brezillon@free-electrons.com>
762306a36Sopenharmony_ci * Maxime Ripard <maxime.ripard@free-electrons.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __SUN4I_TCON_H__
1162306a36Sopenharmony_ci#define __SUN4I_TCON_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <drm/drm_crtc.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <linux/kernel.h>
1662306a36Sopenharmony_ci#include <linux/list.h>
1762306a36Sopenharmony_ci#include <linux/mod_devicetable.h>
1862306a36Sopenharmony_ci#include <linux/reset.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define SUN4I_TCON_GCTL_REG			0x0
2162306a36Sopenharmony_ci#define SUN4I_TCON_GCTL_TCON_ENABLE			BIT(31)
2262306a36Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_MASK			BIT(0)
2362306a36Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_TCON1			(1 << 0)
2462306a36Sopenharmony_ci#define SUN4I_TCON_GCTL_IOMAP_TCON0			(0 << 0)
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_REG			0x4
2762306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_VBLANK_ENABLE(pipe)		BIT(31 - (pipe))
2862306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_ENABLE	BIT(27)
2962306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_ENABLE	BIT(26)
3062306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_VBLANK_INT(pipe)		BIT(15 - (pipe))
3162306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_FINISH_INT		BIT(11)
3262306a36Sopenharmony_ci#define SUN4I_TCON_GINT0_TCON0_TRI_COUNTER_INT		BIT(10)
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define SUN4I_TCON_GINT1_REG			0x8
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define SUN4I_TCON_FRM_CTL_REG			0x10
3762306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_EN				BIT(31)
3862306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_R			BIT(6)
3962306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_G			BIT(5)
4062306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_CTL_MODE_B			BIT(4)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PR_REG		0x14
4362306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PG_REG		0x18
4462306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_PB_REG		0x1c
4562306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LR_REG		0x20
4662306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LG_REG		0x24
4762306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_SEED_LB_REG		0x28
4862306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL0_REG		0x2c
4962306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL1_REG		0x30
5062306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL2_REG		0x34
5162306a36Sopenharmony_ci#define SUN4I_TCON0_FRM_TBL3_REG		0x38
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_REG			0x40
5462306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_TCON_ENABLE			BIT(31)
5562306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_IF_MASK				GENMASK(25, 24)
5662306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_IF_8080				(1 << 24)
5762306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_CLK_DELAY_MASK			GENMASK(8, 4)
5862306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_CLK_DELAY(delay)		((delay << 4) & SUN4I_TCON0_CTL_CLK_DELAY_MASK)
5962306a36Sopenharmony_ci#define SUN4I_TCON0_CTL_SRC_SEL_MASK			GENMASK(2, 0)
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define SUN4I_TCON0_DCLK_REG			0x44
6262306a36Sopenharmony_ci#define SUN4I_TCON0_DCLK_GATE_BIT			(31)
6362306a36Sopenharmony_ci#define SUN4I_TCON0_DCLK_DIV_SHIFT			(0)
6462306a36Sopenharmony_ci#define SUN4I_TCON0_DCLK_DIV_WIDTH			(7)
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC0_REG			0x48
6762306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC0_X(width)			((((width) - 1) & 0xfff) << 16)
6862306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC0_Y(height)			(((height) - 1) & 0xfff)
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC1_REG			0x4c
7162306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC1_H_TOTAL(total)		((((total) - 1) & 0x1fff) << 16)
7262306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC1_H_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC2_REG			0x50
7562306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC2_V_TOTAL(total)		(((total) & 0x1fff) << 16)
7662306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC2_V_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC3_REG			0x54
7962306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC3_H_SYNC(width)		((((width) - 1) & 0x7ff) << 16)
8062306a36Sopenharmony_ci#define SUN4I_TCON0_BASIC3_V_SYNC(height)		(((height) - 1) & 0x7ff)
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#define SUN4I_TCON0_HV_IF_REG			0x58
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_REG			0x60
8562306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_MODE_MASK			GENMASK(31, 28)
8662306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_MODE_DSI			(1 << 28)
8762306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_FIFO_FLUSH		BIT(16)
8862306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_FIFO_EN			BIT(2)
8962306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_IF_TRI_EN			BIT(0)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_WR_REG			0x64
9262306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_RD0_REG			0x68
9362306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_RDA_REG			0x6c
9462306a36Sopenharmony_ci#define SUN4I_TCON0_TTL0_REG			0x70
9562306a36Sopenharmony_ci#define SUN4I_TCON0_TTL1_REG			0x74
9662306a36Sopenharmony_ci#define SUN4I_TCON0_TTL2_REG			0x78
9762306a36Sopenharmony_ci#define SUN4I_TCON0_TTL3_REG			0x7c
9862306a36Sopenharmony_ci#define SUN4I_TCON0_TTL4_REG			0x80
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_REG			0x84
10162306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_EN				BIT(31)
10262306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK		BIT(26)
10362306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS		(1 << 26)
10462306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS		(0 << 26)
10562306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_SEL_MASK		BIT(20)
10662306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0		(1 << 20)
10762306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_MASK		BIT(4)
10862306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_NORMAL		(1 << 4)
10962306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_CLK_POL_INV			(0 << 4)
11062306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_MASK		GENMASK(3, 0)
11162306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL		(0xf)
11262306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_IF_DATA_POL_INV		(0)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_REG			0x88
11562306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase)		((phase & 3) << 28)
11662306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DE_NEGATIVE			BIT(27)
11762306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE		BIT(26)
11862306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE		BIT(25)
11962306a36Sopenharmony_ci#define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE		BIT(24)
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_REG			0x8c
12262306a36Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_HSYNC_DISABLE		BIT(25)
12362306a36Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_VSYNC_DISABLE		BIT(24)
12462306a36Sopenharmony_ci#define SUN4I_TCON0_IO_TRI_DATA_PINS_DISABLE(pins)	GENMASK(pins, 0)
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_REG			0x90
12762306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_TCON_ENABLE			BIT(31)
12862306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_INTERLACE_ENABLE		BIT(20)
12962306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_CLK_DELAY_MASK			GENMASK(8, 4)
13062306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_CLK_DELAY(delay)		((delay << 4) & SUN4I_TCON1_CTL_CLK_DELAY_MASK)
13162306a36Sopenharmony_ci#define SUN4I_TCON1_CTL_SRC_SEL_MASK			GENMASK(1, 0)
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC0_REG			0x94
13462306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC0_X(width)			((((width) - 1) & 0xfff) << 16)
13562306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC0_Y(height)			(((height) - 1) & 0xfff)
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC1_REG			0x98
13862306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC1_X(width)			((((width) - 1) & 0xfff) << 16)
13962306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC1_Y(height)			(((height) - 1) & 0xfff)
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC2_REG			0x9c
14262306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC2_X(width)			((((width) - 1) & 0xfff) << 16)
14362306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC2_Y(height)			(((height) - 1) & 0xfff)
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC3_REG			0xa0
14662306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC3_H_TOTAL(total)		((((total) - 1) & 0x1fff) << 16)
14762306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC3_H_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC4_REG			0xa4
15062306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC4_V_TOTAL(total)		(((total) & 0x1fff) << 16)
15162306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC4_V_BACKPORCH(bp)		(((bp) - 1) & 0xfff)
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC5_REG			0xa8
15462306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC5_H_SYNC(width)		((((width) - 1) & 0x3ff) << 16)
15562306a36Sopenharmony_ci#define SUN4I_TCON1_BASIC5_V_SYNC(height)		(((height) - 1) & 0x3ff)
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#define SUN4I_TCON1_IO_POL_REG			0xf0
15862306a36Sopenharmony_ci/* there is no documentation about this bit */
15962306a36Sopenharmony_ci#define SUN4I_TCON1_IO_POL_UNKNOWN			BIT(26)
16062306a36Sopenharmony_ci#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE		BIT(25)
16162306a36Sopenharmony_ci#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE		BIT(24)
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci#define SUN4I_TCON1_IO_TRI_REG			0xf4
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#define SUN4I_TCON_ECC_FIFO_REG			0xf8
16662306a36Sopenharmony_ci#define SUN4I_TCON_ECC_FIFO_EN				BIT(3)
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#define SUN4I_TCON_CEU_CTL_REG			0x100
16962306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RR_REG		0x110
17062306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RG_REG		0x114
17162306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_RB_REG		0x118
17262306a36Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_RC_REG		0x11c
17362306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GR_REG		0x120
17462306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GG_REG		0x124
17562306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_GB_REG		0x128
17662306a36Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_GC_REG		0x12c
17762306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BR_REG		0x130
17862306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BG_REG		0x134
17962306a36Sopenharmony_ci#define SUN4I_TCON_CEU_MUL_BB_REG		0x138
18062306a36Sopenharmony_ci#define SUN4I_TCON_CEU_ADD_BC_REG		0x13c
18162306a36Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_R_REG		0x140
18262306a36Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_G_REG		0x144
18362306a36Sopenharmony_ci#define SUN4I_TCON_CEU_RANGE_B_REG		0x148
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_REG		0x160
18662306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_BLOCK_SPACE(space)		((((space) - 1) & 0xfff) << 16)
18762306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI0_BLOCK_SIZE(size)		(((size) - 1) & 0xfff)
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI1_REG		0x164
19062306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI1_BLOCK_NUM(num)		(((num) - 1) & 0xffff)
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_REG		0x168
19362306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_START_DELAY(delay)		(((delay) & 0xffff) << 16)
19462306a36Sopenharmony_ci#define SUN4I_TCON0_CPU_TRI2_TRANS_START_SET(set)	((set) & 0xfff)
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_REG		0x1f0
19762306a36Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_NUM(num)			(((num) & 0xfff) << 16)
19862306a36Sopenharmony_ci#define SUN4I_TCON_SAFE_PERIOD_MODE(mode)		((mode) & 0x3)
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#define SUN4I_TCON_MUX_CTRL_REG			0x200
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG		0x220
20362306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_DCHS			BIT(16)
20462306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_PD			(BIT(20) | BIT(21))
20562306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_EN_MB			BIT(22)
20662306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG_C			(BIT(24) | BIT(25))
20762306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_REG_V			(BIT(26) | BIT(27))
20862306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA0_CK_EN			(BIT(29) | BIT(28))
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_MB			BIT(31)
21162306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_LDO			BIT(30)
21262306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_DRVC			BIT(24)
21362306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_EN_DRVD(x)		(((x) & 0xf) << 20)
21462306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_C(x)			(((x) & 3) << 17)
21562306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_V(x)			(((x) & 3) << 8)
21662306a36Sopenharmony_ci#define SUN6I_TCON0_LVDS_ANA0_PD(x)			(((x) & 3) << 4)
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_REG		0x224
21962306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_INIT			(0x1f << 26 | 0x1f << 10)
22062306a36Sopenharmony_ci#define SUN4I_TCON0_LVDS_ANA1_UPDATE			(0x1f << 16 | 0x1f << 00)
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_CTL_REG		0x300
22362306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG0_REG		0x304
22462306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_END0_REG		0x308
22562306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA0_REG		0x30c
22662306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG1_REG		0x310
22762306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_END1_REG		0x314
22862306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA1_REG		0x318
22962306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_BEG2_REG		0x31c
23062306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_END2_REG		0x320
23162306a36Sopenharmony_ci#define SUN4I_TCON1_FILL_DATA2_REG		0x324
23262306a36Sopenharmony_ci#define SUN4I_TCON1_GAMMA_TABLE_REG		0x400
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci#define SUN4I_TCON_MAX_CHANNELS		2
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_cistruct sun4i_tcon;
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_cistruct sun4i_tcon_quirks {
23962306a36Sopenharmony_ci	bool	has_channel_0;	/* a83t does not have channel 0 on second TCON */
24062306a36Sopenharmony_ci	bool	has_channel_1;	/* a33 does not have channel 1 */
24162306a36Sopenharmony_ci	bool	has_lvds_alt;	/* Does the LVDS clock have a parent other than the TCON clock? */
24262306a36Sopenharmony_ci	bool	needs_de_be_mux; /* sun6i needs mux to select backend */
24362306a36Sopenharmony_ci	bool    needs_edp_reset; /* a80 edp reset needed for tcon0 access */
24462306a36Sopenharmony_ci	bool	supports_lvds;   /* Does the TCON support an LVDS output? */
24562306a36Sopenharmony_ci	bool	polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */
24662306a36Sopenharmony_ci	u8	dclk_min_div;	/* minimum divider for TCON0 DCLK */
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci	/* callback to handle tcon muxing options */
24962306a36Sopenharmony_ci	int	(*set_mux)(struct sun4i_tcon *, const struct drm_encoder *);
25062306a36Sopenharmony_ci	/* handler for LVDS setup routine */
25162306a36Sopenharmony_ci	void	(*setup_lvds_phy)(struct sun4i_tcon *tcon,
25262306a36Sopenharmony_ci				  const struct drm_encoder *encoder);
25362306a36Sopenharmony_ci};
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_cistruct sun4i_tcon {
25662306a36Sopenharmony_ci	struct device			*dev;
25762306a36Sopenharmony_ci	struct drm_device		*drm;
25862306a36Sopenharmony_ci	struct regmap			*regs;
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci	/* Main bus clock */
26162306a36Sopenharmony_ci	struct clk			*clk;
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ci	/* Clocks for the TCON channels */
26462306a36Sopenharmony_ci	struct clk			*sclk0;
26562306a36Sopenharmony_ci	struct clk			*sclk1;
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci	/* Possible mux for the LVDS clock */
26862306a36Sopenharmony_ci	struct clk			*lvds_pll;
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci	/* Pixel clock */
27162306a36Sopenharmony_ci	struct clk			*dclk;
27262306a36Sopenharmony_ci	u8				dclk_max_div;
27362306a36Sopenharmony_ci	u8				dclk_min_div;
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci	/* Reset control */
27662306a36Sopenharmony_ci	struct reset_control		*lcd_rst;
27762306a36Sopenharmony_ci	struct reset_control		*lvds_rst;
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	/* Platform adjustments */
28062306a36Sopenharmony_ci	const struct sun4i_tcon_quirks	*quirks;
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci	/* Associated crtc */
28362306a36Sopenharmony_ci	struct sun4i_crtc		*crtc;
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci	int				id;
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci	/* TCON list management */
28862306a36Sopenharmony_ci	struct list_head		list;
28962306a36Sopenharmony_ci};
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_cistruct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node);
29262306a36Sopenharmony_cistruct drm_panel *sun4i_tcon_find_panel(struct device_node *node);
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_civoid sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable);
29562306a36Sopenharmony_civoid sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
29662306a36Sopenharmony_ci			 const struct drm_encoder *encoder,
29762306a36Sopenharmony_ci			 const struct drm_display_mode *mode);
29862306a36Sopenharmony_civoid sun4i_tcon_set_status(struct sun4i_tcon *crtc,
29962306a36Sopenharmony_ci			   const struct drm_encoder *encoder, bool enable);
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ciextern const struct of_device_id sun4i_tcon_of_table[];
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci#endif /* __SUN4I_TCON_H__ */
304