blob: c77065c6224add5f8dbcc911afe4ff255174055e [file] [log] [blame]
Ajay Singh Parmar75098882016-05-16 17:43:17 -07001/*
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +05302 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Ajay Singh Parmar75098882016-05-16 17:43:17 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
Ajay Singh Parmar75098882016-05-16 17:43:17 -070012 */
13
14#ifndef _DSI_CTRL_HW_H_
15#define _DSI_CTRL_HW_H_
16
17#include <linux/kernel.h>
18#include <linux/types.h>
19#include <linux/bitops.h>
20#include <linux/bitmap.h>
21
22#include "dsi_defs.h"
23
24/**
25 * Modifier flag for command transmission. If this flag is set, command
26 * information is programmed to hardware and transmission is not triggered.
27 * Caller should call the trigger_command_dma() to start the transmission. This
28 * flag is valed for kickoff_command() and kickoff_fifo_command() operations.
29 */
30#define DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER 0x1
31
32/**
33 * enum dsi_ctrl_version - version of the dsi host controller
34 * @DSI_CTRL_VERSION_UNKNOWN: Unknown controller version
35 * @DSI_CTRL_VERSION_1_4: DSI host v1.4 controller
36 * @DSI_CTRL_VERSION_2_0: DSI host v2.0 controller
37 * @DSI_CTRL_VERSION_MAX: max version
38 */
39enum dsi_ctrl_version {
40 DSI_CTRL_VERSION_UNKNOWN,
41 DSI_CTRL_VERSION_1_4,
42 DSI_CTRL_VERSION_2_0,
Shashank Babu Chinta Venkataafef8202017-04-21 13:49:56 -070043 DSI_CTRL_VERSION_2_2,
Ajay Singh Parmar75098882016-05-16 17:43:17 -070044 DSI_CTRL_VERSION_MAX
45};
46
47/**
48 * enum dsi_ctrl_hw_features - features supported by dsi host controller
49 * @DSI_CTRL_VIDEO_TPG: Test pattern support for video mode.
50 * @DSI_CTRL_CMD_TPG: Test pattern support for command mode.
51 * @DSI_CTRL_VARIABLE_REFRESH_RATE: variable panel timing
52 * @DSI_CTRL_DYNAMIC_REFRESH: variable pixel clock rate
53 * @DSI_CTRL_NULL_PACKET_INSERTION: NULL packet insertion
54 * @DSI_CTRL_DESKEW_CALIB: Deskew calibration support
55 * @DSI_CTRL_DPHY: Controller support for DPHY
56 * @DSI_CTRL_CPHY: Controller support for CPHY
57 * @DSI_CTRL_MAX_FEATURES:
58 */
59enum dsi_ctrl_hw_features {
60 DSI_CTRL_VIDEO_TPG,
61 DSI_CTRL_CMD_TPG,
62 DSI_CTRL_VARIABLE_REFRESH_RATE,
63 DSI_CTRL_DYNAMIC_REFRESH,
64 DSI_CTRL_NULL_PACKET_INSERTION,
65 DSI_CTRL_DESKEW_CALIB,
66 DSI_CTRL_DPHY,
67 DSI_CTRL_CPHY,
68 DSI_CTRL_MAX_FEATURES
69};
70
71/**
72 * enum dsi_test_pattern - test pattern type
73 * @DSI_TEST_PATTERN_FIXED: Test pattern is fixed, based on init value.
74 * @DSI_TEST_PATTERN_INC: Incremental test pattern, base on init value.
75 * @DSI_TEST_PATTERN_POLY: Pattern generated from polynomial and init val.
76 * @DSI_TEST_PATTERN_MAX:
77 */
78enum dsi_test_pattern {
79 DSI_TEST_PATTERN_FIXED = 0,
80 DSI_TEST_PATTERN_INC,
81 DSI_TEST_PATTERN_POLY,
82 DSI_TEST_PATTERN_MAX
83};
84
85/**
Clarence Ip80ada7f2017-05-04 09:55:21 -070086 * enum dsi_status_int_index - index of interrupts generated by DSI controller
87 * @DSI_SINT_CMD_MODE_DMA_DONE: Command mode DMA packets are sent out.
88 * @DSI_SINT_CMD_STREAM0_FRAME_DONE: A frame of cmd mode stream0 is sent out.
89 * @DSI_SINT_CMD_STREAM1_FRAME_DONE: A frame of cmd mode stream1 is sent out.
90 * @DSI_SINT_CMD_STREAM2_FRAME_DONE: A frame of cmd mode stream2 is sent out.
91 * @DSI_SINT_VIDEO_MODE_FRAME_DONE: A frame of video mode stream is sent out.
92 * @DSI_SINT_BTA_DONE: A BTA is completed.
93 * @DSI_SINT_CMD_FRAME_DONE: A frame of selected cmd mode stream is
94 * sent out by MDP.
95 * @DSI_SINT_DYN_REFRESH_DONE: The dynamic refresh operation completed.
96 * @DSI_SINT_DESKEW_DONE: The deskew calibration operation done.
97 * @DSI_SINT_DYN_BLANK_DMA_DONE: The dynamic blankin DMA operation has
98 * completed.
Sandeep Panda11b20d82017-06-19 12:57:27 +053099 * @DSI_SINT_ERROR: DSI error has happened.
Clarence Ip80ada7f2017-05-04 09:55:21 -0700100 */
101enum dsi_status_int_index {
102 DSI_SINT_CMD_MODE_DMA_DONE = 0,
103 DSI_SINT_CMD_STREAM0_FRAME_DONE = 1,
104 DSI_SINT_CMD_STREAM1_FRAME_DONE = 2,
105 DSI_SINT_CMD_STREAM2_FRAME_DONE = 3,
106 DSI_SINT_VIDEO_MODE_FRAME_DONE = 4,
107 DSI_SINT_BTA_DONE = 5,
108 DSI_SINT_CMD_FRAME_DONE = 6,
109 DSI_SINT_DYN_REFRESH_DONE = 7,
110 DSI_SINT_DESKEW_DONE = 8,
111 DSI_SINT_DYN_BLANK_DMA_DONE = 9,
Sandeep Panda11b20d82017-06-19 12:57:27 +0530112 DSI_SINT_ERROR = 10,
Clarence Ip80ada7f2017-05-04 09:55:21 -0700113
114 DSI_STATUS_INTERRUPT_COUNT
115};
116
117/**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700118 * enum dsi_status_int_type - status interrupts generated by DSI controller
119 * @DSI_CMD_MODE_DMA_DONE: Command mode DMA packets are sent out.
120 * @DSI_CMD_STREAM0_FRAME_DONE: A frame of command mode stream0 is sent out.
121 * @DSI_CMD_STREAM1_FRAME_DONE: A frame of command mode stream1 is sent out.
122 * @DSI_CMD_STREAM2_FRAME_DONE: A frame of command mode stream2 is sent out.
123 * @DSI_VIDEO_MODE_FRAME_DONE: A frame of video mode stream is sent out.
124 * @DSI_BTA_DONE: A BTA is completed.
125 * @DSI_CMD_FRAME_DONE: A frame of selected command mode stream is
126 * sent out by MDP.
127 * @DSI_DYN_REFRESH_DONE: The dynamic refresh operation has completed.
128 * @DSI_DESKEW_DONE: The deskew calibration operation has completed
129 * @DSI_DYN_BLANK_DMA_DONE: The dynamic blankin DMA operation has
130 * completed.
Sandeep Panda11b20d82017-06-19 12:57:27 +0530131 * @DSI_ERROR: DSI error has happened.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700132 */
133enum dsi_status_int_type {
Clarence Ip80ada7f2017-05-04 09:55:21 -0700134 DSI_CMD_MODE_DMA_DONE = BIT(DSI_SINT_CMD_MODE_DMA_DONE),
135 DSI_CMD_STREAM0_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM0_FRAME_DONE),
136 DSI_CMD_STREAM1_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM1_FRAME_DONE),
137 DSI_CMD_STREAM2_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM2_FRAME_DONE),
138 DSI_VIDEO_MODE_FRAME_DONE = BIT(DSI_SINT_VIDEO_MODE_FRAME_DONE),
139 DSI_BTA_DONE = BIT(DSI_SINT_BTA_DONE),
140 DSI_CMD_FRAME_DONE = BIT(DSI_SINT_CMD_FRAME_DONE),
141 DSI_DYN_REFRESH_DONE = BIT(DSI_SINT_DYN_REFRESH_DONE),
142 DSI_DESKEW_DONE = BIT(DSI_SINT_DESKEW_DONE),
Sandeep Panda11b20d82017-06-19 12:57:27 +0530143 DSI_DYN_BLANK_DMA_DONE = BIT(DSI_SINT_DYN_BLANK_DMA_DONE),
144 DSI_ERROR = BIT(DSI_SINT_ERROR)
Clarence Ip80ada7f2017-05-04 09:55:21 -0700145};
146
147/**
148 * enum dsi_error_int_index - index of error interrupts from DSI controller
149 * @DSI_EINT_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
150 * @DSI_EINT_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
151 * @DSI_EINT_RDBK_CRC_ERR: CRC error in read packet.
152 * @DSI_EINT_RDBK_INCOMPLETE_PKT: Incomplete read packet.
153 * @DSI_EINT_PERIPH_ERROR_PKT: Error packet returned from peripheral,
154 * @DSI_EINT_LP_RX_TIMEOUT: Low power reverse transmission timeout.
155 * @DSI_EINT_HS_TX_TIMEOUT: High speed fwd transmission timeout.
156 * @DSI_EINT_BTA_TIMEOUT: BTA timeout.
157 * @DSI_EINT_PLL_UNLOCK: PLL has unlocked.
158 * @DSI_EINT_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
159 * @DSI_EINT_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
160 * @DSI_EINT_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
161 * @DSI_EINT_PENDING_HS_TX_TIMEOUT: Pending High-speed transfer timeout.
162 * @DSI_EINT_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
163 * @DSI_EINT_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
164 * @DSI_EINT_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
165 * receive one complete line from MDP).
166 * @DSI_EINT_DLN0_HS_FIFO_OVERFLOW: High speed FIFO data lane 0 overflows.
167 * @DSI_EINT_DLN1_HS_FIFO_OVERFLOW: High speed FIFO data lane 1 overflows.
168 * @DSI_EINT_DLN2_HS_FIFO_OVERFLOW: High speed FIFO data lane 2 overflows.
169 * @DSI_EINT_DLN3_HS_FIFO_OVERFLOW: High speed FIFO data lane 3 overflows.
170 * @DSI_EINT_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO data lane 0 underflows.
171 * @DSI_EINT_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO data lane 1 underflows.
172 * @DSI_EINT_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO data lane 2 underflows.
173 * @DSI_EINT_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO data lane 3 undeflows.
174 * @DSI_EINT_DLN0_LP0_CONTENTION: PHY level contention while lane 0 low.
175 * @DSI_EINT_DLN1_LP0_CONTENTION: PHY level contention while lane 1 low.
176 * @DSI_EINT_DLN2_LP0_CONTENTION: PHY level contention while lane 2 low.
177 * @DSI_EINT_DLN3_LP0_CONTENTION: PHY level contention while lane 3 low.
178 * @DSI_EINT_DLN0_LP1_CONTENTION: PHY level contention while lane 0 high.
179 * @DSI_EINT_DLN1_LP1_CONTENTION: PHY level contention while lane 1 high.
180 * @DSI_EINT_DLN2_LP1_CONTENTION: PHY level contention while lane 2 high.
181 * @DSI_EINT_DLN3_LP1_CONTENTION: PHY level contention while lane 3 high.
Sandeep Panda11b20d82017-06-19 12:57:27 +0530182 * @DSI_EINT_PANEL_SPECIFIC_ERR: DSI Protocol violation error.
Clarence Ip80ada7f2017-05-04 09:55:21 -0700183 */
184enum dsi_error_int_index {
185 DSI_EINT_RDBK_SINGLE_ECC_ERR = 0,
186 DSI_EINT_RDBK_MULTI_ECC_ERR = 1,
187 DSI_EINT_RDBK_CRC_ERR = 2,
188 DSI_EINT_RDBK_INCOMPLETE_PKT = 3,
189 DSI_EINT_PERIPH_ERROR_PKT = 4,
190 DSI_EINT_LP_RX_TIMEOUT = 5,
191 DSI_EINT_HS_TX_TIMEOUT = 6,
192 DSI_EINT_BTA_TIMEOUT = 7,
193 DSI_EINT_PLL_UNLOCK = 8,
194 DSI_EINT_DLN0_ESC_ENTRY_ERR = 9,
195 DSI_EINT_DLN0_ESC_SYNC_ERR = 10,
196 DSI_EINT_DLN0_LP_CONTROL_ERR = 11,
197 DSI_EINT_PENDING_HS_TX_TIMEOUT = 12,
198 DSI_EINT_INTERLEAVE_OP_CONTENTION = 13,
199 DSI_EINT_CMD_DMA_FIFO_UNDERFLOW = 14,
200 DSI_EINT_CMD_MDP_FIFO_UNDERFLOW = 15,
201 DSI_EINT_DLN0_HS_FIFO_OVERFLOW = 16,
202 DSI_EINT_DLN1_HS_FIFO_OVERFLOW = 17,
203 DSI_EINT_DLN2_HS_FIFO_OVERFLOW = 18,
204 DSI_EINT_DLN3_HS_FIFO_OVERFLOW = 19,
205 DSI_EINT_DLN0_HS_FIFO_UNDERFLOW = 20,
206 DSI_EINT_DLN1_HS_FIFO_UNDERFLOW = 21,
207 DSI_EINT_DLN2_HS_FIFO_UNDERFLOW = 22,
208 DSI_EINT_DLN3_HS_FIFO_UNDERFLOW = 23,
209 DSI_EINT_DLN0_LP0_CONTENTION = 24,
210 DSI_EINT_DLN1_LP0_CONTENTION = 25,
211 DSI_EINT_DLN2_LP0_CONTENTION = 26,
212 DSI_EINT_DLN3_LP0_CONTENTION = 27,
213 DSI_EINT_DLN0_LP1_CONTENTION = 28,
214 DSI_EINT_DLN1_LP1_CONTENTION = 29,
215 DSI_EINT_DLN2_LP1_CONTENTION = 30,
216 DSI_EINT_DLN3_LP1_CONTENTION = 31,
Sandeep Panda11b20d82017-06-19 12:57:27 +0530217 DSI_EINT_PANEL_SPECIFIC_ERR = 32,
Clarence Ip80ada7f2017-05-04 09:55:21 -0700218
219 DSI_ERROR_INTERRUPT_COUNT
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700220};
221
222/**
223 * enum dsi_error_int_type - error interrupts generated by DSI controller
224 * @DSI_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
225 * @DSI_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
226 * @DSI_RDBK_CRC_ERR: CRC error in read packet.
227 * @DSI_RDBK_INCOMPLETE_PKT: Incomplete read packet.
228 * @DSI_PERIPH_ERROR_PKT: Error packet returned from peripheral,
229 * @DSI_LP_RX_TIMEOUT: Low power reverse transmission timeout.
230 * @DSI_HS_TX_TIMEOUT: High speed forward transmission timeout.
231 * @DSI_BTA_TIMEOUT: BTA timeout.
232 * @DSI_PLL_UNLOCK: PLL has unlocked.
233 * @DSI_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
234 * @DSI_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
235 * @DSI_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
236 * @DSI_PENDING_HS_TX_TIMEOUT: Pending High-speed transfer timeout.
237 * @DSI_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
238 * @DSI_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
239 * @DSI_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
240 * receive one complete line from MDP).
241 * @DSI_DLN0_HS_FIFO_OVERFLOW: High speed FIFO for data lane 0 overflows.
242 * @DSI_DLN1_HS_FIFO_OVERFLOW: High speed FIFO for data lane 1 overflows.
243 * @DSI_DLN2_HS_FIFO_OVERFLOW: High speed FIFO for data lane 2 overflows.
244 * @DSI_DLN3_HS_FIFO_OVERFLOW: High speed FIFO for data lane 3 overflows.
245 * @DSI_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 0 underflows.
246 * @DSI_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 1 underflows.
247 * @DSI_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 2 underflows.
248 * @DSI_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 3 undeflows.
249 * @DSI_DLN0_LP0_CONTENTION: PHY level contention while lane 0 is low.
250 * @DSI_DLN1_LP0_CONTENTION: PHY level contention while lane 1 is low.
251 * @DSI_DLN2_LP0_CONTENTION: PHY level contention while lane 2 is low.
252 * @DSI_DLN3_LP0_CONTENTION: PHY level contention while lane 3 is low.
253 * @DSI_DLN0_LP1_CONTENTION: PHY level contention while lane 0 is high.
254 * @DSI_DLN1_LP1_CONTENTION: PHY level contention while lane 1 is high.
255 * @DSI_DLN2_LP1_CONTENTION: PHY level contention while lane 2 is high.
256 * @DSI_DLN3_LP1_CONTENTION: PHY level contention while lane 3 is high.
Sandeep Panda11b20d82017-06-19 12:57:27 +0530257 * @DSI_PANEL_SPECIFIC_ERR: DSI Protocol violation.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700258 */
259enum dsi_error_int_type {
Clarence Ip80ada7f2017-05-04 09:55:21 -0700260 DSI_RDBK_SINGLE_ECC_ERR = BIT(DSI_EINT_RDBK_SINGLE_ECC_ERR),
261 DSI_RDBK_MULTI_ECC_ERR = BIT(DSI_EINT_RDBK_MULTI_ECC_ERR),
262 DSI_RDBK_CRC_ERR = BIT(DSI_EINT_RDBK_CRC_ERR),
263 DSI_RDBK_INCOMPLETE_PKT = BIT(DSI_EINT_RDBK_INCOMPLETE_PKT),
264 DSI_PERIPH_ERROR_PKT = BIT(DSI_EINT_PERIPH_ERROR_PKT),
265 DSI_LP_RX_TIMEOUT = BIT(DSI_EINT_LP_RX_TIMEOUT),
266 DSI_HS_TX_TIMEOUT = BIT(DSI_EINT_HS_TX_TIMEOUT),
267 DSI_BTA_TIMEOUT = BIT(DSI_EINT_BTA_TIMEOUT),
268 DSI_PLL_UNLOCK = BIT(DSI_EINT_PLL_UNLOCK),
269 DSI_DLN0_ESC_ENTRY_ERR = BIT(DSI_EINT_DLN0_ESC_ENTRY_ERR),
270 DSI_DLN0_ESC_SYNC_ERR = BIT(DSI_EINT_DLN0_ESC_SYNC_ERR),
271 DSI_DLN0_LP_CONTROL_ERR = BIT(DSI_EINT_DLN0_LP_CONTROL_ERR),
272 DSI_PENDING_HS_TX_TIMEOUT = BIT(DSI_EINT_PENDING_HS_TX_TIMEOUT),
273 DSI_INTERLEAVE_OP_CONTENTION = BIT(DSI_EINT_INTERLEAVE_OP_CONTENTION),
274 DSI_CMD_DMA_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_DMA_FIFO_UNDERFLOW),
275 DSI_CMD_MDP_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_MDP_FIFO_UNDERFLOW),
276 DSI_DLN0_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_OVERFLOW),
277 DSI_DLN1_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_OVERFLOW),
278 DSI_DLN2_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_OVERFLOW),
279 DSI_DLN3_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_OVERFLOW),
280 DSI_DLN0_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_UNDERFLOW),
281 DSI_DLN1_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_UNDERFLOW),
282 DSI_DLN2_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_UNDERFLOW),
283 DSI_DLN3_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_UNDERFLOW),
284 DSI_DLN0_LP0_CONTENTION = BIT(DSI_EINT_DLN0_LP0_CONTENTION),
285 DSI_DLN1_LP0_CONTENTION = BIT(DSI_EINT_DLN1_LP0_CONTENTION),
286 DSI_DLN2_LP0_CONTENTION = BIT(DSI_EINT_DLN2_LP0_CONTENTION),
287 DSI_DLN3_LP0_CONTENTION = BIT(DSI_EINT_DLN3_LP0_CONTENTION),
288 DSI_DLN0_LP1_CONTENTION = BIT(DSI_EINT_DLN0_LP1_CONTENTION),
289 DSI_DLN1_LP1_CONTENTION = BIT(DSI_EINT_DLN1_LP1_CONTENTION),
290 DSI_DLN2_LP1_CONTENTION = BIT(DSI_EINT_DLN2_LP1_CONTENTION),
291 DSI_DLN3_LP1_CONTENTION = BIT(DSI_EINT_DLN3_LP1_CONTENTION),
Sandeep Panda11b20d82017-06-19 12:57:27 +0530292 DSI_PANEL_SPECIFIC_ERR = BIT(DSI_EINT_PANEL_SPECIFIC_ERR),
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700293};
294
295/**
296 * struct dsi_ctrl_cmd_dma_info - command buffer information
297 * @offset: IOMMU VA for command buffer address.
298 * @length: Length of the command buffer.
299 * @en_broadcast: Enable broadcast mode if set to true.
300 * @is_master: Is master in broadcast mode.
301 * @use_lpm: Use low power mode for command transmission.
302 */
303struct dsi_ctrl_cmd_dma_info {
304 u32 offset;
305 u32 length;
306 bool en_broadcast;
307 bool is_master;
308 bool use_lpm;
309};
310
311/**
312 * struct dsi_ctrl_cmd_dma_fifo_info - command payload tp be sent using FIFO
313 * @command: VA for command buffer.
314 * @size: Size of the command buffer.
315 * @en_broadcast: Enable broadcast mode if set to true.
316 * @is_master: Is master in broadcast mode.
317 * @use_lpm: Use low power mode for command transmission.
318 */
319struct dsi_ctrl_cmd_dma_fifo_info {
320 u32 *command;
321 u32 size;
322 bool en_broadcast;
323 bool is_master;
324 bool use_lpm;
325};
326
327struct dsi_ctrl_hw;
328
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530329struct ctrl_ulps_config_ops {
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530330 /**
331 * ulps_request() - request ulps entry for specified lanes
332 * @ctrl: Pointer to the controller host hardware.
333 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
334 * to enter ULPS.
335 *
336 * Caller should check if lanes are in ULPS mode by calling
337 * get_lanes_in_ulps() operation.
338 */
339 void (*ulps_request)(struct dsi_ctrl_hw *ctrl, u32 lanes);
340
341 /**
342 * ulps_exit() - exit ULPS on specified lanes
343 * @ctrl: Pointer to the controller host hardware.
344 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
345 * to exit ULPS.
346 *
347 * Caller should check if lanes are in active mode by calling
348 * get_lanes_in_ulps() operation.
349 */
350 void (*ulps_exit)(struct dsi_ctrl_hw *ctrl, u32 lanes);
351
352 /**
353 * get_lanes_in_ulps() - returns the list of lanes in ULPS mode
354 * @ctrl: Pointer to the controller host hardware.
355 *
356 * Returns an ORed list of lanes (enum dsi_data_lanes) that are in ULPS
357 * state. If 0 is returned, all the lanes are active.
358 *
359 * Return: List of lanes in ULPS state.
360 */
361 u32 (*get_lanes_in_ulps)(struct dsi_ctrl_hw *ctrl);
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530362};
363
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700364/**
365 * struct dsi_ctrl_hw_ops - operations supported by dsi host hardware
366 */
367struct dsi_ctrl_hw_ops {
368
369 /**
370 * host_setup() - Setup DSI host configuration
371 * @ctrl: Pointer to controller host hardware.
372 * @config: Configuration for DSI host controller
373 */
374 void (*host_setup)(struct dsi_ctrl_hw *ctrl,
375 struct dsi_host_common_cfg *config);
376
377 /**
378 * video_engine_en() - enable DSI video engine
379 * @ctrl: Pointer to controller host hardware.
380 * @on: Enable/disabel video engine.
381 */
382 void (*video_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
383
384 /**
385 * video_engine_setup() - Setup dsi host controller for video mode
386 * @ctrl: Pointer to controller host hardware.
387 * @common_cfg: Common configuration parameters.
388 * @cfg: Video mode configuration.
389 *
390 * Set up DSI video engine with a specific configuration. Controller and
391 * video engine are not enabled as part of this function.
392 */
393 void (*video_engine_setup)(struct dsi_ctrl_hw *ctrl,
394 struct dsi_host_common_cfg *common_cfg,
395 struct dsi_video_engine_cfg *cfg);
396
397 /**
398 * set_video_timing() - set up the timing for video frame
399 * @ctrl: Pointer to controller host hardware.
400 * @mode: Video mode information.
401 *
402 * Set up the video timing parameters for the DSI video mode operation.
403 */
404 void (*set_video_timing)(struct dsi_ctrl_hw *ctrl,
405 struct dsi_mode_info *mode);
406
407 /**
408 * cmd_engine_setup() - setup dsi host controller for command mode
409 * @ctrl: Pointer to the controller host hardware.
410 * @common_cfg: Common configuration parameters.
411 * @cfg: Command mode configuration.
412 *
413 * Setup DSI CMD engine with a specific configuration. Controller and
414 * command engine are not enabled as part of this function.
415 */
416 void (*cmd_engine_setup)(struct dsi_ctrl_hw *ctrl,
417 struct dsi_host_common_cfg *common_cfg,
418 struct dsi_cmd_engine_cfg *cfg);
419
420 /**
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700421 * setup_cmd_stream() - set up parameters for command pixel streams
Alexander Beykunac182352017-02-27 17:46:51 -0500422 * @ctrl: Pointer to controller host hardware.
423 * @mode: Pointer to mode information.
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700424 * @h_stride: Horizontal stride in bytes.
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700425 * @vc_id: stream_id.
426 *
427 * Setup parameters for command mode pixel stream size.
428 */
429 void (*setup_cmd_stream)(struct dsi_ctrl_hw *ctrl,
Alexander Beykunac182352017-02-27 17:46:51 -0500430 struct dsi_mode_info *mode,
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700431 u32 h_stride,
Lloyd Atkinson16e96de2017-04-19 11:18:14 -0400432 u32 vc_id,
433 struct dsi_rect *roi);
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700434
435 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700436 * ctrl_en() - enable DSI controller engine
437 * @ctrl: Pointer to the controller host hardware.
438 * @on: turn on/off the DSI controller engine.
439 */
440 void (*ctrl_en)(struct dsi_ctrl_hw *ctrl, bool on);
441
442 /**
443 * cmd_engine_en() - enable DSI controller command engine
444 * @ctrl: Pointer to the controller host hardware.
445 * @on: Turn on/off the DSI command engine.
446 */
447 void (*cmd_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
448
449 /**
450 * phy_sw_reset() - perform a soft reset on the PHY.
451 * @ctrl: Pointer to the controller host hardware.
452 */
453 void (*phy_sw_reset)(struct dsi_ctrl_hw *ctrl);
454
455 /**
Dhaval Patelf9f3ffe2017-08-16 16:03:10 -0700456 * debug_bus() - get dsi debug bus status.
457 * @ctrl: Pointer to the controller host hardware.
458 */
459 void (*debug_bus)(struct dsi_ctrl_hw *ctrl);
460
461 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700462 * soft_reset() - perform a soft reset on DSI controller
463 * @ctrl: Pointer to the controller host hardware.
464 *
Lloyd Atkinson8c49c582016-11-18 14:23:54 -0500465 * The video, command and controller engines will be disabled before the
466 * reset is triggered. After, the engines will be re-enabled to the same
467 * state as before the reset.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700468 *
469 * If the reset is done while MDP timing engine is turned on, the video
Lloyd Atkinson8c49c582016-11-18 14:23:54 -0500470 * engine should be re-enabled only during the vertical blanking time.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700471 */
472 void (*soft_reset)(struct dsi_ctrl_hw *ctrl);
473
474 /**
475 * setup_lane_map() - setup mapping between logical and physical lanes
476 * @ctrl: Pointer to the controller host hardware.
477 * @lane_map: Structure defining the mapping between DSI logical
478 * lanes and physical lanes.
479 */
480 void (*setup_lane_map)(struct dsi_ctrl_hw *ctrl,
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530481 struct dsi_lane_map *lane_map);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700482
483 /**
484 * kickoff_command() - transmits commands stored in memory
485 * @ctrl: Pointer to the controller host hardware.
486 * @cmd: Command information.
487 * @flags: Modifiers for command transmission.
488 *
489 * The controller hardware is programmed with address and size of the
490 * command buffer. The transmission is kicked off if
491 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
492 * set, caller should make a separate call to trigger_command_dma() to
493 * transmit the command.
494 */
495 void (*kickoff_command)(struct dsi_ctrl_hw *ctrl,
496 struct dsi_ctrl_cmd_dma_info *cmd,
497 u32 flags);
498
499 /**
500 * kickoff_fifo_command() - transmits a command using FIFO in dsi
501 * hardware.
502 * @ctrl: Pointer to the controller host hardware.
503 * @cmd: Command information.
504 * @flags: Modifiers for command transmission.
505 *
506 * The controller hardware FIFO is programmed with command header and
507 * payload. The transmission is kicked off if
508 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
509 * set, caller should make a separate call to trigger_command_dma() to
510 * transmit the command.
511 */
512 void (*kickoff_fifo_command)(struct dsi_ctrl_hw *ctrl,
513 struct dsi_ctrl_cmd_dma_fifo_info *cmd,
514 u32 flags);
515
516 void (*reset_cmd_fifo)(struct dsi_ctrl_hw *ctrl);
517 /**
518 * trigger_command_dma() - trigger transmission of command buffer.
519 * @ctrl: Pointer to the controller host hardware.
520 *
521 * This trigger can be only used if there was a prior call to
522 * kickoff_command() of kickoff_fifo_command() with
523 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag.
524 */
525 void (*trigger_command_dma)(struct dsi_ctrl_hw *ctrl);
526
527 /**
528 * get_cmd_read_data() - get data read from the peripheral
529 * @ctrl: Pointer to the controller host hardware.
530 * @rd_buf: Buffer where data will be read into.
Sandeep Panda79450002017-05-08 17:14:24 +0530531 * @read_offset: Offset from where to read.
532 * @rx_byte: Number of bytes to be read.
533 * @pkt_size: Size of response expected.
534 * @hw_read_cnt: Actual number of bytes read by HW.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700535 */
536 u32 (*get_cmd_read_data)(struct dsi_ctrl_hw *ctrl,
537 u8 *rd_buf,
Sandeep Panda79450002017-05-08 17:14:24 +0530538 u32 read_offset,
539 u32 rx_byte,
540 u32 pkt_size,
541 u32 *hw_read_cnt);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700542
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530543 /**
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700544 * get_cont_splash_status() - get continuous splash status
545 * @ctrl: Pointer to the controller host hardware.
546 */
547 bool (*get_cont_splash_status)(struct dsi_ctrl_hw *ctrl);
548
549 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530550 * wait_for_lane_idle() - wait for DSI lanes to go to idle state
551 * @ctrl: Pointer to the controller host hardware.
552 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
553 * to be checked to be in idle state.
554 */
555 int (*wait_for_lane_idle)(struct dsi_ctrl_hw *ctrl, u32 lanes);
556
557 struct ctrl_ulps_config_ops ulps_ops;
558
559 /**
560 * clamp_enable() - enable DSI clamps
561 * @ctrl: Pointer to the controller host hardware.
562 * @lanes: ORed list of lanes which need to have clamps released.
563 * @enable_ulps: ulps state.
564 */
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700565
566 /**
567 * clamp_enable() - enable DSI clamps to keep PHY driving a stable link
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530568 * @ctrl: Pointer to the controller host hardware.
569 * @lanes: ORed list of lanes which need to have clamps released.
570 * @enable_ulps: TODO:??
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700571 */
572 void (*clamp_enable)(struct dsi_ctrl_hw *ctrl,
573 u32 lanes,
574 bool enable_ulps);
575
576 /**
577 * clamp_disable() - disable DSI clamps
578 * @ctrl: Pointer to the controller host hardware.
579 * @lanes: ORed list of lanes which need to have clamps released.
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530580 * @disable_ulps: ulps state.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700581 */
582 void (*clamp_disable)(struct dsi_ctrl_hw *ctrl,
583 u32 lanes,
584 bool disable_ulps);
585
586 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530587 * phy_reset_config() - Disable/enable propagation of reset signal
588 * from ahb domain to DSI PHY
589 * @ctrl: Pointer to the controller host hardware.
590 * @enable: True to mask the reset signal, false to unmask
591 */
592 void (*phy_reset_config)(struct dsi_ctrl_hw *ctrl,
593 bool enable);
594
595 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700596 * get_interrupt_status() - returns the interrupt status
597 * @ctrl: Pointer to the controller host hardware.
598 *
599 * Returns the ORed list of interrupts(enum dsi_status_int_type) that
600 * are active. This list does not include any error interrupts. Caller
601 * should call get_error_status for error interrupts.
602 *
603 * Return: List of active interrupts.
604 */
605 u32 (*get_interrupt_status)(struct dsi_ctrl_hw *ctrl);
606
607 /**
608 * clear_interrupt_status() - clears the specified interrupts
609 * @ctrl: Pointer to the controller host hardware.
610 * @ints: List of interrupts to be cleared.
611 */
612 void (*clear_interrupt_status)(struct dsi_ctrl_hw *ctrl, u32 ints);
613
614 /**
615 * enable_status_interrupts() - enable the specified interrupts
616 * @ctrl: Pointer to the controller host hardware.
617 * @ints: List of interrupts to be enabled.
618 *
619 * Enables the specified interrupts. This list will override the
620 * previous interrupts enabled through this function. Caller has to
621 * maintain the state of the interrupts enabled. To disable all
622 * interrupts, set ints to 0.
623 */
624 void (*enable_status_interrupts)(struct dsi_ctrl_hw *ctrl, u32 ints);
625
626 /**
627 * get_error_status() - returns the error status
628 * @ctrl: Pointer to the controller host hardware.
629 *
630 * Returns the ORed list of errors(enum dsi_error_int_type) that are
631 * active. This list does not include any status interrupts. Caller
632 * should call get_interrupt_status for status interrupts.
633 *
634 * Return: List of active error interrupts.
635 */
636 u64 (*get_error_status)(struct dsi_ctrl_hw *ctrl);
637
638 /**
639 * clear_error_status() - clears the specified errors
640 * @ctrl: Pointer to the controller host hardware.
641 * @errors: List of errors to be cleared.
642 */
643 void (*clear_error_status)(struct dsi_ctrl_hw *ctrl, u64 errors);
644
645 /**
646 * enable_error_interrupts() - enable the specified interrupts
647 * @ctrl: Pointer to the controller host hardware.
648 * @errors: List of errors to be enabled.
649 *
650 * Enables the specified interrupts. This list will override the
651 * previous interrupts enabled through this function. Caller has to
652 * maintain the state of the interrupts enabled. To disable all
653 * interrupts, set errors to 0.
654 */
655 void (*enable_error_interrupts)(struct dsi_ctrl_hw *ctrl, u64 errors);
656
657 /**
658 * video_test_pattern_setup() - setup test pattern engine for video mode
659 * @ctrl: Pointer to the controller host hardware.
660 * @type: Type of test pattern.
661 * @init_val: Initial value to use for generating test pattern.
662 */
663 void (*video_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
664 enum dsi_test_pattern type,
665 u32 init_val);
666
667 /**
668 * cmd_test_pattern_setup() - setup test patttern engine for cmd mode
669 * @ctrl: Pointer to the controller host hardware.
670 * @type: Type of test pattern.
671 * @init_val: Initial value to use for generating test pattern.
672 * @stream_id: Stream Id on which packets are generated.
673 */
674 void (*cmd_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
675 enum dsi_test_pattern type,
676 u32 init_val,
677 u32 stream_id);
678
679 /**
680 * test_pattern_enable() - enable test pattern engine
681 * @ctrl: Pointer to the controller host hardware.
682 * @enable: Enable/Disable test pattern engine.
683 */
684 void (*test_pattern_enable)(struct dsi_ctrl_hw *ctrl, bool enable);
685
686 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530687 * clear_phy0_ln_err() - clear DSI PHY lane-0 errors
688 * @ctrl: Pointer to the controller host hardware.
689 */
690 void (*clear_phy0_ln_err)(struct dsi_ctrl_hw *ctrl);
691
692 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700693 * trigger_cmd_test_pattern() - trigger a command mode frame update with
694 * test pattern
695 * @ctrl: Pointer to the controller host hardware.
696 * @stream_id: Stream on which frame update is sent.
697 */
698 void (*trigger_cmd_test_pattern)(struct dsi_ctrl_hw *ctrl,
699 u32 stream_id);
Ajay Singh Parmar48ea4272016-06-27 11:44:34 -0700700
701 ssize_t (*reg_dump_to_buffer)(struct dsi_ctrl_hw *ctrl,
702 char *buf,
703 u32 size);
Rajkumar Subbiah01e6dd642017-07-05 14:47:47 -0400704
705 /**
706 * setup_misr() - Setup frame MISR
707 * @ctrl: Pointer to the controller host hardware.
708 * @panel_mode: CMD or VIDEO mode indicator
709 * @enable: Enable/disable MISR.
710 * @frame_count: Number of frames to accumulate MISR.
711 */
712 void (*setup_misr)(struct dsi_ctrl_hw *ctrl,
713 enum dsi_op_mode panel_mode,
714 bool enable, u32 frame_count);
715
716 /**
717 * collect_misr() - Read frame MISR
718 * @ctrl: Pointer to the controller host hardware.
719 * @panel_mode: CMD or VIDEO mode indicator
720 */
721 u32 (*collect_misr)(struct dsi_ctrl_hw *ctrl,
722 enum dsi_op_mode panel_mode);
723
Raviteja Tamatam68892de2017-06-20 04:47:19 +0530724 /**
725 * set_timing_db() - enable/disable Timing DB register
726 * @ctrl: Pointer to controller host hardware.
727 * @enable: Enable/Disable flag.
728 *
729 * Enable or Disabe the Timing DB register.
730 */
731 void (*set_timing_db)(struct dsi_ctrl_hw *ctrl,
732 bool enable);
Sandeep Panda79450002017-05-08 17:14:24 +0530733 /**
734 * clear_rdbk_register() - Clear and reset read back register
735 * @ctrl: Pointer to the controller host hardware.
736 */
737 void (*clear_rdbk_register)(struct dsi_ctrl_hw *ctrl);
Sandeep Pandaa2a3c8c2017-07-09 02:10:44 +0530738
739 /** schedule_dma_cmd() - Schdeule DMA command transfer on a
740 * particular blanking line.
741 * @ctrl: Pointer to the controller host hardware.
742 * @line_no: Blanking line number on whihch DMA command
743 * needs to be sent.
744 */
745 void (*schedule_dma_cmd)(struct dsi_ctrl_hw *ctrl, int line_no);
Sandeep Panda11b20d82017-06-19 12:57:27 +0530746
747 /**
748 * ctrl_reset() - Reset DSI lanes to recover from DSI errors
749 * @ctrl: Pointer to the controller host hardware.
750 * @mask: Indicates the error type.
751 */
752 int (*ctrl_reset)(struct dsi_ctrl_hw *ctrl, int mask);
753
754 /**
755 * mask_error_int() - Mask/Unmask particular DSI error interrupts
756 * @ctrl: Pointer to the controller host hardware.
757 * @idx: Indicates the errors to be masked.
758 * @en: Bool for mask or unmask of the error
759 */
760 void (*mask_error_intr)(struct dsi_ctrl_hw *ctrl, u32 idx, bool en);
761
762 /**
763 * error_intr_ctrl() - Mask/Unmask master DSI error interrupt
764 * @ctrl: Pointer to the controller host hardware.
765 * @en: Bool for mask or unmask of DSI error
766 */
767 void (*error_intr_ctrl)(struct dsi_ctrl_hw *ctrl, bool en);
768
769 /**
770 * get_error_mask() - get DSI error interrupt mask status
771 * @ctrl: Pointer to the controller host hardware.
772 */
773 u32 (*get_error_mask)(struct dsi_ctrl_hw *ctrl);
774
775 /**
776 * get_hw_version() - get DSI controller hw version
777 * @ctrl: Pointer to the controller host hardware.
778 */
779 u32 (*get_hw_version)(struct dsi_ctrl_hw *ctrl);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700780};
781
782/*
783 * struct dsi_ctrl_hw - DSI controller hardware object specific to an instance
Shashank Babu Chinta Venkataafef8202017-04-21 13:49:56 -0700784 * @base: VA for the DSI controller base address.
785 * @length: Length of the DSI controller register map.
786 * @mmss_misc_base: Base address of mmss_misc register map.
787 * @mmss_misc_length: Length of mmss_misc register map.
788 * @disp_cc_base: Base address of disp_cc register map.
789 * @disp_cc_length: Length of disp_cc register map.
790 * @index: Instance ID of the controller.
791 * @feature_map: Features supported by the DSI controller.
792 * @ops: Function pointers to the operations supported by the
793 * controller.
794 * @supported_interrupts: Number of supported interrupts.
795 * @supported_errors: Number of supported errors.
Dhaval Patelabfaa082017-07-28 12:41:10 -0700796 * @phy_isolation_enabled: A boolean property allows to isolate the phy from
797 * dsi controller and run only dsi controller.
Sravanthi Kollukudurud8809322017-10-26 15:24:13 +0530798 * @null_insertion_enabled: A boolean property to allow dsi controller to
799 * insert null packet.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700800 */
801struct dsi_ctrl_hw {
802 void __iomem *base;
803 u32 length;
804 void __iomem *mmss_misc_base;
805 u32 mmss_misc_length;
Shashank Babu Chinta Venkataafef8202017-04-21 13:49:56 -0700806 void __iomem *disp_cc_base;
807 u32 disp_cc_length;
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700808 u32 index;
809
810 /* features */
811 DECLARE_BITMAP(feature_map, DSI_CTRL_MAX_FEATURES);
812 struct dsi_ctrl_hw_ops ops;
813
814 /* capabilities */
815 u32 supported_interrupts;
816 u64 supported_errors;
Dhaval Patelabfaa082017-07-28 12:41:10 -0700817
818 bool phy_isolation_enabled;
Sravanthi Kollukudurud8809322017-10-26 15:24:13 +0530819 bool null_insertion_enabled;
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700820};
821
822#endif /* _DSI_CTRL_HW_H_ */