18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2013 NVIDIA Corporation
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef DRM_TEGRA_DSI_H
78c2ecf20Sopenharmony_ci#define DRM_TEGRA_DSI_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define DSI_INCR_SYNCPT			0x00
108c2ecf20Sopenharmony_ci#define DSI_INCR_SYNCPT_CONTROL		0x01
118c2ecf20Sopenharmony_ci#define DSI_INCR_SYNCPT_ERROR		0x02
128c2ecf20Sopenharmony_ci#define DSI_CTXSW			0x08
138c2ecf20Sopenharmony_ci#define DSI_RD_DATA			0x09
148c2ecf20Sopenharmony_ci#define DSI_WR_DATA			0x0a
158c2ecf20Sopenharmony_ci#define DSI_POWER_CONTROL		0x0b
168c2ecf20Sopenharmony_ci#define DSI_POWER_CONTROL_ENABLE	(1 << 0)
178c2ecf20Sopenharmony_ci#define DSI_INT_ENABLE			0x0c
188c2ecf20Sopenharmony_ci#define DSI_INT_STATUS			0x0d
198c2ecf20Sopenharmony_ci#define DSI_INT_MASK			0x0e
208c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL		0x0f
218c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_FIFO_RESET	(1 << 21)
228c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_CRC_RESET	(1 << 20)
238c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_SOL	(0 << 12)
248c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_FIFO	(1 << 12)
258c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_TX_TRIG_HOST	(2 << 12)
268c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_RAW		(1 << 6)
278c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_HS		(1 << 5)
288c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_FIFO_SEL	(1 << 4)
298c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_IMM_BTA	(1 << 3)
308c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_PKT_BTA	(1 << 2)
318c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_CS		(1 << 1)
328c2ecf20Sopenharmony_ci#define DSI_HOST_CONTROL_ECC		(1 << 0)
338c2ecf20Sopenharmony_ci#define DSI_CONTROL			0x10
348c2ecf20Sopenharmony_ci#define DSI_CONTROL_HS_CLK_CTRL		(1 << 20)
358c2ecf20Sopenharmony_ci#define DSI_CONTROL_CHANNEL(c)		(((c) & 0x3) << 16)
368c2ecf20Sopenharmony_ci#define DSI_CONTROL_FORMAT(f)		(((f) & 0x3) << 12)
378c2ecf20Sopenharmony_ci#define DSI_CONTROL_TX_TRIG(x)		(((x) & 0x3) <<  8)
388c2ecf20Sopenharmony_ci#define DSI_CONTROL_LANES(n)		(((n) & 0x3) <<  4)
398c2ecf20Sopenharmony_ci#define DSI_CONTROL_DCS_ENABLE		(1 << 3)
408c2ecf20Sopenharmony_ci#define DSI_CONTROL_SOURCE(s)		(((s) & 0x1) <<  2)
418c2ecf20Sopenharmony_ci#define DSI_CONTROL_VIDEO_ENABLE	(1 << 1)
428c2ecf20Sopenharmony_ci#define DSI_CONTROL_HOST_ENABLE		(1 << 0)
438c2ecf20Sopenharmony_ci#define DSI_SOL_DELAY			0x11
448c2ecf20Sopenharmony_ci#define DSI_MAX_THRESHOLD		0x12
458c2ecf20Sopenharmony_ci#define DSI_TRIGGER			0x13
468c2ecf20Sopenharmony_ci#define DSI_TRIGGER_HOST		(1 << 1)
478c2ecf20Sopenharmony_ci#define DSI_TRIGGER_VIDEO		(1 << 0)
488c2ecf20Sopenharmony_ci#define DSI_TX_CRC			0x14
498c2ecf20Sopenharmony_ci#define DSI_STATUS			0x15
508c2ecf20Sopenharmony_ci#define DSI_STATUS_IDLE			(1 << 10)
518c2ecf20Sopenharmony_ci#define DSI_STATUS_UNDERFLOW		(1 <<  9)
528c2ecf20Sopenharmony_ci#define DSI_STATUS_OVERFLOW		(1 <<  8)
538c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_CONTROL		0x1a
548c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_0		0x1b
558c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_1		0x1c
568c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_2		0x1d
578c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_3		0x1e
588c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_4		0x1f
598c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_5		0x20
608c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_6		0x21
618c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_7		0x22
628c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_0_LO		0x23
638c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_0_HI		0x24
648c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_1_LO		0x25
658c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_1_HI		0x26
668c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_2_LO		0x27
678c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_2_HI		0x28
688c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_3_LO		0x29
698c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_3_HI		0x2a
708c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_4_LO		0x2b
718c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_4_HI		0x2c
728c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_5_LO		0x2d
738c2ecf20Sopenharmony_ci#define DSI_PKT_SEQ_5_HI		0x2e
748c2ecf20Sopenharmony_ci#define DSI_DCS_CMDS			0x33
758c2ecf20Sopenharmony_ci#define DSI_PKT_LEN_0_1			0x34
768c2ecf20Sopenharmony_ci#define DSI_PKT_LEN_2_3			0x35
778c2ecf20Sopenharmony_ci#define DSI_PKT_LEN_4_5			0x36
788c2ecf20Sopenharmony_ci#define DSI_PKT_LEN_6_7			0x37
798c2ecf20Sopenharmony_ci#define DSI_PHY_TIMING_0		0x3c
808c2ecf20Sopenharmony_ci#define DSI_PHY_TIMING_1		0x3d
818c2ecf20Sopenharmony_ci#define DSI_PHY_TIMING_2		0x3e
828c2ecf20Sopenharmony_ci#define DSI_BTA_TIMING			0x3f
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define DSI_TIMING_FIELD(value, period, hwinc) \
858c2ecf20Sopenharmony_ci	((DIV_ROUND_CLOSEST(value, period) - (hwinc)) & 0xff)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_0			0x44
888c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_LRX(x)		(((x) & 0xffff) << 16)
898c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_HTX(x)		(((x) & 0xffff) <<  0)
908c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_1			0x45
918c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_PR(x)		(((x) & 0xffff) << 16)
928c2ecf20Sopenharmony_ci#define DSI_TIMEOUT_TA(x)		(((x) & 0xffff) <<  0)
938c2ecf20Sopenharmony_ci#define DSI_TO_TALLY			0x46
948c2ecf20Sopenharmony_ci#define DSI_TALLY_TA(x)			(((x) & 0xff) << 16)
958c2ecf20Sopenharmony_ci#define DSI_TALLY_LRX(x)		(((x) & 0xff) <<  8)
968c2ecf20Sopenharmony_ci#define DSI_TALLY_HTX(x)		(((x) & 0xff) <<  0)
978c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_0		0x4b
988c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PDIO(x)	(((x) & 0xf) <<  0)
998c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PDIO_CLK	(1 <<  8)
1008c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PULLDN(x)	(((x) & 0xf) << 16)
1018c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_VS1_PULLDN_CLK	(1 << 24)
1028c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_CD		0x4c
1038c2ecf20Sopenharmony_ci#define DSI_PAD_CD_STATUS		0x4d
1048c2ecf20Sopenharmony_ci#define DSI_VIDEO_MODE_CONTROL		0x4e
1058c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_1		0x4f
1068c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_2		0x50
1078c2ecf20Sopenharmony_ci#define DSI_PAD_OUT_CLK(x)		(((x) & 0x7) <<  0)
1088c2ecf20Sopenharmony_ci#define DSI_PAD_LP_DN(x)		(((x) & 0x7) <<  4)
1098c2ecf20Sopenharmony_ci#define DSI_PAD_LP_UP(x)		(((x) & 0x7) <<  8)
1108c2ecf20Sopenharmony_ci#define DSI_PAD_SLEW_DN(x)		(((x) & 0x7) << 12)
1118c2ecf20Sopenharmony_ci#define DSI_PAD_SLEW_UP(x)		(((x) & 0x7) << 16)
1128c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_3		0x51
1138c2ecf20Sopenharmony_ci#define  DSI_PAD_PREEMP_PD_CLK(x)	(((x) & 0x3) << 12)
1148c2ecf20Sopenharmony_ci#define  DSI_PAD_PREEMP_PU_CLK(x)	(((x) & 0x3) << 8)
1158c2ecf20Sopenharmony_ci#define  DSI_PAD_PREEMP_PD(x)		(((x) & 0x3) << 4)
1168c2ecf20Sopenharmony_ci#define  DSI_PAD_PREEMP_PU(x)		(((x) & 0x3) << 0)
1178c2ecf20Sopenharmony_ci#define DSI_PAD_CONTROL_4		0x52
1188c2ecf20Sopenharmony_ci#define DSI_GANGED_MODE_CONTROL		0x53
1198c2ecf20Sopenharmony_ci#define DSI_GANGED_MODE_CONTROL_ENABLE	(1 << 0)
1208c2ecf20Sopenharmony_ci#define DSI_GANGED_MODE_START		0x54
1218c2ecf20Sopenharmony_ci#define DSI_GANGED_MODE_SIZE		0x55
1228c2ecf20Sopenharmony_ci#define DSI_RAW_DATA_BYTE_COUNT		0x56
1238c2ecf20Sopenharmony_ci#define DSI_ULTRA_LOW_POWER_CONTROL	0x57
1248c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_8		0x58
1258c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_9		0x59
1268c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_10		0x5a
1278c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_11		0x5b
1288c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_12		0x5c
1298c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_13		0x5d
1308c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_14		0x5e
1318c2ecf20Sopenharmony_ci#define DSI_INIT_SEQ_DATA_15		0x5f
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/*
1348c2ecf20Sopenharmony_ci * pixel format as used in the DSI_CONTROL_FORMAT field
1358c2ecf20Sopenharmony_ci */
1368c2ecf20Sopenharmony_cienum tegra_dsi_format {
1378c2ecf20Sopenharmony_ci	TEGRA_DSI_FORMAT_16P,
1388c2ecf20Sopenharmony_ci	TEGRA_DSI_FORMAT_18NP,
1398c2ecf20Sopenharmony_ci	TEGRA_DSI_FORMAT_18P,
1408c2ecf20Sopenharmony_ci	TEGRA_DSI_FORMAT_24P,
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#endif
144