18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// Ingenic JZ47xx KMS driver - Register definitions and private API
48c2ecf20Sopenharmony_ci//
58c2ecf20Sopenharmony_ci// Copyright (C) 2020, Paul Cercueil <paul@crapouillou.net>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H
88c2ecf20Sopenharmony_ci#define DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/bitops.h>
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define JZ_REG_LCD_CFG				0x00
148c2ecf20Sopenharmony_ci#define JZ_REG_LCD_VSYNC			0x04
158c2ecf20Sopenharmony_ci#define JZ_REG_LCD_HSYNC			0x08
168c2ecf20Sopenharmony_ci#define JZ_REG_LCD_VAT				0x0C
178c2ecf20Sopenharmony_ci#define JZ_REG_LCD_DAH				0x10
188c2ecf20Sopenharmony_ci#define JZ_REG_LCD_DAV				0x14
198c2ecf20Sopenharmony_ci#define JZ_REG_LCD_PS				0x18
208c2ecf20Sopenharmony_ci#define JZ_REG_LCD_CLS				0x1C
218c2ecf20Sopenharmony_ci#define JZ_REG_LCD_SPL				0x20
228c2ecf20Sopenharmony_ci#define JZ_REG_LCD_REV				0x24
238c2ecf20Sopenharmony_ci#define JZ_REG_LCD_CTRL				0x30
248c2ecf20Sopenharmony_ci#define JZ_REG_LCD_STATE			0x34
258c2ecf20Sopenharmony_ci#define JZ_REG_LCD_IID				0x38
268c2ecf20Sopenharmony_ci#define JZ_REG_LCD_DA0				0x40
278c2ecf20Sopenharmony_ci#define JZ_REG_LCD_SA0				0x44
288c2ecf20Sopenharmony_ci#define JZ_REG_LCD_FID0				0x48
298c2ecf20Sopenharmony_ci#define JZ_REG_LCD_CMD0				0x4C
308c2ecf20Sopenharmony_ci#define JZ_REG_LCD_DA1				0x50
318c2ecf20Sopenharmony_ci#define JZ_REG_LCD_SA1				0x54
328c2ecf20Sopenharmony_ci#define JZ_REG_LCD_FID1				0x58
338c2ecf20Sopenharmony_ci#define JZ_REG_LCD_CMD1				0x5C
348c2ecf20Sopenharmony_ci#define JZ_REG_LCD_OSDC				0x100
358c2ecf20Sopenharmony_ci#define JZ_REG_LCD_OSDCTRL			0x104
368c2ecf20Sopenharmony_ci#define JZ_REG_LCD_OSDS				0x108
378c2ecf20Sopenharmony_ci#define JZ_REG_LCD_BGC				0x10c
388c2ecf20Sopenharmony_ci#define JZ_REG_LCD_KEY0				0x110
398c2ecf20Sopenharmony_ci#define JZ_REG_LCD_KEY1				0x114
408c2ecf20Sopenharmony_ci#define JZ_REG_LCD_ALPHA			0x118
418c2ecf20Sopenharmony_ci#define JZ_REG_LCD_IPUR				0x11c
428c2ecf20Sopenharmony_ci#define JZ_REG_LCD_XYP0				0x120
438c2ecf20Sopenharmony_ci#define JZ_REG_LCD_XYP1				0x124
448c2ecf20Sopenharmony_ci#define JZ_REG_LCD_SIZE0			0x128
458c2ecf20Sopenharmony_ci#define JZ_REG_LCD_SIZE1			0x12c
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_SLCD				BIT(31)
488c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_PS_DISABLE			BIT(23)
498c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_CLS_DISABLE			BIT(22)
508c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_SPL_DISABLE			BIT(21)
518c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_REV_DISABLE			BIT(20)
528c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_HSYNCM			BIT(19)
538c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_PCLKM			BIT(18)
548c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_INV				BIT(17)
558c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_SYNC_DIR			BIT(16)
568c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_PS_POLARITY			BIT(15)
578c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_CLS_POLARITY			BIT(14)
588c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_SPL_POLARITY			BIT(13)
598c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_REV_POLARITY			BIT(12)
608c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_HSYNC_ACTIVE_LOW		BIT(11)
618c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_PCLK_FALLING_EDGE		BIT(10)
628c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_DE_ACTIVE_LOW		BIT(9)
638c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_VSYNC_ACTIVE_LOW		BIT(8)
648c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_18_BIT			BIT(7)
658c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_PDW				(BIT(5) | BIT(4))
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_16BIT		0
688c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_18BIT		BIT(7)
698c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_24BIT		BIT(6)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_1		1
728c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_2		2
738c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_3		3
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_TV_OUT_P		4
768c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_TV_OUT_I		6
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_SINGLE_COLOR_STN	8
798c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_SINGLE_MONOCHROME_STN	9
808c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_DUAL_COLOR_STN		10
818c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_DUAL_MONOCHROME_STN	11
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_8BIT_SERIAL		12
848c2ecf20Sopenharmony_ci#define JZ_LCD_CFG_MODE_LCM			13
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define JZ_LCD_VSYNC_VPS_OFFSET			16
878c2ecf20Sopenharmony_ci#define JZ_LCD_VSYNC_VPE_OFFSET			0
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define JZ_LCD_HSYNC_HPS_OFFSET			16
908c2ecf20Sopenharmony_ci#define JZ_LCD_HSYNC_HPE_OFFSET			0
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define JZ_LCD_VAT_HT_OFFSET			16
938c2ecf20Sopenharmony_ci#define JZ_LCD_VAT_VT_OFFSET			0
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define JZ_LCD_DAH_HDS_OFFSET			16
968c2ecf20Sopenharmony_ci#define JZ_LCD_DAH_HDE_OFFSET			0
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define JZ_LCD_DAV_VDS_OFFSET			16
998c2ecf20Sopenharmony_ci#define JZ_LCD_DAV_VDE_OFFSET			0
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BURST_4			(0x0 << 28)
1028c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BURST_8			(0x1 << 28)
1038c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BURST_16			(0x2 << 28)
1048c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_RGB555			BIT(27)
1058c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_OFUP			BIT(26)
1068c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_16		(0x0 << 24)
1078c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_4		(0x1 << 24)
1088c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_2		(0x2 << 24)
1098c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_PDD_MASK			(0xff << 16)
1108c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_EOF_IRQ			BIT(13)
1118c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_SOF_IRQ			BIT(12)
1128c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_OFU_IRQ			BIT(11)
1138c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_IFU0_IRQ			BIT(10)
1148c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_IFU1_IRQ			BIT(9)
1158c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_DD_IRQ			BIT(8)
1168c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_QDD_IRQ			BIT(7)
1178c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_REVERSE_ENDIAN		BIT(6)
1188c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_LSB_FISRT			BIT(5)
1198c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_DISABLE			BIT(4)
1208c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_ENABLE			BIT(3)
1218c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_1			0x0
1228c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_2			0x1
1238c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_4			0x2
1248c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_8			0x3
1258c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_15_16			0x4
1268c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_18_24			0x5
1278c2ecf20Sopenharmony_ci#define JZ_LCD_CTRL_BPP_MASK			(JZ_LCD_CTRL_RGB555 | 0x7)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define JZ_LCD_CMD_SOF_IRQ			BIT(31)
1308c2ecf20Sopenharmony_ci#define JZ_LCD_CMD_EOF_IRQ			BIT(30)
1318c2ecf20Sopenharmony_ci#define JZ_LCD_CMD_ENABLE_PAL			BIT(28)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define JZ_LCD_SYNC_MASK			0x3ff
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define JZ_LCD_STATE_EOF_IRQ			BIT(5)
1368c2ecf20Sopenharmony_ci#define JZ_LCD_STATE_SOF_IRQ			BIT(4)
1378c2ecf20Sopenharmony_ci#define JZ_LCD_STATE_DISABLED			BIT(0)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#define JZ_LCD_OSDC_OSDEN			BIT(0)
1408c2ecf20Sopenharmony_ci#define JZ_LCD_OSDC_F0EN			BIT(3)
1418c2ecf20Sopenharmony_ci#define JZ_LCD_OSDC_F1EN			BIT(4)
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_IPU			BIT(15)
1448c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_RGB555			BIT(4)
1458c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_CHANGE			BIT(3)
1468c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_15_16		0x4
1478c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_18_24		0x5
1488c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_30			0x7
1498c2ecf20Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_MASK			(JZ_LCD_OSDCTRL_RGB555 | 0x7)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define JZ_LCD_OSDS_READY			BIT(0)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define JZ_LCD_IPUR_IPUREN			BIT(31)
1548c2ecf20Sopenharmony_ci#define JZ_LCD_IPUR_IPUR_LSB			0
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define JZ_LCD_XYP01_XPOS_LSB			0
1578c2ecf20Sopenharmony_ci#define JZ_LCD_XYP01_YPOS_LSB			16
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define JZ_LCD_SIZE01_WIDTH_LSB			0
1608c2ecf20Sopenharmony_ci#define JZ_LCD_SIZE01_HEIGHT_LSB		16
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistruct device;
1638c2ecf20Sopenharmony_cistruct drm_plane;
1648c2ecf20Sopenharmony_cistruct drm_plane_state;
1658c2ecf20Sopenharmony_cistruct platform_driver;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_civoid ingenic_drm_plane_config(struct device *dev,
1688c2ecf20Sopenharmony_ci			      struct drm_plane *plane, u32 fourcc);
1698c2ecf20Sopenharmony_civoid ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane);
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ciextern struct platform_driver *ingenic_ipu_driver_ptr;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci#endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */
174