162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci// 362306a36Sopenharmony_ci// Ingenic JZ47xx KMS driver - Register definitions and private API 462306a36Sopenharmony_ci// 562306a36Sopenharmony_ci// Copyright (C) 2020, Paul Cercueil <paul@crapouillou.net> 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H 862306a36Sopenharmony_ci#define DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/bitops.h> 1162306a36Sopenharmony_ci#include <linux/types.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define JZ_REG_LCD_CFG 0x00 1462306a36Sopenharmony_ci#define JZ_REG_LCD_VSYNC 0x04 1562306a36Sopenharmony_ci#define JZ_REG_LCD_HSYNC 0x08 1662306a36Sopenharmony_ci#define JZ_REG_LCD_VAT 0x0C 1762306a36Sopenharmony_ci#define JZ_REG_LCD_DAH 0x10 1862306a36Sopenharmony_ci#define JZ_REG_LCD_DAV 0x14 1962306a36Sopenharmony_ci#define JZ_REG_LCD_PS 0x18 2062306a36Sopenharmony_ci#define JZ_REG_LCD_CLS 0x1C 2162306a36Sopenharmony_ci#define JZ_REG_LCD_SPL 0x20 2262306a36Sopenharmony_ci#define JZ_REG_LCD_REV 0x24 2362306a36Sopenharmony_ci#define JZ_REG_LCD_CTRL 0x30 2462306a36Sopenharmony_ci#define JZ_REG_LCD_STATE 0x34 2562306a36Sopenharmony_ci#define JZ_REG_LCD_IID 0x38 2662306a36Sopenharmony_ci#define JZ_REG_LCD_DA0 0x40 2762306a36Sopenharmony_ci#define JZ_REG_LCD_SA0 0x44 2862306a36Sopenharmony_ci#define JZ_REG_LCD_FID0 0x48 2962306a36Sopenharmony_ci#define JZ_REG_LCD_CMD0 0x4C 3062306a36Sopenharmony_ci#define JZ_REG_LCD_DA1 0x50 3162306a36Sopenharmony_ci#define JZ_REG_LCD_SA1 0x54 3262306a36Sopenharmony_ci#define JZ_REG_LCD_FID1 0x58 3362306a36Sopenharmony_ci#define JZ_REG_LCD_CMD1 0x5C 3462306a36Sopenharmony_ci#define JZ_REG_LCD_RGBC 0x90 3562306a36Sopenharmony_ci#define JZ_REG_LCD_OSDC 0x100 3662306a36Sopenharmony_ci#define JZ_REG_LCD_OSDCTRL 0x104 3762306a36Sopenharmony_ci#define JZ_REG_LCD_OSDS 0x108 3862306a36Sopenharmony_ci#define JZ_REG_LCD_BGC 0x10c 3962306a36Sopenharmony_ci#define JZ_REG_LCD_KEY0 0x110 4062306a36Sopenharmony_ci#define JZ_REG_LCD_KEY1 0x114 4162306a36Sopenharmony_ci#define JZ_REG_LCD_ALPHA 0x118 4262306a36Sopenharmony_ci#define JZ_REG_LCD_IPUR 0x11c 4362306a36Sopenharmony_ci#define JZ_REG_LCD_XYP0 0x120 4462306a36Sopenharmony_ci#define JZ_REG_LCD_XYP1 0x124 4562306a36Sopenharmony_ci#define JZ_REG_LCD_SIZE0 0x128 4662306a36Sopenharmony_ci#define JZ_REG_LCD_SIZE1 0x12c 4762306a36Sopenharmony_ci#define JZ_REG_LCD_PCFG 0x2c0 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define JZ_LCD_CFG_SLCD BIT(31) 5062306a36Sopenharmony_ci#define JZ_LCD_CFG_DESCRIPTOR_8 BIT(28) 5162306a36Sopenharmony_ci#define JZ_LCD_CFG_RECOVER_FIFO_UNDERRUN BIT(25) 5262306a36Sopenharmony_ci#define JZ_LCD_CFG_PS_DISABLE BIT(23) 5362306a36Sopenharmony_ci#define JZ_LCD_CFG_CLS_DISABLE BIT(22) 5462306a36Sopenharmony_ci#define JZ_LCD_CFG_SPL_DISABLE BIT(21) 5562306a36Sopenharmony_ci#define JZ_LCD_CFG_REV_DISABLE BIT(20) 5662306a36Sopenharmony_ci#define JZ_LCD_CFG_HSYNCM BIT(19) 5762306a36Sopenharmony_ci#define JZ_LCD_CFG_PCLKM BIT(18) 5862306a36Sopenharmony_ci#define JZ_LCD_CFG_INV BIT(17) 5962306a36Sopenharmony_ci#define JZ_LCD_CFG_SYNC_DIR BIT(16) 6062306a36Sopenharmony_ci#define JZ_LCD_CFG_PS_POLARITY BIT(15) 6162306a36Sopenharmony_ci#define JZ_LCD_CFG_CLS_POLARITY BIT(14) 6262306a36Sopenharmony_ci#define JZ_LCD_CFG_SPL_POLARITY BIT(13) 6362306a36Sopenharmony_ci#define JZ_LCD_CFG_REV_POLARITY BIT(12) 6462306a36Sopenharmony_ci#define JZ_LCD_CFG_HSYNC_ACTIVE_LOW BIT(11) 6562306a36Sopenharmony_ci#define JZ_LCD_CFG_PCLK_FALLING_EDGE BIT(10) 6662306a36Sopenharmony_ci#define JZ_LCD_CFG_DE_ACTIVE_LOW BIT(9) 6762306a36Sopenharmony_ci#define JZ_LCD_CFG_VSYNC_ACTIVE_LOW BIT(8) 6862306a36Sopenharmony_ci#define JZ_LCD_CFG_18_BIT BIT(7) 6962306a36Sopenharmony_ci#define JZ_LCD_CFG_24_BIT BIT(6) 7062306a36Sopenharmony_ci#define JZ_LCD_CFG_PDW (BIT(5) | BIT(4)) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_16BIT 0 7362306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_18BIT BIT(7) 7462306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_GENERIC_24BIT BIT(6) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_1 1 7762306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_2 2 7862306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_SPECIAL_TFT_3 3 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_TV_OUT_P 4 8162306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_TV_OUT_I 6 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_SINGLE_COLOR_STN 8 8462306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_SINGLE_MONOCHROME_STN 9 8562306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_DUAL_COLOR_STN 10 8662306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_DUAL_MONOCHROME_STN 11 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_8BIT_SERIAL 12 8962306a36Sopenharmony_ci#define JZ_LCD_CFG_MODE_LCM 13 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define JZ_LCD_VSYNC_VPS_OFFSET 16 9262306a36Sopenharmony_ci#define JZ_LCD_VSYNC_VPE_OFFSET 0 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define JZ_LCD_HSYNC_HPS_OFFSET 16 9562306a36Sopenharmony_ci#define JZ_LCD_HSYNC_HPE_OFFSET 0 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define JZ_LCD_VAT_HT_OFFSET 16 9862306a36Sopenharmony_ci#define JZ_LCD_VAT_VT_OFFSET 0 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define JZ_LCD_DAH_HDS_OFFSET 16 10162306a36Sopenharmony_ci#define JZ_LCD_DAH_HDE_OFFSET 0 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define JZ_LCD_DAV_VDS_OFFSET 16 10462306a36Sopenharmony_ci#define JZ_LCD_DAV_VDE_OFFSET 0 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_4 (0x0 << 28) 10762306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_8 (0x1 << 28) 10862306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_16 (0x2 << 28) 10962306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_32 (0x3 << 28) 11062306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_64 (0x4 << 28) 11162306a36Sopenharmony_ci#define JZ_LCD_CTRL_BURST_MASK (0x7 << 28) 11262306a36Sopenharmony_ci#define JZ_LCD_CTRL_RGB555 BIT(27) 11362306a36Sopenharmony_ci#define JZ_LCD_CTRL_OFUP BIT(26) 11462306a36Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_16 (0x0 << 24) 11562306a36Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_4 (0x1 << 24) 11662306a36Sopenharmony_ci#define JZ_LCD_CTRL_FRC_GRAYSCALE_2 (0x2 << 24) 11762306a36Sopenharmony_ci#define JZ_LCD_CTRL_PDD_MASK (0xff << 16) 11862306a36Sopenharmony_ci#define JZ_LCD_CTRL_EOF_IRQ BIT(13) 11962306a36Sopenharmony_ci#define JZ_LCD_CTRL_SOF_IRQ BIT(12) 12062306a36Sopenharmony_ci#define JZ_LCD_CTRL_OFU_IRQ BIT(11) 12162306a36Sopenharmony_ci#define JZ_LCD_CTRL_IFU0_IRQ BIT(10) 12262306a36Sopenharmony_ci#define JZ_LCD_CTRL_IFU1_IRQ BIT(9) 12362306a36Sopenharmony_ci#define JZ_LCD_CTRL_DD_IRQ BIT(8) 12462306a36Sopenharmony_ci#define JZ_LCD_CTRL_QDD_IRQ BIT(7) 12562306a36Sopenharmony_ci#define JZ_LCD_CTRL_REVERSE_ENDIAN BIT(6) 12662306a36Sopenharmony_ci#define JZ_LCD_CTRL_LSB_FISRT BIT(5) 12762306a36Sopenharmony_ci#define JZ_LCD_CTRL_DISABLE BIT(4) 12862306a36Sopenharmony_ci#define JZ_LCD_CTRL_ENABLE BIT(3) 12962306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_1 0x0 13062306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_2 0x1 13162306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_4 0x2 13262306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_8 0x3 13362306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_15_16 0x4 13462306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_18_24 0x5 13562306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_24_COMP 0x6 13662306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_30 0x7 13762306a36Sopenharmony_ci#define JZ_LCD_CTRL_BPP_MASK (JZ_LCD_CTRL_RGB555 | 0x7) 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#define JZ_LCD_CMD_SOF_IRQ BIT(31) 14062306a36Sopenharmony_ci#define JZ_LCD_CMD_EOF_IRQ BIT(30) 14162306a36Sopenharmony_ci#define JZ_LCD_CMD_ENABLE_PAL BIT(28) 14262306a36Sopenharmony_ci#define JZ_LCD_CMD_FRM_ENABLE BIT(26) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci#define JZ_LCD_SYNC_MASK 0x3ff 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci#define JZ_LCD_STATE_EOF_IRQ BIT(5) 14762306a36Sopenharmony_ci#define JZ_LCD_STATE_SOF_IRQ BIT(4) 14862306a36Sopenharmony_ci#define JZ_LCD_STATE_DISABLED BIT(0) 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_RGB (0x0 << 4) 15162306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_RBG (0x1 << 4) 15262306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_GRB (0x2 << 4) 15362306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_GBR (0x3 << 4) 15462306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_BRG (0x4 << 4) 15562306a36Sopenharmony_ci#define JZ_LCD_RGBC_ODD_BGR (0x5 << 4) 15662306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_RGB (0x0 << 0) 15762306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_RBG (0x1 << 0) 15862306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_GRB (0x2 << 0) 15962306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_GBR (0x3 << 0) 16062306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_BRG (0x4 << 0) 16162306a36Sopenharmony_ci#define JZ_LCD_RGBC_EVEN_BGR (0x5 << 0) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci#define JZ_LCD_OSDC_OSDEN BIT(0) 16462306a36Sopenharmony_ci#define JZ_LCD_OSDC_ALPHAEN BIT(2) 16562306a36Sopenharmony_ci#define JZ_LCD_OSDC_F0EN BIT(3) 16662306a36Sopenharmony_ci#define JZ_LCD_OSDC_F1EN BIT(4) 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_IPU BIT(15) 16962306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_RGB555 BIT(4) 17062306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_CHANGE BIT(3) 17162306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_15_16 0x4 17262306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_18_24 0x5 17362306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_24_COMP 0x6 17462306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_30 0x7 17562306a36Sopenharmony_ci#define JZ_LCD_OSDCTRL_BPP_MASK (JZ_LCD_OSDCTRL_RGB555 | 0x7) 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci#define JZ_LCD_OSDS_READY BIT(0) 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci#define JZ_LCD_IPUR_IPUREN BIT(31) 18062306a36Sopenharmony_ci#define JZ_LCD_IPUR_IPUR_LSB 0 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci#define JZ_LCD_XYP01_XPOS_LSB 0 18362306a36Sopenharmony_ci#define JZ_LCD_XYP01_YPOS_LSB 16 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define JZ_LCD_SIZE01_WIDTH_LSB 0 18662306a36Sopenharmony_ci#define JZ_LCD_SIZE01_HEIGHT_LSB 16 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci#define JZ_LCD_DESSIZE_ALPHA_OFFSET 24 18962306a36Sopenharmony_ci#define JZ_LCD_DESSIZE_HEIGHT_MASK GENMASK(23, 12) 19062306a36Sopenharmony_ci#define JZ_LCD_DESSIZE_WIDTH_MASK GENMASK(11, 0) 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci#define JZ_LCD_CPOS_BPP_15_16 (4 << 27) 19362306a36Sopenharmony_ci#define JZ_LCD_CPOS_BPP_18_24 (5 << 27) 19462306a36Sopenharmony_ci#define JZ_LCD_CPOS_BPP_30 (7 << 27) 19562306a36Sopenharmony_ci#define JZ_LCD_CPOS_RGB555 BIT(30) 19662306a36Sopenharmony_ci#define JZ_LCD_CPOS_PREMULTIPLY_LCD BIT(26) 19762306a36Sopenharmony_ci#define JZ_LCD_CPOS_COEFFICIENT_OFFSET 24 19862306a36Sopenharmony_ci#define JZ_LCD_CPOS_COEFFICIENT_0 0 19962306a36Sopenharmony_ci#define JZ_LCD_CPOS_COEFFICIENT_1 1 20062306a36Sopenharmony_ci#define JZ_LCD_CPOS_COEFFICIENT_ALPHA1 2 20162306a36Sopenharmony_ci#define JZ_LCD_CPOS_COEFFICIENT_1_ALPHA1 3 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define JZ_LCD_RGBC_RGB_PADDING BIT(15) 20462306a36Sopenharmony_ci#define JZ_LCD_RGBC_RGB_PADDING_FIRST BIT(14) 20562306a36Sopenharmony_ci#define JZ_LCD_RGBC_422 BIT(8) 20662306a36Sopenharmony_ci#define JZ_LCD_RGBC_RGB_FORMAT_ENABLE BIT(7) 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define JZ_LCD_PCFG_PRI_MODE BIT(31) 20962306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_4 (0 << 28) 21062306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_8 (1 << 28) 21162306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_16 (2 << 28) 21262306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_32 (3 << 28) 21362306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_64 (4 << 28) 21462306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_16_CONT (5 << 28) 21562306a36Sopenharmony_ci#define JZ_LCD_PCFG_HP_BST_DISABLE (7 << 28) 21662306a36Sopenharmony_ci#define JZ_LCD_PCFG_THRESHOLD2_OFFSET 18 21762306a36Sopenharmony_ci#define JZ_LCD_PCFG_THRESHOLD1_OFFSET 9 21862306a36Sopenharmony_ci#define JZ_LCD_PCFG_THRESHOLD0_OFFSET 0 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistruct device; 22162306a36Sopenharmony_cistruct drm_plane; 22262306a36Sopenharmony_cistruct drm_plane_state; 22362306a36Sopenharmony_cistruct platform_driver; 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_civoid ingenic_drm_plane_config(struct device *dev, 22662306a36Sopenharmony_ci struct drm_plane *plane, u32 fourcc); 22762306a36Sopenharmony_civoid ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane); 22862306a36Sopenharmony_cibool ingenic_drm_map_noncoherent(const struct device *dev); 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ciextern struct platform_driver *ingenic_ipu_driver_ptr; 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci#endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */ 233