blob: c34fe443ba9d07c987784f0b028a4480dca75280 [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.
99 */
100enum dsi_status_int_index {
101 DSI_SINT_CMD_MODE_DMA_DONE = 0,
102 DSI_SINT_CMD_STREAM0_FRAME_DONE = 1,
103 DSI_SINT_CMD_STREAM1_FRAME_DONE = 2,
104 DSI_SINT_CMD_STREAM2_FRAME_DONE = 3,
105 DSI_SINT_VIDEO_MODE_FRAME_DONE = 4,
106 DSI_SINT_BTA_DONE = 5,
107 DSI_SINT_CMD_FRAME_DONE = 6,
108 DSI_SINT_DYN_REFRESH_DONE = 7,
109 DSI_SINT_DESKEW_DONE = 8,
110 DSI_SINT_DYN_BLANK_DMA_DONE = 9,
111
112 DSI_STATUS_INTERRUPT_COUNT
113};
114
115/**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700116 * enum dsi_status_int_type - status interrupts generated by DSI controller
117 * @DSI_CMD_MODE_DMA_DONE: Command mode DMA packets are sent out.
118 * @DSI_CMD_STREAM0_FRAME_DONE: A frame of command mode stream0 is sent out.
119 * @DSI_CMD_STREAM1_FRAME_DONE: A frame of command mode stream1 is sent out.
120 * @DSI_CMD_STREAM2_FRAME_DONE: A frame of command mode stream2 is sent out.
121 * @DSI_VIDEO_MODE_FRAME_DONE: A frame of video mode stream is sent out.
122 * @DSI_BTA_DONE: A BTA is completed.
123 * @DSI_CMD_FRAME_DONE: A frame of selected command mode stream is
124 * sent out by MDP.
125 * @DSI_DYN_REFRESH_DONE: The dynamic refresh operation has completed.
126 * @DSI_DESKEW_DONE: The deskew calibration operation has completed
127 * @DSI_DYN_BLANK_DMA_DONE: The dynamic blankin DMA operation has
128 * completed.
129 */
130enum dsi_status_int_type {
Clarence Ip80ada7f2017-05-04 09:55:21 -0700131 DSI_CMD_MODE_DMA_DONE = BIT(DSI_SINT_CMD_MODE_DMA_DONE),
132 DSI_CMD_STREAM0_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM0_FRAME_DONE),
133 DSI_CMD_STREAM1_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM1_FRAME_DONE),
134 DSI_CMD_STREAM2_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM2_FRAME_DONE),
135 DSI_VIDEO_MODE_FRAME_DONE = BIT(DSI_SINT_VIDEO_MODE_FRAME_DONE),
136 DSI_BTA_DONE = BIT(DSI_SINT_BTA_DONE),
137 DSI_CMD_FRAME_DONE = BIT(DSI_SINT_CMD_FRAME_DONE),
138 DSI_DYN_REFRESH_DONE = BIT(DSI_SINT_DYN_REFRESH_DONE),
139 DSI_DESKEW_DONE = BIT(DSI_SINT_DESKEW_DONE),
140 DSI_DYN_BLANK_DMA_DONE = BIT(DSI_SINT_DYN_BLANK_DMA_DONE)
141};
142
143/**
144 * enum dsi_error_int_index - index of error interrupts from DSI controller
145 * @DSI_EINT_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
146 * @DSI_EINT_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
147 * @DSI_EINT_RDBK_CRC_ERR: CRC error in read packet.
148 * @DSI_EINT_RDBK_INCOMPLETE_PKT: Incomplete read packet.
149 * @DSI_EINT_PERIPH_ERROR_PKT: Error packet returned from peripheral,
150 * @DSI_EINT_LP_RX_TIMEOUT: Low power reverse transmission timeout.
151 * @DSI_EINT_HS_TX_TIMEOUT: High speed fwd transmission timeout.
152 * @DSI_EINT_BTA_TIMEOUT: BTA timeout.
153 * @DSI_EINT_PLL_UNLOCK: PLL has unlocked.
154 * @DSI_EINT_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
155 * @DSI_EINT_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
156 * @DSI_EINT_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
157 * @DSI_EINT_PENDING_HS_TX_TIMEOUT: Pending High-speed transfer timeout.
158 * @DSI_EINT_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
159 * @DSI_EINT_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
160 * @DSI_EINT_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
161 * receive one complete line from MDP).
162 * @DSI_EINT_DLN0_HS_FIFO_OVERFLOW: High speed FIFO data lane 0 overflows.
163 * @DSI_EINT_DLN1_HS_FIFO_OVERFLOW: High speed FIFO data lane 1 overflows.
164 * @DSI_EINT_DLN2_HS_FIFO_OVERFLOW: High speed FIFO data lane 2 overflows.
165 * @DSI_EINT_DLN3_HS_FIFO_OVERFLOW: High speed FIFO data lane 3 overflows.
166 * @DSI_EINT_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO data lane 0 underflows.
167 * @DSI_EINT_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO data lane 1 underflows.
168 * @DSI_EINT_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO data lane 2 underflows.
169 * @DSI_EINT_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO data lane 3 undeflows.
170 * @DSI_EINT_DLN0_LP0_CONTENTION: PHY level contention while lane 0 low.
171 * @DSI_EINT_DLN1_LP0_CONTENTION: PHY level contention while lane 1 low.
172 * @DSI_EINT_DLN2_LP0_CONTENTION: PHY level contention while lane 2 low.
173 * @DSI_EINT_DLN3_LP0_CONTENTION: PHY level contention while lane 3 low.
174 * @DSI_EINT_DLN0_LP1_CONTENTION: PHY level contention while lane 0 high.
175 * @DSI_EINT_DLN1_LP1_CONTENTION: PHY level contention while lane 1 high.
176 * @DSI_EINT_DLN2_LP1_CONTENTION: PHY level contention while lane 2 high.
177 * @DSI_EINT_DLN3_LP1_CONTENTION: PHY level contention while lane 3 high.
178 */
179enum dsi_error_int_index {
180 DSI_EINT_RDBK_SINGLE_ECC_ERR = 0,
181 DSI_EINT_RDBK_MULTI_ECC_ERR = 1,
182 DSI_EINT_RDBK_CRC_ERR = 2,
183 DSI_EINT_RDBK_INCOMPLETE_PKT = 3,
184 DSI_EINT_PERIPH_ERROR_PKT = 4,
185 DSI_EINT_LP_RX_TIMEOUT = 5,
186 DSI_EINT_HS_TX_TIMEOUT = 6,
187 DSI_EINT_BTA_TIMEOUT = 7,
188 DSI_EINT_PLL_UNLOCK = 8,
189 DSI_EINT_DLN0_ESC_ENTRY_ERR = 9,
190 DSI_EINT_DLN0_ESC_SYNC_ERR = 10,
191 DSI_EINT_DLN0_LP_CONTROL_ERR = 11,
192 DSI_EINT_PENDING_HS_TX_TIMEOUT = 12,
193 DSI_EINT_INTERLEAVE_OP_CONTENTION = 13,
194 DSI_EINT_CMD_DMA_FIFO_UNDERFLOW = 14,
195 DSI_EINT_CMD_MDP_FIFO_UNDERFLOW = 15,
196 DSI_EINT_DLN0_HS_FIFO_OVERFLOW = 16,
197 DSI_EINT_DLN1_HS_FIFO_OVERFLOW = 17,
198 DSI_EINT_DLN2_HS_FIFO_OVERFLOW = 18,
199 DSI_EINT_DLN3_HS_FIFO_OVERFLOW = 19,
200 DSI_EINT_DLN0_HS_FIFO_UNDERFLOW = 20,
201 DSI_EINT_DLN1_HS_FIFO_UNDERFLOW = 21,
202 DSI_EINT_DLN2_HS_FIFO_UNDERFLOW = 22,
203 DSI_EINT_DLN3_HS_FIFO_UNDERFLOW = 23,
204 DSI_EINT_DLN0_LP0_CONTENTION = 24,
205 DSI_EINT_DLN1_LP0_CONTENTION = 25,
206 DSI_EINT_DLN2_LP0_CONTENTION = 26,
207 DSI_EINT_DLN3_LP0_CONTENTION = 27,
208 DSI_EINT_DLN0_LP1_CONTENTION = 28,
209 DSI_EINT_DLN1_LP1_CONTENTION = 29,
210 DSI_EINT_DLN2_LP1_CONTENTION = 30,
211 DSI_EINT_DLN3_LP1_CONTENTION = 31,
212
213 DSI_ERROR_INTERRUPT_COUNT
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700214};
215
216/**
217 * enum dsi_error_int_type - error interrupts generated by DSI controller
218 * @DSI_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
219 * @DSI_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
220 * @DSI_RDBK_CRC_ERR: CRC error in read packet.
221 * @DSI_RDBK_INCOMPLETE_PKT: Incomplete read packet.
222 * @DSI_PERIPH_ERROR_PKT: Error packet returned from peripheral,
223 * @DSI_LP_RX_TIMEOUT: Low power reverse transmission timeout.
224 * @DSI_HS_TX_TIMEOUT: High speed forward transmission timeout.
225 * @DSI_BTA_TIMEOUT: BTA timeout.
226 * @DSI_PLL_UNLOCK: PLL has unlocked.
227 * @DSI_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
228 * @DSI_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
229 * @DSI_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
230 * @DSI_PENDING_HS_TX_TIMEOUT: Pending High-speed transfer timeout.
231 * @DSI_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
232 * @DSI_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
233 * @DSI_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
234 * receive one complete line from MDP).
235 * @DSI_DLN0_HS_FIFO_OVERFLOW: High speed FIFO for data lane 0 overflows.
236 * @DSI_DLN1_HS_FIFO_OVERFLOW: High speed FIFO for data lane 1 overflows.
237 * @DSI_DLN2_HS_FIFO_OVERFLOW: High speed FIFO for data lane 2 overflows.
238 * @DSI_DLN3_HS_FIFO_OVERFLOW: High speed FIFO for data lane 3 overflows.
239 * @DSI_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 0 underflows.
240 * @DSI_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 1 underflows.
241 * @DSI_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 2 underflows.
242 * @DSI_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 3 undeflows.
243 * @DSI_DLN0_LP0_CONTENTION: PHY level contention while lane 0 is low.
244 * @DSI_DLN1_LP0_CONTENTION: PHY level contention while lane 1 is low.
245 * @DSI_DLN2_LP0_CONTENTION: PHY level contention while lane 2 is low.
246 * @DSI_DLN3_LP0_CONTENTION: PHY level contention while lane 3 is low.
247 * @DSI_DLN0_LP1_CONTENTION: PHY level contention while lane 0 is high.
248 * @DSI_DLN1_LP1_CONTENTION: PHY level contention while lane 1 is high.
249 * @DSI_DLN2_LP1_CONTENTION: PHY level contention while lane 2 is high.
250 * @DSI_DLN3_LP1_CONTENTION: PHY level contention while lane 3 is high.
251 */
252enum dsi_error_int_type {
Clarence Ip80ada7f2017-05-04 09:55:21 -0700253 DSI_RDBK_SINGLE_ECC_ERR = BIT(DSI_EINT_RDBK_SINGLE_ECC_ERR),
254 DSI_RDBK_MULTI_ECC_ERR = BIT(DSI_EINT_RDBK_MULTI_ECC_ERR),
255 DSI_RDBK_CRC_ERR = BIT(DSI_EINT_RDBK_CRC_ERR),
256 DSI_RDBK_INCOMPLETE_PKT = BIT(DSI_EINT_RDBK_INCOMPLETE_PKT),
257 DSI_PERIPH_ERROR_PKT = BIT(DSI_EINT_PERIPH_ERROR_PKT),
258 DSI_LP_RX_TIMEOUT = BIT(DSI_EINT_LP_RX_TIMEOUT),
259 DSI_HS_TX_TIMEOUT = BIT(DSI_EINT_HS_TX_TIMEOUT),
260 DSI_BTA_TIMEOUT = BIT(DSI_EINT_BTA_TIMEOUT),
261 DSI_PLL_UNLOCK = BIT(DSI_EINT_PLL_UNLOCK),
262 DSI_DLN0_ESC_ENTRY_ERR = BIT(DSI_EINT_DLN0_ESC_ENTRY_ERR),
263 DSI_DLN0_ESC_SYNC_ERR = BIT(DSI_EINT_DLN0_ESC_SYNC_ERR),
264 DSI_DLN0_LP_CONTROL_ERR = BIT(DSI_EINT_DLN0_LP_CONTROL_ERR),
265 DSI_PENDING_HS_TX_TIMEOUT = BIT(DSI_EINT_PENDING_HS_TX_TIMEOUT),
266 DSI_INTERLEAVE_OP_CONTENTION = BIT(DSI_EINT_INTERLEAVE_OP_CONTENTION),
267 DSI_CMD_DMA_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_DMA_FIFO_UNDERFLOW),
268 DSI_CMD_MDP_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_MDP_FIFO_UNDERFLOW),
269 DSI_DLN0_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_OVERFLOW),
270 DSI_DLN1_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_OVERFLOW),
271 DSI_DLN2_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_OVERFLOW),
272 DSI_DLN3_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_OVERFLOW),
273 DSI_DLN0_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_UNDERFLOW),
274 DSI_DLN1_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_UNDERFLOW),
275 DSI_DLN2_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_UNDERFLOW),
276 DSI_DLN3_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_UNDERFLOW),
277 DSI_DLN0_LP0_CONTENTION = BIT(DSI_EINT_DLN0_LP0_CONTENTION),
278 DSI_DLN1_LP0_CONTENTION = BIT(DSI_EINT_DLN1_LP0_CONTENTION),
279 DSI_DLN2_LP0_CONTENTION = BIT(DSI_EINT_DLN2_LP0_CONTENTION),
280 DSI_DLN3_LP0_CONTENTION = BIT(DSI_EINT_DLN3_LP0_CONTENTION),
281 DSI_DLN0_LP1_CONTENTION = BIT(DSI_EINT_DLN0_LP1_CONTENTION),
282 DSI_DLN1_LP1_CONTENTION = BIT(DSI_EINT_DLN1_LP1_CONTENTION),
283 DSI_DLN2_LP1_CONTENTION = BIT(DSI_EINT_DLN2_LP1_CONTENTION),
284 DSI_DLN3_LP1_CONTENTION = BIT(DSI_EINT_DLN3_LP1_CONTENTION),
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700285};
286
287/**
288 * struct dsi_ctrl_cmd_dma_info - command buffer information
289 * @offset: IOMMU VA for command buffer address.
290 * @length: Length of the command buffer.
291 * @en_broadcast: Enable broadcast mode if set to true.
292 * @is_master: Is master in broadcast mode.
293 * @use_lpm: Use low power mode for command transmission.
294 */
295struct dsi_ctrl_cmd_dma_info {
296 u32 offset;
297 u32 length;
298 bool en_broadcast;
299 bool is_master;
300 bool use_lpm;
301};
302
303/**
304 * struct dsi_ctrl_cmd_dma_fifo_info - command payload tp be sent using FIFO
305 * @command: VA for command buffer.
306 * @size: Size of the command buffer.
307 * @en_broadcast: Enable broadcast mode if set to true.
308 * @is_master: Is master in broadcast mode.
309 * @use_lpm: Use low power mode for command transmission.
310 */
311struct dsi_ctrl_cmd_dma_fifo_info {
312 u32 *command;
313 u32 size;
314 bool en_broadcast;
315 bool is_master;
316 bool use_lpm;
317};
318
319struct dsi_ctrl_hw;
320
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530321struct ctrl_ulps_config_ops {
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530322 /**
323 * ulps_request() - request ulps entry for specified lanes
324 * @ctrl: Pointer to the controller host hardware.
325 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
326 * to enter ULPS.
327 *
328 * Caller should check if lanes are in ULPS mode by calling
329 * get_lanes_in_ulps() operation.
330 */
331 void (*ulps_request)(struct dsi_ctrl_hw *ctrl, u32 lanes);
332
333 /**
334 * ulps_exit() - exit ULPS on specified lanes
335 * @ctrl: Pointer to the controller host hardware.
336 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
337 * to exit ULPS.
338 *
339 * Caller should check if lanes are in active mode by calling
340 * get_lanes_in_ulps() operation.
341 */
342 void (*ulps_exit)(struct dsi_ctrl_hw *ctrl, u32 lanes);
343
344 /**
345 * get_lanes_in_ulps() - returns the list of lanes in ULPS mode
346 * @ctrl: Pointer to the controller host hardware.
347 *
348 * Returns an ORed list of lanes (enum dsi_data_lanes) that are in ULPS
349 * state. If 0 is returned, all the lanes are active.
350 *
351 * Return: List of lanes in ULPS state.
352 */
353 u32 (*get_lanes_in_ulps)(struct dsi_ctrl_hw *ctrl);
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530354};
355
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700356/**
357 * struct dsi_ctrl_hw_ops - operations supported by dsi host hardware
358 */
359struct dsi_ctrl_hw_ops {
360
361 /**
362 * host_setup() - Setup DSI host configuration
363 * @ctrl: Pointer to controller host hardware.
364 * @config: Configuration for DSI host controller
365 */
366 void (*host_setup)(struct dsi_ctrl_hw *ctrl,
367 struct dsi_host_common_cfg *config);
368
369 /**
370 * video_engine_en() - enable DSI video engine
371 * @ctrl: Pointer to controller host hardware.
372 * @on: Enable/disabel video engine.
373 */
374 void (*video_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
375
376 /**
377 * video_engine_setup() - Setup dsi host controller for video mode
378 * @ctrl: Pointer to controller host hardware.
379 * @common_cfg: Common configuration parameters.
380 * @cfg: Video mode configuration.
381 *
382 * Set up DSI video engine with a specific configuration. Controller and
383 * video engine are not enabled as part of this function.
384 */
385 void (*video_engine_setup)(struct dsi_ctrl_hw *ctrl,
386 struct dsi_host_common_cfg *common_cfg,
387 struct dsi_video_engine_cfg *cfg);
388
389 /**
390 * set_video_timing() - set up the timing for video frame
391 * @ctrl: Pointer to controller host hardware.
392 * @mode: Video mode information.
393 *
394 * Set up the video timing parameters for the DSI video mode operation.
395 */
396 void (*set_video_timing)(struct dsi_ctrl_hw *ctrl,
397 struct dsi_mode_info *mode);
398
399 /**
400 * cmd_engine_setup() - setup dsi host controller for command mode
401 * @ctrl: Pointer to the controller host hardware.
402 * @common_cfg: Common configuration parameters.
403 * @cfg: Command mode configuration.
404 *
405 * Setup DSI CMD engine with a specific configuration. Controller and
406 * command engine are not enabled as part of this function.
407 */
408 void (*cmd_engine_setup)(struct dsi_ctrl_hw *ctrl,
409 struct dsi_host_common_cfg *common_cfg,
410 struct dsi_cmd_engine_cfg *cfg);
411
412 /**
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700413 * setup_cmd_stream() - set up parameters for command pixel streams
Alexander Beykunac182352017-02-27 17:46:51 -0500414 * @ctrl: Pointer to controller host hardware.
415 * @mode: Pointer to mode information.
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700416 * @h_stride: Horizontal stride in bytes.
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700417 * @vc_id: stream_id.
418 *
419 * Setup parameters for command mode pixel stream size.
420 */
421 void (*setup_cmd_stream)(struct dsi_ctrl_hw *ctrl,
Alexander Beykunac182352017-02-27 17:46:51 -0500422 struct dsi_mode_info *mode,
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700423 u32 h_stride,
Lloyd Atkinson16e96de2017-04-19 11:18:14 -0400424 u32 vc_id,
425 struct dsi_rect *roi);
Ajay Singh Parmaraa9152d2016-05-16 18:02:07 -0700426
427 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700428 * ctrl_en() - enable DSI controller engine
429 * @ctrl: Pointer to the controller host hardware.
430 * @on: turn on/off the DSI controller engine.
431 */
432 void (*ctrl_en)(struct dsi_ctrl_hw *ctrl, bool on);
433
434 /**
435 * cmd_engine_en() - enable DSI controller command engine
436 * @ctrl: Pointer to the controller host hardware.
437 * @on: Turn on/off the DSI command engine.
438 */
439 void (*cmd_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
440
441 /**
442 * phy_sw_reset() - perform a soft reset on the PHY.
443 * @ctrl: Pointer to the controller host hardware.
444 */
445 void (*phy_sw_reset)(struct dsi_ctrl_hw *ctrl);
446
447 /**
Dhaval Patelf9f3ffe2017-08-16 16:03:10 -0700448 * debug_bus() - get dsi debug bus status.
449 * @ctrl: Pointer to the controller host hardware.
450 */
451 void (*debug_bus)(struct dsi_ctrl_hw *ctrl);
452
453 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700454 * soft_reset() - perform a soft reset on DSI controller
455 * @ctrl: Pointer to the controller host hardware.
456 *
Lloyd Atkinson8c49c582016-11-18 14:23:54 -0500457 * The video, command and controller engines will be disabled before the
458 * reset is triggered. After, the engines will be re-enabled to the same
459 * state as before the reset.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700460 *
461 * If the reset is done while MDP timing engine is turned on, the video
Lloyd Atkinson8c49c582016-11-18 14:23:54 -0500462 * engine should be re-enabled only during the vertical blanking time.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700463 */
464 void (*soft_reset)(struct dsi_ctrl_hw *ctrl);
465
466 /**
467 * setup_lane_map() - setup mapping between logical and physical lanes
468 * @ctrl: Pointer to the controller host hardware.
469 * @lane_map: Structure defining the mapping between DSI logical
470 * lanes and physical lanes.
471 */
472 void (*setup_lane_map)(struct dsi_ctrl_hw *ctrl,
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530473 struct dsi_lane_map *lane_map);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700474
475 /**
476 * kickoff_command() - transmits commands stored in memory
477 * @ctrl: Pointer to the controller host hardware.
478 * @cmd: Command information.
479 * @flags: Modifiers for command transmission.
480 *
481 * The controller hardware is programmed with address and size of the
482 * command buffer. The transmission is kicked off if
483 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
484 * set, caller should make a separate call to trigger_command_dma() to
485 * transmit the command.
486 */
487 void (*kickoff_command)(struct dsi_ctrl_hw *ctrl,
488 struct dsi_ctrl_cmd_dma_info *cmd,
489 u32 flags);
490
491 /**
492 * kickoff_fifo_command() - transmits a command using FIFO in dsi
493 * hardware.
494 * @ctrl: Pointer to the controller host hardware.
495 * @cmd: Command information.
496 * @flags: Modifiers for command transmission.
497 *
498 * The controller hardware FIFO is programmed with command header and
499 * payload. The transmission is kicked off if
500 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
501 * set, caller should make a separate call to trigger_command_dma() to
502 * transmit the command.
503 */
504 void (*kickoff_fifo_command)(struct dsi_ctrl_hw *ctrl,
505 struct dsi_ctrl_cmd_dma_fifo_info *cmd,
506 u32 flags);
507
508 void (*reset_cmd_fifo)(struct dsi_ctrl_hw *ctrl);
509 /**
510 * trigger_command_dma() - trigger transmission of command buffer.
511 * @ctrl: Pointer to the controller host hardware.
512 *
513 * This trigger can be only used if there was a prior call to
514 * kickoff_command() of kickoff_fifo_command() with
515 * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag.
516 */
517 void (*trigger_command_dma)(struct dsi_ctrl_hw *ctrl);
518
519 /**
520 * get_cmd_read_data() - get data read from the peripheral
521 * @ctrl: Pointer to the controller host hardware.
522 * @rd_buf: Buffer where data will be read into.
Sandeep Panda79450002017-05-08 17:14:24 +0530523 * @read_offset: Offset from where to read.
524 * @rx_byte: Number of bytes to be read.
525 * @pkt_size: Size of response expected.
526 * @hw_read_cnt: Actual number of bytes read by HW.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700527 */
528 u32 (*get_cmd_read_data)(struct dsi_ctrl_hw *ctrl,
529 u8 *rd_buf,
Sandeep Panda79450002017-05-08 17:14:24 +0530530 u32 read_offset,
531 u32 rx_byte,
532 u32 pkt_size,
533 u32 *hw_read_cnt);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700534
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530535 /**
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700536 * get_cont_splash_status() - get continuous splash status
537 * @ctrl: Pointer to the controller host hardware.
538 */
539 bool (*get_cont_splash_status)(struct dsi_ctrl_hw *ctrl);
540
541 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530542 * wait_for_lane_idle() - wait for DSI lanes to go to idle state
543 * @ctrl: Pointer to the controller host hardware.
544 * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
545 * to be checked to be in idle state.
546 */
547 int (*wait_for_lane_idle)(struct dsi_ctrl_hw *ctrl, u32 lanes);
548
549 struct ctrl_ulps_config_ops ulps_ops;
550
551 /**
552 * clamp_enable() - enable DSI clamps
553 * @ctrl: Pointer to the controller host hardware.
554 * @lanes: ORed list of lanes which need to have clamps released.
555 * @enable_ulps: ulps state.
556 */
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700557
558 /**
559 * clamp_enable() - enable DSI clamps to keep PHY driving a stable link
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530560 * @ctrl: Pointer to the controller host hardware.
561 * @lanes: ORed list of lanes which need to have clamps released.
562 * @enable_ulps: TODO:??
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700563 */
564 void (*clamp_enable)(struct dsi_ctrl_hw *ctrl,
565 u32 lanes,
566 bool enable_ulps);
567
568 /**
569 * clamp_disable() - disable DSI clamps
570 * @ctrl: Pointer to the controller host hardware.
571 * @lanes: ORed list of lanes which need to have clamps released.
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530572 * @disable_ulps: ulps state.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700573 */
574 void (*clamp_disable)(struct dsi_ctrl_hw *ctrl,
575 u32 lanes,
576 bool disable_ulps);
577
578 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530579 * phy_reset_config() - Disable/enable propagation of reset signal
580 * from ahb domain to DSI PHY
581 * @ctrl: Pointer to the controller host hardware.
582 * @enable: True to mask the reset signal, false to unmask
583 */
584 void (*phy_reset_config)(struct dsi_ctrl_hw *ctrl,
585 bool enable);
586
587 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700588 * get_interrupt_status() - returns the interrupt status
589 * @ctrl: Pointer to the controller host hardware.
590 *
591 * Returns the ORed list of interrupts(enum dsi_status_int_type) that
592 * are active. This list does not include any error interrupts. Caller
593 * should call get_error_status for error interrupts.
594 *
595 * Return: List of active interrupts.
596 */
597 u32 (*get_interrupt_status)(struct dsi_ctrl_hw *ctrl);
598
599 /**
600 * clear_interrupt_status() - clears the specified interrupts
601 * @ctrl: Pointer to the controller host hardware.
602 * @ints: List of interrupts to be cleared.
603 */
604 void (*clear_interrupt_status)(struct dsi_ctrl_hw *ctrl, u32 ints);
605
606 /**
607 * enable_status_interrupts() - enable the specified interrupts
608 * @ctrl: Pointer to the controller host hardware.
609 * @ints: List of interrupts to be enabled.
610 *
611 * Enables the specified interrupts. This list will override the
612 * previous interrupts enabled through this function. Caller has to
613 * maintain the state of the interrupts enabled. To disable all
614 * interrupts, set ints to 0.
615 */
616 void (*enable_status_interrupts)(struct dsi_ctrl_hw *ctrl, u32 ints);
617
618 /**
619 * get_error_status() - returns the error status
620 * @ctrl: Pointer to the controller host hardware.
621 *
622 * Returns the ORed list of errors(enum dsi_error_int_type) that are
623 * active. This list does not include any status interrupts. Caller
624 * should call get_interrupt_status for status interrupts.
625 *
626 * Return: List of active error interrupts.
627 */
628 u64 (*get_error_status)(struct dsi_ctrl_hw *ctrl);
629
630 /**
631 * clear_error_status() - clears the specified errors
632 * @ctrl: Pointer to the controller host hardware.
633 * @errors: List of errors to be cleared.
634 */
635 void (*clear_error_status)(struct dsi_ctrl_hw *ctrl, u64 errors);
636
637 /**
638 * enable_error_interrupts() - enable the specified interrupts
639 * @ctrl: Pointer to the controller host hardware.
640 * @errors: List of errors to be enabled.
641 *
642 * Enables the specified interrupts. This list will override the
643 * previous interrupts enabled through this function. Caller has to
644 * maintain the state of the interrupts enabled. To disable all
645 * interrupts, set errors to 0.
646 */
647 void (*enable_error_interrupts)(struct dsi_ctrl_hw *ctrl, u64 errors);
648
649 /**
650 * video_test_pattern_setup() - setup test pattern engine for video mode
651 * @ctrl: Pointer to the controller host hardware.
652 * @type: Type of test pattern.
653 * @init_val: Initial value to use for generating test pattern.
654 */
655 void (*video_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
656 enum dsi_test_pattern type,
657 u32 init_val);
658
659 /**
660 * cmd_test_pattern_setup() - setup test patttern engine for cmd mode
661 * @ctrl: Pointer to the controller host hardware.
662 * @type: Type of test pattern.
663 * @init_val: Initial value to use for generating test pattern.
664 * @stream_id: Stream Id on which packets are generated.
665 */
666 void (*cmd_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
667 enum dsi_test_pattern type,
668 u32 init_val,
669 u32 stream_id);
670
671 /**
672 * test_pattern_enable() - enable test pattern engine
673 * @ctrl: Pointer to the controller host hardware.
674 * @enable: Enable/Disable test pattern engine.
675 */
676 void (*test_pattern_enable)(struct dsi_ctrl_hw *ctrl, bool enable);
677
678 /**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530679 * clear_phy0_ln_err() - clear DSI PHY lane-0 errors
680 * @ctrl: Pointer to the controller host hardware.
681 */
682 void (*clear_phy0_ln_err)(struct dsi_ctrl_hw *ctrl);
683
684 /**
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700685 * trigger_cmd_test_pattern() - trigger a command mode frame update with
686 * test pattern
687 * @ctrl: Pointer to the controller host hardware.
688 * @stream_id: Stream on which frame update is sent.
689 */
690 void (*trigger_cmd_test_pattern)(struct dsi_ctrl_hw *ctrl,
691 u32 stream_id);
Ajay Singh Parmar48ea4272016-06-27 11:44:34 -0700692
693 ssize_t (*reg_dump_to_buffer)(struct dsi_ctrl_hw *ctrl,
694 char *buf,
695 u32 size);
Rajkumar Subbiah01e6dd642017-07-05 14:47:47 -0400696
697 /**
698 * setup_misr() - Setup frame MISR
699 * @ctrl: Pointer to the controller host hardware.
700 * @panel_mode: CMD or VIDEO mode indicator
701 * @enable: Enable/disable MISR.
702 * @frame_count: Number of frames to accumulate MISR.
703 */
704 void (*setup_misr)(struct dsi_ctrl_hw *ctrl,
705 enum dsi_op_mode panel_mode,
706 bool enable, u32 frame_count);
707
708 /**
709 * collect_misr() - Read frame MISR
710 * @ctrl: Pointer to the controller host hardware.
711 * @panel_mode: CMD or VIDEO mode indicator
712 */
713 u32 (*collect_misr)(struct dsi_ctrl_hw *ctrl,
714 enum dsi_op_mode panel_mode);
715
Raviteja Tamatam68892de2017-06-20 04:47:19 +0530716 /**
717 * set_timing_db() - enable/disable Timing DB register
718 * @ctrl: Pointer to controller host hardware.
719 * @enable: Enable/Disable flag.
720 *
721 * Enable or Disabe the Timing DB register.
722 */
723 void (*set_timing_db)(struct dsi_ctrl_hw *ctrl,
724 bool enable);
Sandeep Panda79450002017-05-08 17:14:24 +0530725 /**
726 * clear_rdbk_register() - Clear and reset read back register
727 * @ctrl: Pointer to the controller host hardware.
728 */
729 void (*clear_rdbk_register)(struct dsi_ctrl_hw *ctrl);
Sandeep Pandaa2a3c8c2017-07-09 02:10:44 +0530730
731 /** schedule_dma_cmd() - Schdeule DMA command transfer on a
732 * particular blanking line.
733 * @ctrl: Pointer to the controller host hardware.
734 * @line_no: Blanking line number on whihch DMA command
735 * needs to be sent.
736 */
737 void (*schedule_dma_cmd)(struct dsi_ctrl_hw *ctrl, int line_no);
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700738};
739
740/*
741 * struct dsi_ctrl_hw - DSI controller hardware object specific to an instance
Shashank Babu Chinta Venkataafef8202017-04-21 13:49:56 -0700742 * @base: VA for the DSI controller base address.
743 * @length: Length of the DSI controller register map.
744 * @mmss_misc_base: Base address of mmss_misc register map.
745 * @mmss_misc_length: Length of mmss_misc register map.
746 * @disp_cc_base: Base address of disp_cc register map.
747 * @disp_cc_length: Length of disp_cc register map.
748 * @index: Instance ID of the controller.
749 * @feature_map: Features supported by the DSI controller.
750 * @ops: Function pointers to the operations supported by the
751 * controller.
752 * @supported_interrupts: Number of supported interrupts.
753 * @supported_errors: Number of supported errors.
Dhaval Patelabfaa082017-07-28 12:41:10 -0700754 * @phy_isolation_enabled: A boolean property allows to isolate the phy from
755 * dsi controller and run only dsi controller.
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700756 */
757struct dsi_ctrl_hw {
758 void __iomem *base;
759 u32 length;
760 void __iomem *mmss_misc_base;
761 u32 mmss_misc_length;
Shashank Babu Chinta Venkataafef8202017-04-21 13:49:56 -0700762 void __iomem *disp_cc_base;
763 u32 disp_cc_length;
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700764 u32 index;
765
766 /* features */
767 DECLARE_BITMAP(feature_map, DSI_CTRL_MAX_FEATURES);
768 struct dsi_ctrl_hw_ops ops;
769
770 /* capabilities */
771 u32 supported_interrupts;
772 u64 supported_errors;
Dhaval Patelabfaa082017-07-28 12:41:10 -0700773
774 bool phy_isolation_enabled;
Ajay Singh Parmar75098882016-05-16 17:43:17 -0700775};
776
777#endif /* _DSI_CTRL_HW_H_ */