162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2013 NVIDIA Corporation
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef DRM_TEGRA_DSI_H
762306a36Sopenharmony_ci#define DRM_TEGRA_DSI_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define DSI_INCR_SYNCPT			0x00
1062306a36Sopenharmony_ci#define DSI_INCR_SYNCPT_CONTROL		0x01
1162306a36Sopenharmony_ci#define DSI_INCR_SYNCPT_ERROR		0x02
1262306a36Sopenharmony_ci#define DSI_CTXSW			0x08
1362306a36Sopenharmony_ci#define DSI_RD_DATA			0x09
1462306a36Sopenharmony_ci#define DSI_WR_DATA			0x0a
1562306a36Sopenharmony_ci#define DSI_POWER_CONTROL		0x0b
1662306a36Sopenharmony_ci#define DSI_POWER_CONTROL_ENABLE	(1 << 0)
1762306a36Sopenharmony_ci#define DSI_INT_ENABLE			0x0c
1862306a36Sopenharmony_ci#define DSI_INT_STATUS			0x0d
1962306a36Sopenharmony_ci#define DSI_INT_MASK			0x0e
2062306a36Sopenharmony_ci#define DSI_HOST_CONTROL		0x0f
2162306a36Sopenharmony_ci#define DSI_HOST_CONTROL_FIFO_RESET	(1 << 21)
2262306a36Sopenharmony_ci#define DSI_HOST_CONTROL_CRC_RESET	(1 << 20)
2362306a36Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_SOL	(0 << 12)
2462306a36Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_FIFO	(1 << 12)
2562306a36Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_HOST	(2 << 12)
2662306a36Sopenharmony_ci#define DSI_HOST_CONTROL_RAW		(1 << 6)
2762306a36Sopenharmony_ci#define DSI_HOST_CONTROL_HS		(1 << 5)
2862306a36Sopenharmony_ci#define DSI_HOST_CONTROL_FIFO_SEL	(1 << 4)
2962306a36Sopenharmony_ci#define DSI_HOST_CONTROL_IMM_BTA	(1 << 3)
3062306a36Sopenharmony_ci#define DSI_HOST_CONTROL_PKT_BTA	(1 << 2)
3162306a36Sopenharmony_ci#define DSI_HOST_CONTROL_CS		(1 << 1)
3262306a36Sopenharmony_ci#define DSI_HOST_CONTROL_ECC		(1 << 0)
3362306a36Sopenharmony_ci#define DSI_CONTROL			0x10
3462306a36Sopenharmony_ci#define DSI_CONTROL_HS_CLK_CTRL		(1 << 20)
3562306a36Sopenharmony_ci#define DSI_CONTROL_CHANNEL(c)		(((c) & 0x3) << 16)
3662306a36Sopenharmony_ci#define DSI_CONTROL_FORMAT(f)		(((f) & 0x3) << 12)
3762306a36Sopenharmony_ci#define DSI_CONTROL_TX_TRIG(x)		(((x) & 0x3) <<  8)
3862306a36Sopenharmony_ci#define DSI_CONTROL_LANES(n)		(((n) & 0x3) <<  4)
3962306a36Sopenharmony_ci#define DSI_CONTROL_DCS_ENABLE		(1 << 3)
4062306a36Sopenharmony_ci#define DSI_CONTROL_SOURCE(s)		(((s) & 0x1) <<  2)
4162306a36Sopenharmony_ci#define DSI_CONTROL_VIDEO_ENABLE	(1 << 1)
4262306a36Sopenharmony_ci#define DSI_CONTROL_HOST_ENABLE		(1 << 0)
4362306a36Sopenharmony_ci#define DSI_SOL_DELAY			0x11
4462306a36Sopenharmony_ci#define DSI_MAX_THRESHOLD		0x12
4562306a36Sopenharmony_ci#define DSI_TRIGGER			0x13
4662306a36Sopenharmony_ci#define DSI_TRIGGER_HOST		(1 << 1)
4762306a36Sopenharmony_ci#define DSI_TRIGGER_VIDEO		(1 << 0)
4862306a36Sopenharmony_ci#define DSI_TX_CRC			0x14
4962306a36Sopenharmony_ci#define DSI_STATUS			0x15
5062306a36Sopenharmony_ci#define DSI_STATUS_IDLE			(1 << 10)
5162306a36Sopenharmony_ci#define DSI_STATUS_UNDERFLOW		(1 <<  9)
5262306a36Sopenharmony_ci#define DSI_STATUS_OVERFLOW		(1 <<  8)
5362306a36Sopenharmony_ci#define DSI_INIT_SEQ_CONTROL		0x1a
5462306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_0		0x1b
5562306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_1		0x1c
5662306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_2		0x1d
5762306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_3		0x1e
5862306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_4		0x1f
5962306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_5		0x20
6062306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_6		0x21
6162306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_7		0x22
6262306a36Sopenharmony_ci#define DSI_PKT_SEQ_0_LO		0x23
6362306a36Sopenharmony_ci#define DSI_PKT_SEQ_0_HI		0x24
6462306a36Sopenharmony_ci#define DSI_PKT_SEQ_1_LO		0x25
6562306a36Sopenharmony_ci#define DSI_PKT_SEQ_1_HI		0x26
6662306a36Sopenharmony_ci#define DSI_PKT_SEQ_2_LO		0x27
6762306a36Sopenharmony_ci#define DSI_PKT_SEQ_2_HI		0x28
6862306a36Sopenharmony_ci#define DSI_PKT_SEQ_3_LO		0x29
6962306a36Sopenharmony_ci#define DSI_PKT_SEQ_3_HI		0x2a
7062306a36Sopenharmony_ci#define DSI_PKT_SEQ_4_LO		0x2b
7162306a36Sopenharmony_ci#define DSI_PKT_SEQ_4_HI		0x2c
7262306a36Sopenharmony_ci#define DSI_PKT_SEQ_5_LO		0x2d
7362306a36Sopenharmony_ci#define DSI_PKT_SEQ_5_HI		0x2e
7462306a36Sopenharmony_ci#define DSI_DCS_CMDS			0x33
7562306a36Sopenharmony_ci#define DSI_PKT_LEN_0_1			0x34
7662306a36Sopenharmony_ci#define DSI_PKT_LEN_2_3			0x35
7762306a36Sopenharmony_ci#define DSI_PKT_LEN_4_5			0x36
7862306a36Sopenharmony_ci#define DSI_PKT_LEN_6_7			0x37
7962306a36Sopenharmony_ci#define DSI_PHY_TIMING_0		0x3c
8062306a36Sopenharmony_ci#define DSI_PHY_TIMING_1		0x3d
8162306a36Sopenharmony_ci#define DSI_PHY_TIMING_2		0x3e
8262306a36Sopenharmony_ci#define DSI_BTA_TIMING			0x3f
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define DSI_TIMING_FIELD(value, period, hwinc) \
8562306a36Sopenharmony_ci	((DIV_ROUND_CLOSEST(value, period) - (hwinc)) & 0xff)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define DSI_TIMEOUT_0			0x44
8862306a36Sopenharmony_ci#define DSI_TIMEOUT_LRX(x)		(((x) & 0xffff) << 16)
8962306a36Sopenharmony_ci#define DSI_TIMEOUT_HTX(x)		(((x) & 0xffff) <<  0)
9062306a36Sopenharmony_ci#define DSI_TIMEOUT_1			0x45
9162306a36Sopenharmony_ci#define DSI_TIMEOUT_PR(x)		(((x) & 0xffff) << 16)
9262306a36Sopenharmony_ci#define DSI_TIMEOUT_TA(x)		(((x) & 0xffff) <<  0)
9362306a36Sopenharmony_ci#define DSI_TO_TALLY			0x46
9462306a36Sopenharmony_ci#define DSI_TALLY_TA(x)			(((x) & 0xff) << 16)
9562306a36Sopenharmony_ci#define DSI_TALLY_LRX(x)		(((x) & 0xff) <<  8)
9662306a36Sopenharmony_ci#define DSI_TALLY_HTX(x)		(((x) & 0xff) <<  0)
9762306a36Sopenharmony_ci#define DSI_PAD_CONTROL_0		0x4b
9862306a36Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PDIO(x)	(((x) & 0xf) <<  0)
9962306a36Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PDIO_CLK	(1 <<  8)
10062306a36Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PULLDN(x)	(((x) & 0xf) << 16)
10162306a36Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PULLDN_CLK	(1 << 24)
10262306a36Sopenharmony_ci#define DSI_PAD_CONTROL_CD		0x4c
10362306a36Sopenharmony_ci#define DSI_PAD_CD_STATUS		0x4d
10462306a36Sopenharmony_ci#define DSI_VIDEO_MODE_CONTROL		0x4e
10562306a36Sopenharmony_ci#define DSI_PAD_CONTROL_1		0x4f
10662306a36Sopenharmony_ci#define DSI_PAD_CONTROL_2		0x50
10762306a36Sopenharmony_ci#define DSI_PAD_OUT_CLK(x)		(((x) & 0x7) <<  0)
10862306a36Sopenharmony_ci#define DSI_PAD_LP_DN(x)		(((x) & 0x7) <<  4)
10962306a36Sopenharmony_ci#define DSI_PAD_LP_UP(x)		(((x) & 0x7) <<  8)
11062306a36Sopenharmony_ci#define DSI_PAD_SLEW_DN(x)		(((x) & 0x7) << 12)
11162306a36Sopenharmony_ci#define DSI_PAD_SLEW_UP(x)		(((x) & 0x7) << 16)
11262306a36Sopenharmony_ci#define DSI_PAD_CONTROL_3		0x51
11362306a36Sopenharmony_ci#define  DSI_PAD_PREEMP_PD_CLK(x)	(((x) & 0x3) << 12)
11462306a36Sopenharmony_ci#define  DSI_PAD_PREEMP_PU_CLK(x)	(((x) & 0x3) << 8)
11562306a36Sopenharmony_ci#define  DSI_PAD_PREEMP_PD(x)		(((x) & 0x3) << 4)
11662306a36Sopenharmony_ci#define  DSI_PAD_PREEMP_PU(x)		(((x) & 0x3) << 0)
11762306a36Sopenharmony_ci#define DSI_PAD_CONTROL_4		0x52
11862306a36Sopenharmony_ci#define DSI_GANGED_MODE_CONTROL		0x53
11962306a36Sopenharmony_ci#define DSI_GANGED_MODE_CONTROL_ENABLE	(1 << 0)
12062306a36Sopenharmony_ci#define DSI_GANGED_MODE_START		0x54
12162306a36Sopenharmony_ci#define DSI_GANGED_MODE_SIZE		0x55
12262306a36Sopenharmony_ci#define DSI_RAW_DATA_BYTE_COUNT		0x56
12362306a36Sopenharmony_ci#define DSI_ULTRA_LOW_POWER_CONTROL	0x57
12462306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_8		0x58
12562306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_9		0x59
12662306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_10		0x5a
12762306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_11		0x5b
12862306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_12		0x5c
12962306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_13		0x5d
13062306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_14		0x5e
13162306a36Sopenharmony_ci#define DSI_INIT_SEQ_DATA_15		0x5f
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci/*
13462306a36Sopenharmony_ci * pixel format as used in the DSI_CONTROL_FORMAT field
13562306a36Sopenharmony_ci */
13662306a36Sopenharmony_cienum tegra_dsi_format {
13762306a36Sopenharmony_ci	TEGRA_DSI_FORMAT_16P,
13862306a36Sopenharmony_ci	TEGRA_DSI_FORMAT_18NP,
13962306a36Sopenharmony_ci	TEGRA_DSI_FORMAT_18P,
14062306a36Sopenharmony_ci	TEGRA_DSI_FORMAT_24P,
14162306a36Sopenharmony_ci};
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#endif
144