1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2020 Rockchip Electronics Co. Ltd. 4 * 5 * Author: Guochun Huang <hero.huang@rock-chips.com> 6 */ 7 8 #ifndef RK628_DSI_H 9 #define RK628_DSI_H 10 #include "rk628.h" 11 12 #define DSI0_BASE 0x50000 13 #define DSI1_BASE 0x60000 14 15 #define DSI_VERSION 0x0000 16 #define DSI_PWR_UP 0x0004 17 #define RESET 0 18 #define POWER_UP BIT(0) 19 #define DSI_CLKMGR_CFG 0x0008 20 #define TO_CLK_DIVISION(x) UPDATE(x, 15, 8) 21 #define TX_ESC_CLK_DIVISION(x) UPDATE(x, 7, 0) 22 #define DSI_DPI_VCID 0x000c 23 #define DPI_VID(x) UPDATE(x, 1, 0) 24 #define DSI_DPI_COLOR_CODING 0x0010 25 #define LOOSELY18_EN BIT(8) 26 #define DPI_COLOR_CODING(x) UPDATE(x, 3, 0) 27 #define DSI_DPI_CFG_POL 0x0014 28 #define COLORM_ACTIVE_LOW BIT(4) 29 #define SHUTD_ACTIVE_LOW BIT(3) 30 #define HSYNC_ACTIVE_LOW BIT(2) 31 #define VSYNC_ACTIVE_LOW BIT(1) 32 #define DATAEN_ACTIVE_LOW BIT(0) 33 #define DSI_DPI_LP_CMD_TIM 0x0018 34 #define OUTVACT_LPCMD_TIME(x) UPDATE(x, 23, 16) 35 #define INVACT_LPCMD_TIME(x) UPDATE(x, 7, 0) 36 #define DSI_PCKHDL_CFG 0x002c 37 #define CRC_RX_EN BIT(4) 38 #define ECC_RX_EN BIT(3) 39 #define BTA_EN BIT(2) 40 #define EOTP_RX_EN BIT(1) 41 #define EOTP_TX_EN BIT(0) 42 #define DSI_GEN_VCID 0x0030 43 #define DSI_MODE_CFG 0x0034 44 #define CMD_VIDEO_MODE(x) UPDATE(x, 0, 0) 45 #define DSI_VID_MODE_CFG 0x0038 46 #define VPG_EN BIT(16) 47 #define LP_CMD_EN BIT(15) 48 #define FRAME_BTA_ACK_EN BIT(14) 49 #define LP_HFP_EN BIT(13) 50 #define LP_HBP_EN BIT(12) 51 #define LP_VACT_EN BIT(11) 52 #define LP_VFP_EN BIT(10) 53 #define LP_VBP_EN BIT(9) 54 #define LP_VSA_EN BIT(8) 55 #define VID_MODE_TYPE(x) UPDATE(x, 1, 0) 56 #define DSI_VID_PKT_SIZE 0x003c 57 #define VID_PKT_SIZE(x) UPDATE(x, 13, 0) 58 #define DSI_VID_NUM_CHUNKS 0x0040 59 #define DSI_VID_NULL_SIZE 0x0044 60 #define DSI_VID_HSA_TIME 0x0048 61 #define VID_HSA_TIME(x) UPDATE(x, 11, 0) 62 #define DSI_VID_HBP_TIME 0x004c 63 #define VID_HBP_TIME(x) UPDATE(x, 11, 0) 64 #define DSI_VID_HLINE_TIME 0x0050 65 #define VID_HLINE_TIME(x) UPDATE(x, 14, 0) 66 #define DSI_VID_VSA_LINES 0x0054 67 #define VSA_LINES(x) UPDATE(x, 9, 0) 68 #define DSI_VID_VBP_LINES 0x0058 69 #define VBP_LINES(x) UPDATE(x, 9, 0) 70 #define DSI_VID_VFP_LINES 0x005c 71 #define VFP_LINES(x) UPDATE(x, 9, 0) 72 #define DSI_VID_VACTIVE_LINES 0x0060 73 #define V_ACTIVE_LINES(x) UPDATE(x, 13, 0) 74 #define DSI_EDPI_CMD_SIZE 0x0064 75 #define EDPI_ALLOWED_CMD_SIZE(x) UPDATE(x, 15, 0) 76 #define DSI_CMD_MODE_CFG 0x0068 77 #define MAX_RD_PKT_SIZE BIT(24) 78 #define DCS_LW_TX BIT(19) 79 #define DCS_SR_0P_TX BIT(18) 80 #define DCS_SW_1P_TX BIT(17) 81 #define DCS_SW_0P_TX BIT(16) 82 #define GEN_LW_TX BIT(14) 83 #define GEN_SR_2P_TX BIT(13) 84 #define GEN_SR_1P_TX BIT(12) 85 #define GEN_SR_0P_TX BIT(11) 86 #define GEN_SW_2P_TX BIT(10) 87 #define GEN_SW_1P_TX BIT(9) 88 #define GEN_SW_0P_TX BIT(8) 89 #define ACK_RQST_EN BIT(1) 90 #define TEAR_FX_EN BIT(0) 91 #define DSI_GEN_HDR 0x006c 92 #define GEN_WC_MSBYTE(x) UPDATE(x, 23, 16) 93 #define GEN_WC_LSBYTE(x) UPDATE(x, 15, 8) 94 #define GEN_VC(x) UPDATE(x, 7, 6) 95 #define GEN_DT(x) UPDATE(x, 5, 0) 96 #define DSI_GEN_PLD_DATA 0x0070 97 #define DSI_CMD_PKT_STATUS 0x0074 98 #define GEN_RD_CMD_BUSY BIT(6) 99 #define GEN_PLD_R_FULL BIT(5) 100 #define GEN_PLD_R_EMPTY BIT(4) 101 #define GEN_PLD_W_FULL BIT(3) 102 #define GEN_PLD_W_EMPTY BIT(2) 103 #define GEN_CMD_FULL BIT(1) 104 #define GEN_CMD_EMPTY BIT(0) 105 #define DSI_TO_CNT_CFG 0x0078 106 #define HSTX_TO_CNT(x) UPDATE(x, 31, 16) 107 #define LPRX_TO_CNT(x) UPDATE(x, 15, 0) 108 #define DSI_HS_RD_TO_CNT 0x007c 109 #define HS_RD_TO_CNT(x) UPDATE(x, 15, 0) 110 #define DSI_LP_RD_TO_CNT 0x0080 111 #define LP_RD_TO_CNT(x) UPDATE(x, 15, 0) 112 #define DSI_HS_WR_TO_CNT 0x0084 113 #define HS_WR_TO_CNT(x) UPDATE(x, 15, 0) 114 #define DSI_LP_WR_TO_CNT 0x0088 115 #define LP_WR_TO_CNT(x) UPDATE(x, 15, 0) 116 #define DSI_BTA_TO_CNT 0x008c 117 #define BTA_TO_CNT(x) UPDATE(x, 15, 0) 118 #define DSI_SDF_3D 0x0090 119 #define DSI_LPCLK_CTRL 0x0094 120 #define AUTO_CLKLANE_CTRL BIT(1) 121 #define PHY_TXREQUESTCLKHS BIT(0) 122 #define DSI_PHY_TMR_LPCLK_CFG 0x0098 123 #define PHY_CLKHS2LP_TIME(x) UPDATE(x, 25, 16) 124 #define PHY_CLKLP2HS_TIME(x) UPDATE(x, 9, 0) 125 #define DSI_PHY_TMR_CFG 0x009c 126 #define PHY_HS2LP_TIME(x) UPDATE(x, 31, 24) 127 #define PHY_LP2HS_TIME(x) UPDATE(x, 23, 16) 128 #define MAX_RD_TIME(x) UPDATE(x, 14, 0) 129 #define DSI_PHY_RSTZ 0x00a0 130 #define PHY_FORCEPLL BIT(3) 131 #define PHY_ENABLECLK BIT(2) 132 #define PHY_RSTZ BIT(1) 133 #define PHY_SHUTDOWNZ BIT(0) 134 #define DSI_PHY_IF_CFG 0x00a4 135 #define PHY_STOP_WAIT_TIME(x) UPDATE(x, 15, 8) 136 #define N_LANES(x) UPDATE(x, 1, 0) 137 #define DSI_PHY_STATUS 0x00b0 138 #define PHY_STOPSTATE3LANE BIT(11) 139 #define PHY_STOPSTATE2LANE BIT(9) 140 #define PHY_STOPSTATE1LANE BIT(7) 141 #define PHY_STOPSTATE0LANE BIT(4) 142 #define PHY_STOPSTATECLKLANE BIT(2) 143 #define PHY_LOCK BIT(0) 144 #define PHY_STOPSTATELANE (PHY_STOPSTATE0LANE | \ 145 PHY_STOPSTATECLKLANE) 146 #define DSI_INT_ST0 0x00bc 147 #define DSI_INT_ST1 0x00c0 148 #define DSI_INT_MSK0 0x00c4 149 #define DSI_INT_MSK1 0x00c8 150 #define DSI_INT_FORCE0 0x00d8 151 #define DSI_INT_FORCE1 0x00dc 152 #define DSI_MAX_REGISTER DSI_INT_FORCE1 153 154 int rk628_dsi_parse(struct rk628 *rk628, struct device_node *dsi_np); 155 void rk628_mipi_dsi_pre_enable(struct rk628 *rk628); 156 void rk628_mipi_dsi_enable(struct rk628 *rk628); 157 void rk628_dsi_disable(struct rk628 *rk628); 158 #endif 159