blob: 80b91ca3c49bf3485e2df17ce24afb4bb5873b08 [file] [log] [blame]
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -07001/*
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +05302 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -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.
12 *
13 */
14
15#ifndef _DSI_CTRL_H_
16#define _DSI_CTRL_H_
17
Ajay Singh Parmar48ea4272016-06-27 11:44:34 -070018#include <linux/debugfs.h>
19
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070020#include "dsi_defs.h"
21#include "dsi_ctrl_hw.h"
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053022#include "dsi_clk.h"
23#include "dsi_pwr.h"
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070024#include "drm_mipi_dsi.h"
25
26/*
27 * DSI Command transfer modifiers
28 * @DSI_CTRL_CMD_READ: The current transfer involves reading data.
29 * @DSI_CTRL_CMD_BROADCAST: The current transfer needs to be done in
30 * broadcast mode to multiple slaves.
31 * @DSI_CTRL_CMD_BROADCAST_MASTER: This controller is the master and the slaves
32 * sync to this trigger.
33 * @DSI_CTRL_CMD_DEFER_TRIGGER: Defer the command trigger to later.
34 * @DSI_CTRL_CMD_FIFO_STORE: Use FIFO for command transfer in place of
35 * reading data from memory.
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -070036 * @DSI_CTRL_CMD_FETCH_MEMORY: Fetch command from memory through AXI bus
37 * and transfer it.
Vara Reddy326612b2017-09-20 04:41:10 -070038 * @DSI_CTRL_CMD_LAST_COMMAND: Trigger the DMA cmd transfer if this is last
39 * command in the batch.
Vara Reddydbeab892017-11-17 16:38:16 -080040 * @DSI_CTRL_CMD_NON_EMBEDDED_MODE:Trasfer cmd packets in non embedded mode.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070041 */
42#define DSI_CTRL_CMD_READ 0x1
43#define DSI_CTRL_CMD_BROADCAST 0x2
44#define DSI_CTRL_CMD_BROADCAST_MASTER 0x4
45#define DSI_CTRL_CMD_DEFER_TRIGGER 0x8
46#define DSI_CTRL_CMD_FIFO_STORE 0x10
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -070047#define DSI_CTRL_CMD_FETCH_MEMORY 0x20
Vara Reddy326612b2017-09-20 04:41:10 -070048#define DSI_CTRL_CMD_LAST_COMMAND 0x40
Vara Reddydbeab892017-11-17 16:38:16 -080049#define DSI_CTRL_CMD_NON_EMBEDDED_MODE 0x80
50
51/* DSI embedded mode fifo size
52 * If the command is greater than 256 bytes it is sent in non-embedded mode.
53 */
54#define DSI_EMBEDDED_MODE_DMA_MAX_SIZE_BYTES 256
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070055
Veera Sundaram Sankarand2a93942017-10-20 12:44:18 -070056/* max size supported for dsi cmd transfer using TPG */
57#define DSI_CTRL_MAX_CMD_FIFO_STORE_SIZE 64
58
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070059/**
60 * enum dsi_power_state - defines power states for dsi controller.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053061 * @DSI_CTRL_POWER_VREG_OFF: Digital and analog supplies for DSI controller
62 turned off
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070063 * @DSI_CTRL_POWER_VREG_ON: Digital and analog supplies for DSI controller
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070064 * @DSI_CTRL_POWER_MAX: Maximum value.
65 */
66enum dsi_power_state {
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053067 DSI_CTRL_POWER_VREG_OFF = 0,
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070068 DSI_CTRL_POWER_VREG_ON,
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -070069 DSI_CTRL_POWER_MAX,
70};
71
72/**
73 * enum dsi_engine_state - define engine status for dsi controller.
74 * @DSI_CTRL_ENGINE_OFF: Engine is turned off.
75 * @DSI_CTRL_ENGINE_ON: Engine is turned on.
76 * @DSI_CTRL_ENGINE_MAX: Maximum value.
77 */
78enum dsi_engine_state {
79 DSI_CTRL_ENGINE_OFF = 0,
80 DSI_CTRL_ENGINE_ON,
81 DSI_CTRL_ENGINE_MAX,
82};
83
84/**
85 * struct dsi_ctrl_power_info - digital and analog power supplies for dsi host
86 * @digital: Digital power supply required to turn on DSI controller hardware.
87 * @host_pwr: Analog power supplies required to turn on DSI controller hardware.
88 * Even though DSI controller it self does not require an analog
89 * power supply, supplies required for PLL can be defined here to
90 * allow proper control over these supplies.
91 */
92struct dsi_ctrl_power_info {
93 struct dsi_regulator_info digital;
94 struct dsi_regulator_info host_pwr;
95};
96
97/**
98 * struct dsi_ctrl_clk_info - clock information for DSI controller
99 * @core_clks: Core clocks needed to access DSI controller registers.
100 * @link_clks: Link clocks required to transmit data over DSI link.
101 * @rcg_clks: Root clock generation clocks generated in MMSS_CC. The
102 * output of the PLL is set as parent for these root
103 * clocks. These clocks are specific to controller
104 * instance.
105 * @mux_clks: Mux clocks used for Dynamic refresh feature.
106 * @ext_clks: External byte/pixel clocks from the MMSS block. These
107 * clocks are set as parent to rcg clocks.
108 * @pll_op_clks: TODO:
109 * @shadow_clks: TODO:
110 */
111struct dsi_ctrl_clk_info {
112 /* Clocks parsed from DT */
113 struct dsi_core_clk_info core_clks;
114 struct dsi_link_clk_info link_clks;
115 struct dsi_clk_link_set rcg_clks;
116
117 /* Clocks set by DSI Manager */
118 struct dsi_clk_link_set mux_clks;
119 struct dsi_clk_link_set ext_clks;
120 struct dsi_clk_link_set pll_op_clks;
121 struct dsi_clk_link_set shadow_clks;
122};
123
124/**
125 * struct dsi_ctrl_bus_scale_info - Bus scale info for msm-bus bandwidth voting
126 * @bus_scale_table: Bus scale voting usecases.
127 * @bus_handle: Handle used for voting bandwidth.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700128 */
129struct dsi_ctrl_bus_scale_info {
130 struct msm_bus_scale_pdata *bus_scale_table;
131 u32 bus_handle;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700132};
133
134/**
135 * struct dsi_ctrl_state_info - current driver state information
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530136 * @power_state: Status of power states on DSI controller.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700137 * @cmd_engine_state: Status of DSI command engine.
138 * @vid_engine_state: Status of DSI video engine.
139 * @controller_state: Status of DSI Controller engine.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530140 * @host_initialized: Boolean to indicate status of DSi host Initialization
141 * @tpg_enabled: Boolean to indicate whether tpg is enabled.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700142 */
143struct dsi_ctrl_state_info {
144 enum dsi_power_state power_state;
145 enum dsi_engine_state cmd_engine_state;
146 enum dsi_engine_state vid_engine_state;
147 enum dsi_engine_state controller_state;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700148 bool host_initialized;
149 bool tpg_enabled;
150};
151
152/**
153 * struct dsi_ctrl_interrupts - define interrupt information
Clarence Ip80ada7f2017-05-04 09:55:21 -0700154 * @irq_lock: Spinlock for ISR handler.
155 * @irq_num: Linux interrupt number associated with device.
156 * @irq_stat_mask: Hardware mask of currently enabled interrupts.
157 * @irq_stat_refcount: Number of times each interrupt has been requested.
158 * @irq_stat_cb: Status IRQ callback definitions.
Sandeep Panda11b20d82017-06-19 12:57:27 +0530159 * @irq_err_cb: IRQ callback definition to handle DSI ERRORs.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700160 * @cmd_dma_done: Completion signal for DSI_CMD_MODE_DMA_DONE interrupt
161 * @vid_frame_done: Completion signal for DSI_VIDEO_MODE_FRAME_DONE int.
162 * @cmd_frame_done: Completion signal for DSI_CMD_FRAME_DONE interrupt.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700163 */
164struct dsi_ctrl_interrupts {
Clarence Ip80ada7f2017-05-04 09:55:21 -0700165 spinlock_t irq_lock;
166 int irq_num;
167 uint32_t irq_stat_mask;
168 int irq_stat_refcount[DSI_STATUS_INTERRUPT_COUNT];
169 struct dsi_event_cb_info irq_stat_cb[DSI_STATUS_INTERRUPT_COUNT];
Sandeep Panda11b20d82017-06-19 12:57:27 +0530170 struct dsi_event_cb_info irq_err_cb;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700171
172 struct completion cmd_dma_done;
173 struct completion vid_frame_done;
174 struct completion cmd_frame_done;
Clarence Ip80ada7f2017-05-04 09:55:21 -0700175 struct completion bta_done;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700176};
177
178/**
179 * struct dsi_ctrl - DSI controller object
180 * @pdev: Pointer to platform device.
Alexander Beykun32a6a182017-02-27 17:46:51 -0500181 * @cell_index: Instance cell id.
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400182 * @horiz_index: Index in physical horizontal CTRL layout, 0 = leftmost
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700183 * @name: Name of the controller instance.
184 * @refcount: ref counter.
185 * @ctrl_lock: Mutex for hardware and object access.
186 * @drm_dev: Pointer to DRM device.
187 * @version: DSI controller version.
188 * @hw: DSI controller hardware object.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530189 * @current_state: Current driver and hardware state.
190 * @clk_cb: Callback for DSI clock control.
Clarence Ip80ada7f2017-05-04 09:55:21 -0700191 * @irq_info: Interrupt information.
Sandeep Panda11b20d82017-06-19 12:57:27 +0530192 * @recovery_cb: Recovery call back to SDE.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700193 * @clk_info: Clock information.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530194 * @clk_freq: DSi Link clock frequency information.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700195 * @pwr_info: Power information.
196 * @axi_bus_info: AXI bus information.
197 * @host_config: Current host configuration.
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400198 * @mode_bounds: Boundaries of the default mode ROI.
199 * Origin is at top left of all CTRLs.
200 * @roi: Partial update region of interest.
201 * Origin is top left of this CTRL.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700202 * @tx_cmd_buf: Tx command buffer.
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -0700203 * @cmd_buffer_iova: cmd buffer mapped address.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700204 * @cmd_buffer_size: Size of command buffer.
Veera Sundaram Sankarand2a93942017-10-20 12:44:18 -0700205 * @vaddr: CPU virtual address of cmd buffer.
206 * @secure_mode: Indicates if secure-session is in progress
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700207 * @debugfs_root: Root for debugfs entries.
Rajkumar Subbiah01e6dd642017-07-05 14:47:47 -0400208 * @misr_enable: Frame MISR enable/disable
209 * @misr_cache: Cached Frame MISR value
Dhaval Patelabfaa082017-07-28 12:41:10 -0700210 * @phy_isolation_enabled: A boolean property allows to isolate the phy from
211 * dsi controller and run only dsi controller.
Sravanthi Kollukudurud8809322017-10-26 15:24:13 +0530212 * @null_insertion_enabled: A boolean property to allow dsi controller to
213 * insert null packet.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700214 */
215struct dsi_ctrl {
216 struct platform_device *pdev;
Alexander Beykun32a6a182017-02-27 17:46:51 -0500217 u32 cell_index;
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400218 u32 horiz_index;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700219 const char *name;
220 u32 refcount;
221 struct mutex ctrl_lock;
222 struct drm_device *drm_dev;
223
224 enum dsi_ctrl_version version;
225 struct dsi_ctrl_hw hw;
226
227 /* Current state */
228 struct dsi_ctrl_state_info current_state;
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530229 struct clk_ctrl_cb clk_cb;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700230
Clarence Ip80ada7f2017-05-04 09:55:21 -0700231 struct dsi_ctrl_interrupts irq_info;
Sandeep Panda11b20d82017-06-19 12:57:27 +0530232 struct dsi_event_cb_info recovery_cb;
Clarence Ip80ada7f2017-05-04 09:55:21 -0700233
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700234 /* Clock and power states */
235 struct dsi_ctrl_clk_info clk_info;
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530236 struct link_clk_freq clk_freq;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700237 struct dsi_ctrl_power_info pwr_info;
238 struct dsi_ctrl_bus_scale_info axi_bus_info;
239
240 struct dsi_host_config host_config;
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400241 struct dsi_rect mode_bounds;
242 struct dsi_rect roi;
243
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700244 /* Command tx and rx */
245 struct drm_gem_object *tx_cmd_buf;
246 u32 cmd_buffer_size;
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -0700247 u32 cmd_buffer_iova;
Vara Reddy326612b2017-09-20 04:41:10 -0700248 u32 cmd_len;
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -0700249 void *vaddr;
Veera Sundaram Sankarand2a93942017-10-20 12:44:18 -0700250 u32 secure_mode;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700251
252 /* Debug Information */
253 struct dentry *debugfs_root;
254
Rajkumar Subbiah01e6dd642017-07-05 14:47:47 -0400255 /* MISR */
256 bool misr_enable;
257 u32 misr_cache;
258
Dhaval Patelabfaa082017-07-28 12:41:10 -0700259 bool phy_isolation_enabled;
Sravanthi Kollukudurud8809322017-10-26 15:24:13 +0530260 bool null_insertion_enabled;
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700261};
262
263/**
264 * dsi_ctrl_get() - get a dsi_ctrl handle from an of_node
265 * @of_node: of_node of the DSI controller.
266 *
267 * Gets the DSI controller handle for the corresponding of_node. The ref count
268 * is incremented to one and all subsequent gets will fail until the original
269 * clients calls a put.
270 *
271 * Return: DSI Controller handle.
272 */
273struct dsi_ctrl *dsi_ctrl_get(struct device_node *of_node);
274
275/**
276 * dsi_ctrl_put() - releases a dsi controller handle.
277 * @dsi_ctrl: DSI controller handle.
278 *
279 * Releases the DSI controller. Driver will clean up all resources and puts back
280 * the DSI controller into reset state.
281 */
282void dsi_ctrl_put(struct dsi_ctrl *dsi_ctrl);
283
284/**
285 * dsi_ctrl_drv_init() - initialize dsi controller driver.
286 * @dsi_ctrl: DSI controller handle.
Ajay Singh Parmar48ea4272016-06-27 11:44:34 -0700287 * @parent: Parent directory for debug fs.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700288 *
289 * Initializes DSI controller driver. Driver should be initialized after
290 * dsi_ctrl_get() succeeds.
291 *
292 * Return: error code.
293 */
Ajay Singh Parmar48ea4272016-06-27 11:44:34 -0700294int dsi_ctrl_drv_init(struct dsi_ctrl *dsi_ctrl, struct dentry *parent);
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700295
296/**
297 * dsi_ctrl_drv_deinit() - de-initializes dsi controller driver
298 * @dsi_ctrl: DSI controller handle.
299 *
300 * Releases all resources acquired by dsi_ctrl_drv_init().
301 *
302 * Return: error code.
303 */
304int dsi_ctrl_drv_deinit(struct dsi_ctrl *dsi_ctrl);
305
306/**
307 * dsi_ctrl_validate_timing() - validate a video timing configuration
308 * @dsi_ctrl: DSI controller handle.
309 * @timing: Pointer to timing data.
310 *
311 * Driver will validate if the timing configuration is supported on the
312 * controller hardware.
313 *
314 * Return: error code if timing is not supported.
315 */
316int dsi_ctrl_validate_timing(struct dsi_ctrl *dsi_ctrl,
317 struct dsi_mode_info *timing);
318
319/**
320 * dsi_ctrl_update_host_config() - update dsi host configuration
321 * @dsi_ctrl: DSI controller handle.
322 * @config: DSI host configuration.
Ajay Singh Parmar62f795b2016-06-10 23:20:23 -0700323 * @flags: dsi_mode_flags modifying the behavior
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530324 * @clk_handle: Clock handle for DSI clocks
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700325 *
326 * Updates driver with new Host configuration to use for host initialization.
327 * This function call will only update the software context. The stored
328 * configuration information will be used when the host is initialized.
329 *
330 * Return: error code.
331 */
332int dsi_ctrl_update_host_config(struct dsi_ctrl *dsi_ctrl,
Ajay Singh Parmar62f795b2016-06-10 23:20:23 -0700333 struct dsi_host_config *config,
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530334 int flags, void *clk_handle);
Ajay Singh Parmar62f795b2016-06-10 23:20:23 -0700335
336/**
Raviteja Tamatam68892de2017-06-20 04:47:19 +0530337 * dsi_ctrl_timing_db_update() - update only controller Timing DB
338 * @dsi_ctrl: DSI controller handle.
339 * @enable: Enable/disable Timing DB register
340 *
341 * Update timing db register value during dfps usecases
342 *
343 * Return: error code.
344 */
345int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
346 bool enable);
347
348/**
Ajay Singh Parmar62f795b2016-06-10 23:20:23 -0700349 * dsi_ctrl_async_timing_update() - update only controller timing
350 * @dsi_ctrl: DSI controller handle.
351 * @timing: New DSI timing info
352 *
353 * Updates host timing values to asynchronously transition to new timing
354 * For example, to update the porch values in a seamless/dynamic fps switch.
355 *
356 * Return: error code.
357 */
358int dsi_ctrl_async_timing_update(struct dsi_ctrl *dsi_ctrl,
359 struct dsi_mode_info *timing);
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700360
361/**
362 * dsi_ctrl_phy_sw_reset() - perform a PHY software reset
363 * @dsi_ctrl: DSI controller handle.
364 *
365 * Performs a PHY software reset on the DSI controller. Reset should be done
366 * when the controller power state is DSI_CTRL_POWER_CORE_CLK_ON and the PHY is
367 * not enabled.
368 *
369 * This function will fail if driver is in any other state.
370 *
371 * Return: error code.
372 */
373int dsi_ctrl_phy_sw_reset(struct dsi_ctrl *dsi_ctrl);
374
375/**
Padmanabhan Komanduru8ee8ee52016-12-19 12:10:51 +0530376 * dsi_ctrl_phy_reset_config() - Mask/unmask propagation of ahb reset signal
377 * to DSI PHY hardware.
378 * @dsi_ctrl: DSI controller handle.
379 * @enable: Mask/unmask the PHY reset signal.
380 *
381 * Return: error code.
382 */
383int dsi_ctrl_phy_reset_config(struct dsi_ctrl *dsi_ctrl, bool enable);
384
385/**
Lloyd Atkinson8c49c582016-11-18 14:23:54 -0500386 * dsi_ctrl_soft_reset() - perform a soft reset on DSI controller
387 * @dsi_ctrl: DSI controller handle.
388 *
389 * The video, command and controller engines will be disabled before the
390 * reset is triggered. After, the engines will be re-enabled to the same state
391 * as before the reset.
392 *
393 * If the reset is done while MDP timing engine is turned on, the video
394 * engine should be re-enabled only during the vertical blanking time.
395 *
396 * Return: error code
397 */
398int dsi_ctrl_soft_reset(struct dsi_ctrl *dsi_ctrl);
399
400/**
Jeykumar Sankarana7c7bbe2017-05-31 18:12:05 -0700401 * dsi_ctrl_host_timing_update - reinitialize host with new timing values
402 * @dsi_ctrl: DSI controller handle.
403 *
404 * Reinitialize DSI controller hardware with new display timing values
405 * when resolution is switched dynamically.
406 *
407 * Return: error code
408 */
409int dsi_ctrl_host_timing_update(struct dsi_ctrl *dsi_ctrl);
410
411/**
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700412 * dsi_ctrl_host_init() - Initialize DSI host hardware.
413 * @dsi_ctrl: DSI controller handle.
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700414 * @is_splash_enabled: boolean signifying splash status.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700415 *
416 * Initializes DSI controller hardware with host configuration provided by
417 * dsi_ctrl_update_host_config(). Initialization can be performed only during
418 * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
419 * performed.
420 *
421 * Return: error code.
422 */
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700423int dsi_ctrl_host_init(struct dsi_ctrl *dsi_ctrl, bool is_splash_enabled);
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700424
425/**
426 * dsi_ctrl_host_deinit() - De-Initialize DSI host hardware.
427 * @dsi_ctrl: DSI controller handle.
428 *
429 * De-initializes DSI controller hardware. It can be performed only during
430 * DSI_CTRL_POWER_CORE_CLK_ON state after LINK clocks have been turned off.
431 *
432 * Return: error code.
433 */
434int dsi_ctrl_host_deinit(struct dsi_ctrl *dsi_ctrl);
435
436/**
Shashank Babu Chinta Venkata82109522017-05-09 18:59:21 -0700437 * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
438 * @dsi_ctrl: DSI controller handle.
439 * @enable: enable/disable ULPS.
440 *
441 * ULPS can be enabled/disabled after DSI host engine is turned on.
442 *
443 * Return: error code.
444 */
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530445int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
446
447/**
448 * dsi_ctrl_setup() - Setup DSI host hardware while coming out of idle screen.
449 * @dsi_ctrl: DSI controller handle.
450 *
451 * Initializes DSI controller hardware with host configuration provided by
452 * dsi_ctrl_update_host_config(). Initialization can be performed only during
453 * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
454 * performed.
455 *
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400456 * Also used to program the video mode timing values.
457 *
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530458 * Return: error code.
459 */
460int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl);
461
462/**
Lloyd Atkinsone53b7372017-03-22 17:16:47 -0400463 * dsi_ctrl_set_roi() - Set DSI controller's region of interest
464 * @dsi_ctrl: DSI controller handle.
465 * @roi: Region of interest rectangle, must be less than mode bounds
466 * @changed: Output parameter, set to true of the controller's ROI was
467 * dirtied by setting the new ROI, and DCS cmd update needed
468 *
469 * Return: error code.
470 */
471int dsi_ctrl_set_roi(struct dsi_ctrl *dsi_ctrl, struct dsi_rect *roi,
472 bool *changed);
473
474/**
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700475 * dsi_ctrl_set_tpg_state() - enable/disable test pattern on the controller
476 * @dsi_ctrl: DSI controller handle.
477 * @on: enable/disable test pattern.
478 *
479 * Test pattern can be enabled only after Video engine (for video mode panels)
480 * or command engine (for cmd mode panels) is enabled.
481 *
482 * Return: error code.
483 */
484int dsi_ctrl_set_tpg_state(struct dsi_ctrl *dsi_ctrl, bool on);
485
486/**
487 * dsi_ctrl_cmd_transfer() - Transfer commands on DSI link
488 * @dsi_ctrl: DSI controller handle.
489 * @msg: Message to transfer on DSI link.
490 * @flags: Modifiers for message transfer.
491 *
492 * Command transfer can be done only when command engine is enabled. The
493 * transfer API will until either the command transfer finishes or the timeout
494 * value is reached. If the trigger is deferred, it will return without
495 * triggering the transfer. Command parameters are programmed to hardware.
496 *
497 * Return: error code.
498 */
499int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
500 const struct mipi_dsi_msg *msg,
501 u32 flags);
502
503/**
504 * dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command.
505 * @dsi_ctrl: DSI controller handle.
506 * @flags: Modifiers.
507 *
508 * Return: error code.
509 */
510int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags);
511
512/**
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700513 * dsi_ctrl_update_host_engine_state_for_cont_splash() - update engine
514 * states for cont splash usecase
515 * @dsi_ctrl: DSI controller handle.
516 * @state: DSI engine state
517 *
518 * Return: error code.
519 */
520int dsi_ctrl_update_host_engine_state_for_cont_splash(struct dsi_ctrl *dsi_ctrl,
521 enum dsi_engine_state state);
522
523/**
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700524 * dsi_ctrl_set_power_state() - set power state for dsi controller
525 * @dsi_ctrl: DSI controller handle.
526 * @state: Power state.
527 *
528 * Set power state for DSI controller. Power state can be changed only when
529 * Controller, Video and Command engines are turned off.
530 *
531 * Return: error code.
532 */
533int dsi_ctrl_set_power_state(struct dsi_ctrl *dsi_ctrl,
534 enum dsi_power_state state);
535
536/**
537 * dsi_ctrl_set_cmd_engine_state() - set command engine state
538 * @dsi_ctrl: DSI Controller handle.
539 * @state: Engine state.
540 *
541 * Command engine state can be modified only when DSI controller power state is
542 * set to DSI_CTRL_POWER_LINK_CLK_ON.
543 *
544 * Return: error code.
545 */
546int dsi_ctrl_set_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
547 enum dsi_engine_state state);
548
549/**
550 * dsi_ctrl_set_vid_engine_state() - set video engine state
551 * @dsi_ctrl: DSI Controller handle.
552 * @state: Engine state.
553 *
554 * Video engine state can be modified only when DSI controller power state is
555 * set to DSI_CTRL_POWER_LINK_CLK_ON.
556 *
557 * Return: error code.
558 */
559int dsi_ctrl_set_vid_engine_state(struct dsi_ctrl *dsi_ctrl,
560 enum dsi_engine_state state);
561
562/**
563 * dsi_ctrl_set_host_engine_state() - set host engine state
564 * @dsi_ctrl: DSI Controller handle.
565 * @state: Engine state.
566 *
567 * Host engine state can be modified only when DSI controller power state is
568 * set to DSI_CTRL_POWER_LINK_CLK_ON and cmd, video engines are disabled.
569 *
570 * Return: error code.
571 */
572int dsi_ctrl_set_host_engine_state(struct dsi_ctrl *dsi_ctrl,
573 enum dsi_engine_state state);
574
575/**
576 * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
577 * @dsi_ctrl: DSI controller handle.
578 * @enable: enable/disable ULPS.
579 *
580 * ULPS can be enabled/disabled after DSI host engine is turned on.
581 *
582 * Return: error code.
583 */
584int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
585
586/**
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530587 * dsi_ctrl_clk_cb_register() - Register DSI controller clk control callback
588 * @dsi_ctrl: DSI controller handle.
589 * @clk__cb: Structure containing callback for clock control.
590 *
591 * Register call for DSI clock control
592 *
593 * Return: error code.
594 */
595int dsi_ctrl_clk_cb_register(struct dsi_ctrl *dsi_ctrl,
596 struct clk_ctrl_cb *clk_cb);
597
598/**
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700599 * dsi_ctrl_set_clamp_state() - set clamp state for DSI phy
600 * @dsi_ctrl: DSI controller handle.
601 * @enable: enable/disable clamping.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530602 * @ulps_enabled: ulps state.
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700603 *
604 * Clamps can be enabled/disabled while DSI contoller is still turned on.
605 *
606 * Return: error code.
607 */
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530608int dsi_ctrl_set_clamp_state(struct dsi_ctrl *dsi_Ctrl,
609 bool enable, bool ulps_enabled);
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700610
611/**
612 * dsi_ctrl_set_clock_source() - set clock source fpr dsi link clocks
613 * @dsi_ctrl: DSI controller handle.
614 * @source_clks: Source clocks for DSI link clocks.
615 *
616 * Clock source should be changed while link clocks are disabled.
617 *
618 * Return: error code.
619 */
620int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl,
621 struct dsi_clk_link_set *source_clks);
622
623/**
Clarence Ip80ada7f2017-05-04 09:55:21 -0700624 * dsi_ctrl_enable_status_interrupt() - enable status interrupts
625 * @dsi_ctrl: DSI controller handle.
626 * @intr_idx: Index interrupt to disable.
627 * @event_info: Pointer to event callback definition
628 */
629void dsi_ctrl_enable_status_interrupt(struct dsi_ctrl *dsi_ctrl,
630 uint32_t intr_idx, struct dsi_event_cb_info *event_info);
631
632/**
633 * dsi_ctrl_disable_status_interrupt() - disable status interrupts
634 * @dsi_ctrl: DSI controller handle.
635 * @intr_idx: Index interrupt to disable.
636 */
637void dsi_ctrl_disable_status_interrupt(
638 struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx);
639
640/**
Rajkumar Subbiah01e6dd642017-07-05 14:47:47 -0400641 * dsi_ctrl_setup_misr() - Setup frame MISR
642 * @dsi_ctrl: DSI controller handle.
643 * @enable: enable/disable MISR.
644 * @frame_count: Number of frames to accumulate MISR.
645 *
646 * Return: error code.
647 */
648int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
649 bool enable,
650 u32 frame_count);
651
652/**
653 * dsi_ctrl_collect_misr() - Read frame MISR
654 * @dsi_ctrl: DSI controller handle.
655 *
656 * Return: MISR value.
657 */
658u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl);
659
660/**
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700661 * dsi_ctrl_drv_register() - register platform driver for dsi controller
662 */
663void dsi_ctrl_drv_register(void);
664
665/**
666 * dsi_ctrl_drv_unregister() - unregister platform driver
667 */
668void dsi_ctrl_drv_unregister(void);
669
Sandeep Panda11b20d82017-06-19 12:57:27 +0530670/**
671 * dsi_ctrl_reset() - Reset DSI PHY CLK/DATA lane
672 * @dsi_ctrl: DSI controller handle.
673 * @mask: Mask to indicate if CLK and/or DATA lane needs reset.
674 */
675int dsi_ctrl_reset(struct dsi_ctrl *dsi_ctrl, int mask);
676
677/**
678 * dsi_ctrl_get_hw_version() - read dsi controller hw revision
679 * @dsi_ctrl: DSI controller handle.
680 */
681int dsi_ctrl_get_hw_version(struct dsi_ctrl *dsi_ctrl);
682
683/**
684 * dsi_ctrl_vid_engine_en() - Control DSI video engine HW state
685 * @dsi_ctrl: DSI controller handle.
686 * @on: variable to control video engine ON/OFF.
687 */
688int dsi_ctrl_vid_engine_en(struct dsi_ctrl *dsi_ctrl, bool on);
689
Vara Reddydbeab892017-11-17 16:38:16 -0800690/**
691 * @dsi_ctrl: DSI controller handle.
692 * cmd_len: Length of command.
693 * flags: Config mode flags.
694 */
695void dsi_message_setup_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
696 u32 *flags);
697
698/**
699 * @dsi_ctrl: DSI controller handle.
700 * cmd_len: Length of command.
701 * flags: Config mode flags.
702 */
703int dsi_message_validate_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
704 u32 *flags);
705
Ajay Singh Parmar5c6b4862016-06-22 17:31:21 -0700706#endif /* _DSI_CTRL_H_ */