Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 //
0003 // Ingenic JZ47xx KMS driver - Register definitions and private API
0004 //
0005 // Copyright (C) 2020, Paul Cercueil <paul@crapouillou.net>
0006 
0007 #ifndef DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H
0008 #define DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H
0009 
0010 #include <linux/bitops.h>
0011 #include <linux/types.h>
0012 
0013 #define JZ_REG_LCD_CFG              0x00
0014 #define JZ_REG_LCD_VSYNC            0x04
0015 #define JZ_REG_LCD_HSYNC            0x08
0016 #define JZ_REG_LCD_VAT              0x0C
0017 #define JZ_REG_LCD_DAH              0x10
0018 #define JZ_REG_LCD_DAV              0x14
0019 #define JZ_REG_LCD_PS               0x18
0020 #define JZ_REG_LCD_CLS              0x1C
0021 #define JZ_REG_LCD_SPL              0x20
0022 #define JZ_REG_LCD_REV              0x24
0023 #define JZ_REG_LCD_CTRL             0x30
0024 #define JZ_REG_LCD_STATE            0x34
0025 #define JZ_REG_LCD_IID              0x38
0026 #define JZ_REG_LCD_DA0              0x40
0027 #define JZ_REG_LCD_SA0              0x44
0028 #define JZ_REG_LCD_FID0             0x48
0029 #define JZ_REG_LCD_CMD0             0x4C
0030 #define JZ_REG_LCD_DA1              0x50
0031 #define JZ_REG_LCD_SA1              0x54
0032 #define JZ_REG_LCD_FID1             0x58
0033 #define JZ_REG_LCD_CMD1             0x5C
0034 #define JZ_REG_LCD_RGBC             0x90
0035 #define JZ_REG_LCD_OSDC             0x100
0036 #define JZ_REG_LCD_OSDCTRL          0x104
0037 #define JZ_REG_LCD_OSDS             0x108
0038 #define JZ_REG_LCD_BGC              0x10c
0039 #define JZ_REG_LCD_KEY0             0x110
0040 #define JZ_REG_LCD_KEY1             0x114
0041 #define JZ_REG_LCD_ALPHA            0x118
0042 #define JZ_REG_LCD_IPUR             0x11c
0043 #define JZ_REG_LCD_XYP0             0x120
0044 #define JZ_REG_LCD_XYP1             0x124
0045 #define JZ_REG_LCD_SIZE0            0x128
0046 #define JZ_REG_LCD_SIZE1            0x12c
0047 #define JZ_REG_LCD_PCFG             0x2c0
0048 
0049 #define JZ_LCD_CFG_SLCD             BIT(31)
0050 #define JZ_LCD_CFG_DESCRIPTOR_8         BIT(28)
0051 #define JZ_LCD_CFG_RECOVER_FIFO_UNDERRUN    BIT(25)
0052 #define JZ_LCD_CFG_PS_DISABLE           BIT(23)
0053 #define JZ_LCD_CFG_CLS_DISABLE          BIT(22)
0054 #define JZ_LCD_CFG_SPL_DISABLE          BIT(21)
0055 #define JZ_LCD_CFG_REV_DISABLE          BIT(20)
0056 #define JZ_LCD_CFG_HSYNCM           BIT(19)
0057 #define JZ_LCD_CFG_PCLKM            BIT(18)
0058 #define JZ_LCD_CFG_INV              BIT(17)
0059 #define JZ_LCD_CFG_SYNC_DIR         BIT(16)
0060 #define JZ_LCD_CFG_PS_POLARITY          BIT(15)
0061 #define JZ_LCD_CFG_CLS_POLARITY         BIT(14)
0062 #define JZ_LCD_CFG_SPL_POLARITY         BIT(13)
0063 #define JZ_LCD_CFG_REV_POLARITY         BIT(12)
0064 #define JZ_LCD_CFG_HSYNC_ACTIVE_LOW     BIT(11)
0065 #define JZ_LCD_CFG_PCLK_FALLING_EDGE        BIT(10)
0066 #define JZ_LCD_CFG_DE_ACTIVE_LOW        BIT(9)
0067 #define JZ_LCD_CFG_VSYNC_ACTIVE_LOW     BIT(8)
0068 #define JZ_LCD_CFG_18_BIT           BIT(7)
0069 #define JZ_LCD_CFG_24_BIT           BIT(6)
0070 #define JZ_LCD_CFG_PDW              (BIT(5) | BIT(4))
0071 
0072 #define JZ_LCD_CFG_MODE_GENERIC_16BIT       0
0073 #define JZ_LCD_CFG_MODE_GENERIC_18BIT       BIT(7)
0074 #define JZ_LCD_CFG_MODE_GENERIC_24BIT       BIT(6)
0075 
0076 #define JZ_LCD_CFG_MODE_SPECIAL_TFT_1       1
0077 #define JZ_LCD_CFG_MODE_SPECIAL_TFT_2       2
0078 #define JZ_LCD_CFG_MODE_SPECIAL_TFT_3       3
0079 
0080 #define JZ_LCD_CFG_MODE_TV_OUT_P        4
0081 #define JZ_LCD_CFG_MODE_TV_OUT_I        6
0082 
0083 #define JZ_LCD_CFG_MODE_SINGLE_COLOR_STN    8
0084 #define JZ_LCD_CFG_MODE_SINGLE_MONOCHROME_STN   9
0085 #define JZ_LCD_CFG_MODE_DUAL_COLOR_STN      10
0086 #define JZ_LCD_CFG_MODE_DUAL_MONOCHROME_STN 11
0087 
0088 #define JZ_LCD_CFG_MODE_8BIT_SERIAL     12
0089 #define JZ_LCD_CFG_MODE_LCM         13
0090 
0091 #define JZ_LCD_VSYNC_VPS_OFFSET         16
0092 #define JZ_LCD_VSYNC_VPE_OFFSET         0
0093 
0094 #define JZ_LCD_HSYNC_HPS_OFFSET         16
0095 #define JZ_LCD_HSYNC_HPE_OFFSET         0
0096 
0097 #define JZ_LCD_VAT_HT_OFFSET            16
0098 #define JZ_LCD_VAT_VT_OFFSET            0
0099 
0100 #define JZ_LCD_DAH_HDS_OFFSET           16
0101 #define JZ_LCD_DAH_HDE_OFFSET           0
0102 
0103 #define JZ_LCD_DAV_VDS_OFFSET           16
0104 #define JZ_LCD_DAV_VDE_OFFSET           0
0105 
0106 #define JZ_LCD_CTRL_BURST_4         (0x0 << 28)
0107 #define JZ_LCD_CTRL_BURST_8         (0x1 << 28)
0108 #define JZ_LCD_CTRL_BURST_16            (0x2 << 28)
0109 #define JZ_LCD_CTRL_BURST_32            (0x3 << 28)
0110 #define JZ_LCD_CTRL_BURST_64            (0x4 << 28)
0111 #define JZ_LCD_CTRL_BURST_MASK          (0x7 << 28)
0112 #define JZ_LCD_CTRL_RGB555          BIT(27)
0113 #define JZ_LCD_CTRL_OFUP            BIT(26)
0114 #define JZ_LCD_CTRL_FRC_GRAYSCALE_16        (0x0 << 24)
0115 #define JZ_LCD_CTRL_FRC_GRAYSCALE_4     (0x1 << 24)
0116 #define JZ_LCD_CTRL_FRC_GRAYSCALE_2     (0x2 << 24)
0117 #define JZ_LCD_CTRL_PDD_MASK            (0xff << 16)
0118 #define JZ_LCD_CTRL_EOF_IRQ         BIT(13)
0119 #define JZ_LCD_CTRL_SOF_IRQ         BIT(12)
0120 #define JZ_LCD_CTRL_OFU_IRQ         BIT(11)
0121 #define JZ_LCD_CTRL_IFU0_IRQ            BIT(10)
0122 #define JZ_LCD_CTRL_IFU1_IRQ            BIT(9)
0123 #define JZ_LCD_CTRL_DD_IRQ          BIT(8)
0124 #define JZ_LCD_CTRL_QDD_IRQ         BIT(7)
0125 #define JZ_LCD_CTRL_REVERSE_ENDIAN      BIT(6)
0126 #define JZ_LCD_CTRL_LSB_FISRT           BIT(5)
0127 #define JZ_LCD_CTRL_DISABLE         BIT(4)
0128 #define JZ_LCD_CTRL_ENABLE          BIT(3)
0129 #define JZ_LCD_CTRL_BPP_1           0x0
0130 #define JZ_LCD_CTRL_BPP_2           0x1
0131 #define JZ_LCD_CTRL_BPP_4           0x2
0132 #define JZ_LCD_CTRL_BPP_8           0x3
0133 #define JZ_LCD_CTRL_BPP_15_16           0x4
0134 #define JZ_LCD_CTRL_BPP_18_24           0x5
0135 #define JZ_LCD_CTRL_BPP_24_COMP         0x6
0136 #define JZ_LCD_CTRL_BPP_30          0x7
0137 #define JZ_LCD_CTRL_BPP_MASK            (JZ_LCD_CTRL_RGB555 | 0x7)
0138 
0139 #define JZ_LCD_CMD_SOF_IRQ          BIT(31)
0140 #define JZ_LCD_CMD_EOF_IRQ          BIT(30)
0141 #define JZ_LCD_CMD_ENABLE_PAL           BIT(28)
0142 #define JZ_LCD_CMD_FRM_ENABLE           BIT(26)
0143 
0144 #define JZ_LCD_SYNC_MASK            0x3ff
0145 
0146 #define JZ_LCD_STATE_EOF_IRQ            BIT(5)
0147 #define JZ_LCD_STATE_SOF_IRQ            BIT(4)
0148 #define JZ_LCD_STATE_DISABLED           BIT(0)
0149 
0150 #define JZ_LCD_RGBC_ODD_RGB         (0x0 << 4)
0151 #define JZ_LCD_RGBC_ODD_RBG         (0x1 << 4)
0152 #define JZ_LCD_RGBC_ODD_GRB         (0x2 << 4)
0153 #define JZ_LCD_RGBC_ODD_GBR         (0x3 << 4)
0154 #define JZ_LCD_RGBC_ODD_BRG         (0x4 << 4)
0155 #define JZ_LCD_RGBC_ODD_BGR         (0x5 << 4)
0156 #define JZ_LCD_RGBC_EVEN_RGB            (0x0 << 0)
0157 #define JZ_LCD_RGBC_EVEN_RBG            (0x1 << 0)
0158 #define JZ_LCD_RGBC_EVEN_GRB            (0x2 << 0)
0159 #define JZ_LCD_RGBC_EVEN_GBR            (0x3 << 0)
0160 #define JZ_LCD_RGBC_EVEN_BRG            (0x4 << 0)
0161 #define JZ_LCD_RGBC_EVEN_BGR            (0x5 << 0)
0162 
0163 #define JZ_LCD_OSDC_OSDEN           BIT(0)
0164 #define JZ_LCD_OSDC_ALPHAEN         BIT(2)
0165 #define JZ_LCD_OSDC_F0EN            BIT(3)
0166 #define JZ_LCD_OSDC_F1EN            BIT(4)
0167 
0168 #define JZ_LCD_OSDCTRL_IPU          BIT(15)
0169 #define JZ_LCD_OSDCTRL_RGB555           BIT(4)
0170 #define JZ_LCD_OSDCTRL_CHANGE           BIT(3)
0171 #define JZ_LCD_OSDCTRL_BPP_15_16        0x4
0172 #define JZ_LCD_OSDCTRL_BPP_18_24        0x5
0173 #define JZ_LCD_OSDCTRL_BPP_24_COMP      0x6
0174 #define JZ_LCD_OSDCTRL_BPP_30           0x7
0175 #define JZ_LCD_OSDCTRL_BPP_MASK         (JZ_LCD_OSDCTRL_RGB555 | 0x7)
0176 
0177 #define JZ_LCD_OSDS_READY           BIT(0)
0178 
0179 #define JZ_LCD_IPUR_IPUREN          BIT(31)
0180 #define JZ_LCD_IPUR_IPUR_LSB            0
0181 
0182 #define JZ_LCD_XYP01_XPOS_LSB           0
0183 #define JZ_LCD_XYP01_YPOS_LSB           16
0184 
0185 #define JZ_LCD_SIZE01_WIDTH_LSB         0
0186 #define JZ_LCD_SIZE01_HEIGHT_LSB        16
0187 
0188 #define JZ_LCD_DESSIZE_ALPHA_OFFSET     24
0189 #define JZ_LCD_DESSIZE_HEIGHT_MASK      GENMASK(23, 12)
0190 #define JZ_LCD_DESSIZE_WIDTH_MASK       GENMASK(11, 0)
0191 
0192 #define JZ_LCD_CPOS_BPP_15_16           (4 << 27)
0193 #define JZ_LCD_CPOS_BPP_18_24           (5 << 27)
0194 #define JZ_LCD_CPOS_BPP_30          (7 << 27)
0195 #define JZ_LCD_CPOS_RGB555          BIT(30)
0196 #define JZ_LCD_CPOS_PREMULTIPLY_LCD     BIT(26)
0197 #define JZ_LCD_CPOS_COEFFICIENT_OFFSET      24
0198 #define JZ_LCD_CPOS_COEFFICIENT_0       0
0199 #define JZ_LCD_CPOS_COEFFICIENT_1       1
0200 #define JZ_LCD_CPOS_COEFFICIENT_ALPHA1      2
0201 #define JZ_LCD_CPOS_COEFFICIENT_1_ALPHA1    3
0202 
0203 #define JZ_LCD_RGBC_RGB_PADDING         BIT(15)
0204 #define JZ_LCD_RGBC_RGB_PADDING_FIRST       BIT(14)
0205 #define JZ_LCD_RGBC_422             BIT(8)
0206 #define JZ_LCD_RGBC_RGB_FORMAT_ENABLE       BIT(7)
0207 
0208 #define JZ_LCD_PCFG_PRI_MODE            BIT(31)
0209 #define JZ_LCD_PCFG_HP_BST_4            (0 << 28)
0210 #define JZ_LCD_PCFG_HP_BST_8            (1 << 28)
0211 #define JZ_LCD_PCFG_HP_BST_16           (2 << 28)
0212 #define JZ_LCD_PCFG_HP_BST_32           (3 << 28)
0213 #define JZ_LCD_PCFG_HP_BST_64           (4 << 28)
0214 #define JZ_LCD_PCFG_HP_BST_16_CONT      (5 << 28)
0215 #define JZ_LCD_PCFG_HP_BST_DISABLE      (7 << 28)
0216 #define JZ_LCD_PCFG_THRESHOLD2_OFFSET       18
0217 #define JZ_LCD_PCFG_THRESHOLD1_OFFSET       9
0218 #define JZ_LCD_PCFG_THRESHOLD0_OFFSET       0
0219 
0220 struct device;
0221 struct drm_plane;
0222 struct drm_plane_state;
0223 struct platform_driver;
0224 
0225 void ingenic_drm_plane_config(struct device *dev,
0226                   struct drm_plane *plane, u32 fourcc);
0227 void ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane);
0228 bool ingenic_drm_map_noncoherent(const struct device *dev);
0229 
0230 extern struct platform_driver *ingenic_ipu_driver_ptr;
0231 
0232 #endif /* DRIVERS_GPU_DRM_INGENIC_INGENIC_DRM_H */