28 #ifndef __MDFLD_DSI_OUTPUT_H__
29 #define __MDFLD_DSI_OUTPUT_H__
44 #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end))
45 #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
46 #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
47 #define FLD_MOD(orig, val, start, end) \
48 (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
50 #define REG_FLD_MOD(reg, val, start, end) \
51 REG_WRITE(reg, FLD_MOD(REG_READ(reg), val, start, end))
66 #define REG_FLD_WAIT(reg, val, start, end) \
67 REGISTER_FLD_WAIT(dev, reg, val, start, end)
69 #define REG_BIT_WAIT(reg, val, bitnum) \
70 REGISTER_FLD_WAIT(dev, reg, val, bitnum, bitnum)
72 #define MDFLD_DSI_BRIGHTNESS_MAX_LEVEL 100
75 #define CHECK_PIPE(pipe) ({ \
76 const typeof(pipe) __pipe = (pipe); \
77 BUG_ON(__pipe != 0 && __pipe != 2); \
80 #define CHECK_PIPE(pipe) (pipe)
86 #define REG_OFFSET(pipe) (CHECK_PIPE(pipe) * 0x400)
89 #define MIPI_DEVICE_READY_REG(pipe) (0xb000 + REG_OFFSET(pipe))
90 #define MIPI_INTR_STAT_REG(pipe) (0xb004 + REG_OFFSET(pipe))
91 #define MIPI_INTR_EN_REG(pipe) (0xb008 + REG_OFFSET(pipe))
92 #define MIPI_DSI_FUNC_PRG_REG(pipe) (0xb00c + REG_OFFSET(pipe))
93 #define MIPI_HS_TX_TIMEOUT_REG(pipe) (0xb010 + REG_OFFSET(pipe))
94 #define MIPI_LP_RX_TIMEOUT_REG(pipe) (0xb014 + REG_OFFSET(pipe))
95 #define MIPI_TURN_AROUND_TIMEOUT_REG(pipe) (0xb018 + REG_OFFSET(pipe))
96 #define MIPI_DEVICE_RESET_TIMER_REG(pipe) (0xb01c + REG_OFFSET(pipe))
97 #define MIPI_DPI_RESOLUTION_REG(pipe) (0xb020 + REG_OFFSET(pipe))
98 #define MIPI_DBI_FIFO_THROTTLE_REG(pipe) (0xb024 + REG_OFFSET(pipe))
99 #define MIPI_HSYNC_COUNT_REG(pipe) (0xb028 + REG_OFFSET(pipe))
100 #define MIPI_HBP_COUNT_REG(pipe) (0xb02c + REG_OFFSET(pipe))
101 #define MIPI_HFP_COUNT_REG(pipe) (0xb030 + REG_OFFSET(pipe))
102 #define MIPI_HACTIVE_COUNT_REG(pipe) (0xb034 + REG_OFFSET(pipe))
103 #define MIPI_VSYNC_COUNT_REG(pipe) (0xb038 + REG_OFFSET(pipe))
104 #define MIPI_VBP_COUNT_REG(pipe) (0xb03c + REG_OFFSET(pipe))
105 #define MIPI_VFP_COUNT_REG(pipe) (0xb040 + REG_OFFSET(pipe))
106 #define MIPI_HIGH_LOW_SWITCH_COUNT_REG(pipe) (0xb044 + REG_OFFSET(pipe))
107 #define MIPI_DPI_CONTROL_REG(pipe) (0xb048 + REG_OFFSET(pipe))
108 #define MIPI_DPI_DATA_REG(pipe) (0xb04c + REG_OFFSET(pipe))
109 #define MIPI_INIT_COUNT_REG(pipe) (0xb050 + REG_OFFSET(pipe))
110 #define MIPI_MAX_RETURN_PACK_SIZE_REG(pipe) (0xb054 + REG_OFFSET(pipe))
111 #define MIPI_VIDEO_MODE_FORMAT_REG(pipe) (0xb058 + REG_OFFSET(pipe))
112 #define MIPI_EOT_DISABLE_REG(pipe) (0xb05c + REG_OFFSET(pipe))
113 #define MIPI_LP_BYTECLK_REG(pipe) (0xb060 + REG_OFFSET(pipe))
114 #define MIPI_LP_GEN_DATA_REG(pipe) (0xb064 + REG_OFFSET(pipe))
115 #define MIPI_HS_GEN_DATA_REG(pipe) (0xb068 + REG_OFFSET(pipe))
116 #define MIPI_LP_GEN_CTRL_REG(pipe) (0xb06c + REG_OFFSET(pipe))
117 #define MIPI_HS_GEN_CTRL_REG(pipe) (0xb070 + REG_OFFSET(pipe))
118 #define MIPI_GEN_FIFO_STAT_REG(pipe) (0xb074 + REG_OFFSET(pipe))
119 #define MIPI_HS_LS_DBI_ENABLE_REG(pipe) (0xb078 + REG_OFFSET(pipe))
120 #define MIPI_DPHY_PARAM_REG(pipe) (0xb080 + REG_OFFSET(pipe))
121 #define MIPI_DBI_BW_CTRL_REG(pipe) (0xb084 + REG_OFFSET(pipe))
122 #define MIPI_CLK_LANE_SWITCH_TIME_CNT_REG(pipe) (0xb088 + REG_OFFSET(pipe))
124 #define MIPI_CTRL_REG(pipe) (0xb104 + REG_OFFSET(pipe))
125 #define MIPI_DATA_ADD_REG(pipe) (0xb108 + REG_OFFSET(pipe))
126 #define MIPI_DATA_LEN_REG(pipe) (0xb10c + REG_OFFSET(pipe))
127 #define MIPI_CMD_ADD_REG(pipe) (0xb110 + REG_OFFSET(pipe))
128 #define MIPI_CMD_LEN_REG(pipe) (0xb114 + REG_OFFSET(pipe))
131 #define MIPI_PORT_CONTROL(pipe) (CHECK_PIPE(pipe) ? MIPI_C : MIPI)
133 #define DSI_DEVICE_READY (0x1)
134 #define DSI_POWER_STATE_ULPS_ENTER (0x2 << 1)
135 #define DSI_POWER_STATE_ULPS_EXIT (0x1 << 1)
136 #define DSI_POWER_STATE_ULPS_OFFSET (0x1)
139 #define DSI_ONE_DATA_LANE (0x1)
140 #define DSI_TWO_DATA_LANE (0x2)
141 #define DSI_THREE_DATA_LANE (0X3)
142 #define DSI_FOUR_DATA_LANE (0x4)
143 #define DSI_DPI_VIRT_CHANNEL_OFFSET (0x3)
144 #define DSI_DBI_VIRT_CHANNEL_OFFSET (0x5)
145 #define DSI_DPI_COLOR_FORMAT_RGB565 (0x01 << 7)
146 #define DSI_DPI_COLOR_FORMAT_RGB666 (0x02 << 7)
147 #define DSI_DPI_COLOR_FORMAT_RGB666_UNPACK (0x03 << 7)
148 #define DSI_DPI_COLOR_FORMAT_RGB888 (0x04 << 7)
149 #define DSI_DBI_COLOR_FORMAT_OPTION2 (0x05 << 13)
151 #define DSI_INTR_STATE_RXSOTERROR BIT(0)
153 #define DSI_INTR_STATE_SPL_PKG_SENT BIT(30)
154 #define DSI_INTR_STATE_TE BIT(31)
156 #define DSI_HS_TX_TIMEOUT_MASK (0xffffff)
158 #define DSI_LP_RX_TIMEOUT_MASK (0xffffff)
160 #define DSI_TURN_AROUND_TIMEOUT_MASK (0x3f)
162 #define DSI_RESET_TIMER_MASK (0xffff)
164 #define DSI_DBI_FIFO_WM_HALF (0x0)
165 #define DSI_DBI_FIFO_WM_QUARTER (0x1)
166 #define DSI_DBI_FIFO_WM_LOW (0x2)
168 #define DSI_DPI_TIMING_MASK (0xffff)
170 #define DSI_INIT_TIMER_MASK (0xffff)
172 #define DSI_DBI_RETURN_PACK_SIZE_MASK (0x3ff)
174 #define DSI_LP_BYTECLK_MASK (0x0ffff)
176 #define DSI_HS_CTRL_GEN_SHORT_W0 (0x03)
177 #define DSI_HS_CTRL_GEN_SHORT_W1 (0x13)
178 #define DSI_HS_CTRL_GEN_SHORT_W2 (0x23)
179 #define DSI_HS_CTRL_GEN_R0 (0x04)
180 #define DSI_HS_CTRL_GEN_R1 (0x14)
181 #define DSI_HS_CTRL_GEN_R2 (0x24)
182 #define DSI_HS_CTRL_GEN_LONG_W (0x29)
183 #define DSI_HS_CTRL_MCS_SHORT_W0 (0x05)
184 #define DSI_HS_CTRL_MCS_SHORT_W1 (0x15)
185 #define DSI_HS_CTRL_MCS_R0 (0x06)
186 #define DSI_HS_CTRL_MCS_LONG_W (0x39)
187 #define DSI_HS_CTRL_VC_OFFSET (0x06)
188 #define DSI_HS_CTRL_WC_OFFSET (0x08)
190 #define DSI_FIFO_GEN_HS_DATA_FULL BIT(0)
191 #define DSI_FIFO_GEN_HS_DATA_HALF_EMPTY BIT(1)
192 #define DSI_FIFO_GEN_HS_DATA_EMPTY BIT(2)
193 #define DSI_FIFO_GEN_LP_DATA_FULL BIT(8)
194 #define DSI_FIFO_GEN_LP_DATA_HALF_EMPTY BIT(9)
195 #define DSI_FIFO_GEN_LP_DATA_EMPTY BIT(10)
196 #define DSI_FIFO_GEN_HS_CTRL_FULL BIT(16)
197 #define DSI_FIFO_GEN_HS_CTRL_HALF_EMPTY BIT(17)
198 #define DSI_FIFO_GEN_HS_CTRL_EMPTY BIT(18)
199 #define DSI_FIFO_GEN_LP_CTRL_FULL BIT(24)
200 #define DSI_FIFO_GEN_LP_CTRL_HALF_EMPTY BIT(25)
201 #define DSI_FIFO_GEN_LP_CTRL_EMPTY BIT(26)
202 #define DSI_FIFO_DBI_EMPTY BIT(27)
203 #define DSI_FIFO_DPI_EMPTY BIT(28)
205 #define DSI_DBI_HS_LP_SWITCH_MASK (0x1)
207 #define DSI_HS_LP_SWITCH_COUNTER_OFFSET (0x0)
208 #define DSI_LP_HS_SWITCH_COUNTER_OFFSET (0x16)
210 #define DSI_DPI_CTRL_HS_SHUTDOWN (0x00000001)
211 #define DSI_DPI_CTRL_HS_TURN_ON (0x00000002)
214 #define DSI_POWER_MODE_DISPLAY_ON BIT(2)
215 #define DSI_POWER_MODE_NORMAL_ON BIT(3)
216 #define DSI_POWER_MODE_SLEEP_OUT BIT(4)
217 #define DSI_POWER_MODE_PARTIAL_ON BIT(5)
218 #define DSI_POWER_MODE_IDLE_ON BIT(6)
226 #define DSI_DPI_COMPLETE_LAST_LINE BIT(2)
227 #define DSI_DPI_DISABLE_BTA BIT(3)
328 config = mdfld_dsi_encoder_get_config(encoder);
335 static inline void *mdfld_dsi_encoder_get_pkg_sender(
340 dsi_config = mdfld_dsi_encoder_get_config(encoder);
344 return mdfld_dsi_get_pkg_sender(dsi_config);
354 connector = mdfld_dsi_encoder_get_connector(encoder);
357 return connector->
pipe;
362 u32 gen_fifo_stat_reg,
u32 fifo_stat);