Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 1 | /* |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 3 | * |
| 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 Parmar | 48ea427 | 2016-06-27 11:44:34 -0700 | [diff] [blame] | 18 | #include <linux/debugfs.h> |
| 19 | |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 20 | #include "dsi_defs.h" |
| 21 | #include "dsi_ctrl_hw.h" |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 22 | #include "dsi_clk.h" |
| 23 | #include "dsi_pwr.h" |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 24 | #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 Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 36 | * @DSI_CTRL_CMD_FETCH_MEMORY: Fetch command from memory through AXI bus |
| 37 | * and transfer it. |
Vara Reddy | 326612b | 2017-09-20 04:41:10 -0700 | [diff] [blame] | 38 | * @DSI_CTRL_CMD_LAST_COMMAND: Trigger the DMA cmd transfer if this is last |
| 39 | * command in the batch. |
Vara Reddy | dbeab89 | 2017-11-17 16:38:16 -0800 | [diff] [blame] | 40 | * @DSI_CTRL_CMD_NON_EMBEDDED_MODE:Trasfer cmd packets in non embedded mode. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 41 | */ |
| 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 Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 47 | #define DSI_CTRL_CMD_FETCH_MEMORY 0x20 |
Vara Reddy | 326612b | 2017-09-20 04:41:10 -0700 | [diff] [blame] | 48 | #define DSI_CTRL_CMD_LAST_COMMAND 0x40 |
Vara Reddy | dbeab89 | 2017-11-17 16:38:16 -0800 | [diff] [blame] | 49 | #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 Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 55 | |
Veera Sundaram Sankaran | d2a9394 | 2017-10-20 12:44:18 -0700 | [diff] [blame] | 56 | /* max size supported for dsi cmd transfer using TPG */ |
| 57 | #define DSI_CTRL_MAX_CMD_FIFO_STORE_SIZE 64 |
| 58 | |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 59 | /** |
| 60 | * enum dsi_power_state - defines power states for dsi controller. |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 61 | * @DSI_CTRL_POWER_VREG_OFF: Digital and analog supplies for DSI controller |
| 62 | turned off |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 63 | * @DSI_CTRL_POWER_VREG_ON: Digital and analog supplies for DSI controller |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 64 | * @DSI_CTRL_POWER_MAX: Maximum value. |
| 65 | */ |
| 66 | enum dsi_power_state { |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 67 | DSI_CTRL_POWER_VREG_OFF = 0, |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 68 | DSI_CTRL_POWER_VREG_ON, |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 69 | 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 | */ |
| 78 | enum 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 | */ |
| 92 | struct 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 | */ |
| 111 | struct 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 Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 128 | */ |
| 129 | struct dsi_ctrl_bus_scale_info { |
| 130 | struct msm_bus_scale_pdata *bus_scale_table; |
| 131 | u32 bus_handle; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | /** |
| 135 | * struct dsi_ctrl_state_info - current driver state information |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 136 | * @power_state: Status of power states on DSI controller. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 137 | * @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 Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 140 | * @host_initialized: Boolean to indicate status of DSi host Initialization |
| 141 | * @tpg_enabled: Boolean to indicate whether tpg is enabled. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 142 | */ |
| 143 | struct 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 Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 148 | bool host_initialized; |
| 149 | bool tpg_enabled; |
| 150 | }; |
| 151 | |
| 152 | /** |
| 153 | * struct dsi_ctrl_interrupts - define interrupt information |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 154 | * @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 Panda | 11b20d8 | 2017-06-19 12:57:27 +0530 | [diff] [blame] | 159 | * @irq_err_cb: IRQ callback definition to handle DSI ERRORs. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 160 | * @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 Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 163 | */ |
| 164 | struct dsi_ctrl_interrupts { |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 165 | 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 Panda | 11b20d8 | 2017-06-19 12:57:27 +0530 | [diff] [blame] | 170 | struct dsi_event_cb_info irq_err_cb; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 171 | |
| 172 | struct completion cmd_dma_done; |
| 173 | struct completion vid_frame_done; |
| 174 | struct completion cmd_frame_done; |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 175 | struct completion bta_done; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | /** |
| 179 | * struct dsi_ctrl - DSI controller object |
| 180 | * @pdev: Pointer to platform device. |
Alexander Beykun | 32a6a18 | 2017-02-27 17:46:51 -0500 | [diff] [blame] | 181 | * @cell_index: Instance cell id. |
Lloyd Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 182 | * @horiz_index: Index in physical horizontal CTRL layout, 0 = leftmost |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 183 | * @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 Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 189 | * @current_state: Current driver and hardware state. |
| 190 | * @clk_cb: Callback for DSI clock control. |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 191 | * @irq_info: Interrupt information. |
Sandeep Panda | 11b20d8 | 2017-06-19 12:57:27 +0530 | [diff] [blame] | 192 | * @recovery_cb: Recovery call back to SDE. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 193 | * @clk_info: Clock information. |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 194 | * @clk_freq: DSi Link clock frequency information. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 195 | * @pwr_info: Power information. |
| 196 | * @axi_bus_info: AXI bus information. |
| 197 | * @host_config: Current host configuration. |
Lloyd Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 198 | * @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 Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 202 | * @tx_cmd_buf: Tx command buffer. |
Shashank Babu Chinta Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 203 | * @cmd_buffer_iova: cmd buffer mapped address. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 204 | * @cmd_buffer_size: Size of command buffer. |
Veera Sundaram Sankaran | d2a9394 | 2017-10-20 12:44:18 -0700 | [diff] [blame] | 205 | * @vaddr: CPU virtual address of cmd buffer. |
| 206 | * @secure_mode: Indicates if secure-session is in progress |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 207 | * @debugfs_root: Root for debugfs entries. |
Rajkumar Subbiah | 01e6dd64 | 2017-07-05 14:47:47 -0400 | [diff] [blame] | 208 | * @misr_enable: Frame MISR enable/disable |
| 209 | * @misr_cache: Cached Frame MISR value |
Dhaval Patel | abfaa08 | 2017-07-28 12:41:10 -0700 | [diff] [blame] | 210 | * @phy_isolation_enabled: A boolean property allows to isolate the phy from |
| 211 | * dsi controller and run only dsi controller. |
Sravanthi Kollukuduru | d880932 | 2017-10-26 15:24:13 +0530 | [diff] [blame] | 212 | * @null_insertion_enabled: A boolean property to allow dsi controller to |
| 213 | * insert null packet. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 214 | */ |
| 215 | struct dsi_ctrl { |
| 216 | struct platform_device *pdev; |
Alexander Beykun | 32a6a18 | 2017-02-27 17:46:51 -0500 | [diff] [blame] | 217 | u32 cell_index; |
Lloyd Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 218 | u32 horiz_index; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 219 | 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 Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 229 | struct clk_ctrl_cb clk_cb; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 230 | |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 231 | struct dsi_ctrl_interrupts irq_info; |
Sandeep Panda | 11b20d8 | 2017-06-19 12:57:27 +0530 | [diff] [blame] | 232 | struct dsi_event_cb_info recovery_cb; |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 233 | |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 234 | /* Clock and power states */ |
| 235 | struct dsi_ctrl_clk_info clk_info; |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 236 | struct link_clk_freq clk_freq; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 237 | 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 Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 241 | struct dsi_rect mode_bounds; |
| 242 | struct dsi_rect roi; |
| 243 | |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 244 | /* Command tx and rx */ |
| 245 | struct drm_gem_object *tx_cmd_buf; |
| 246 | u32 cmd_buffer_size; |
Shashank Babu Chinta Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 247 | u32 cmd_buffer_iova; |
Vara Reddy | 326612b | 2017-09-20 04:41:10 -0700 | [diff] [blame] | 248 | u32 cmd_len; |
Shashank Babu Chinta Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 249 | void *vaddr; |
Veera Sundaram Sankaran | d2a9394 | 2017-10-20 12:44:18 -0700 | [diff] [blame] | 250 | u32 secure_mode; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 251 | |
| 252 | /* Debug Information */ |
| 253 | struct dentry *debugfs_root; |
| 254 | |
Rajkumar Subbiah | 01e6dd64 | 2017-07-05 14:47:47 -0400 | [diff] [blame] | 255 | /* MISR */ |
| 256 | bool misr_enable; |
| 257 | u32 misr_cache; |
| 258 | |
Dhaval Patel | abfaa08 | 2017-07-28 12:41:10 -0700 | [diff] [blame] | 259 | bool phy_isolation_enabled; |
Sravanthi Kollukuduru | d880932 | 2017-10-26 15:24:13 +0530 | [diff] [blame] | 260 | bool null_insertion_enabled; |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 261 | }; |
| 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 | */ |
| 273 | struct 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 | */ |
| 282 | void 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 Parmar | 48ea427 | 2016-06-27 11:44:34 -0700 | [diff] [blame] | 287 | * @parent: Parent directory for debug fs. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 288 | * |
| 289 | * Initializes DSI controller driver. Driver should be initialized after |
| 290 | * dsi_ctrl_get() succeeds. |
| 291 | * |
| 292 | * Return: error code. |
| 293 | */ |
Ajay Singh Parmar | 48ea427 | 2016-06-27 11:44:34 -0700 | [diff] [blame] | 294 | int dsi_ctrl_drv_init(struct dsi_ctrl *dsi_ctrl, struct dentry *parent); |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 295 | |
| 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 | */ |
| 304 | int 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 | */ |
| 316 | int 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 Parmar | 62f795b | 2016-06-10 23:20:23 -0700 | [diff] [blame] | 323 | * @flags: dsi_mode_flags modifying the behavior |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 324 | * @clk_handle: Clock handle for DSI clocks |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 325 | * |
| 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 | */ |
| 332 | int dsi_ctrl_update_host_config(struct dsi_ctrl *dsi_ctrl, |
Ajay Singh Parmar | 62f795b | 2016-06-10 23:20:23 -0700 | [diff] [blame] | 333 | struct dsi_host_config *config, |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 334 | int flags, void *clk_handle); |
Ajay Singh Parmar | 62f795b | 2016-06-10 23:20:23 -0700 | [diff] [blame] | 335 | |
| 336 | /** |
Raviteja Tamatam | 68892de | 2017-06-20 04:47:19 +0530 | [diff] [blame] | 337 | * 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 | */ |
| 345 | int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl, |
| 346 | bool enable); |
| 347 | |
| 348 | /** |
Ajay Singh Parmar | 62f795b | 2016-06-10 23:20:23 -0700 | [diff] [blame] | 349 | * 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 | */ |
| 358 | int dsi_ctrl_async_timing_update(struct dsi_ctrl *dsi_ctrl, |
| 359 | struct dsi_mode_info *timing); |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 360 | |
| 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 | */ |
| 373 | int dsi_ctrl_phy_sw_reset(struct dsi_ctrl *dsi_ctrl); |
| 374 | |
| 375 | /** |
Padmanabhan Komanduru | 8ee8ee5 | 2016-12-19 12:10:51 +0530 | [diff] [blame] | 376 | * 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 | */ |
| 383 | int dsi_ctrl_phy_reset_config(struct dsi_ctrl *dsi_ctrl, bool enable); |
| 384 | |
| 385 | /** |
Lloyd Atkinson | 8c49c58 | 2016-11-18 14:23:54 -0500 | [diff] [blame] | 386 | * 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 | */ |
| 398 | int dsi_ctrl_soft_reset(struct dsi_ctrl *dsi_ctrl); |
| 399 | |
| 400 | /** |
Jeykumar Sankaran | a7c7bbe | 2017-05-31 18:12:05 -0700 | [diff] [blame] | 401 | * 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 | */ |
| 409 | int dsi_ctrl_host_timing_update(struct dsi_ctrl *dsi_ctrl); |
| 410 | |
| 411 | /** |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 412 | * dsi_ctrl_host_init() - Initialize DSI host hardware. |
| 413 | * @dsi_ctrl: DSI controller handle. |
Shashank Babu Chinta Venkata | 7d60873 | 2017-05-31 14:10:26 -0700 | [diff] [blame] | 414 | * @is_splash_enabled: boolean signifying splash status. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 415 | * |
| 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 Venkata | 7d60873 | 2017-05-31 14:10:26 -0700 | [diff] [blame] | 423 | int dsi_ctrl_host_init(struct dsi_ctrl *dsi_ctrl, bool is_splash_enabled); |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 424 | |
| 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 | */ |
| 434 | int dsi_ctrl_host_deinit(struct dsi_ctrl *dsi_ctrl); |
| 435 | |
| 436 | /** |
Shashank Babu Chinta Venkata | 8210952 | 2017-05-09 18:59:21 -0700 | [diff] [blame] | 437 | * 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 Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 445 | int 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 Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 456 | * Also used to program the video mode timing values. |
| 457 | * |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 458 | * Return: error code. |
| 459 | */ |
| 460 | int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl); |
| 461 | |
| 462 | /** |
Lloyd Atkinson | e53b737 | 2017-03-22 17:16:47 -0400 | [diff] [blame] | 463 | * 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 | */ |
| 471 | int dsi_ctrl_set_roi(struct dsi_ctrl *dsi_ctrl, struct dsi_rect *roi, |
| 472 | bool *changed); |
| 473 | |
| 474 | /** |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 475 | * 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 | */ |
| 484 | int 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 | */ |
| 499 | int 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 | */ |
| 510 | int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags); |
| 511 | |
| 512 | /** |
Shashank Babu Chinta Venkata | 7d60873 | 2017-05-31 14:10:26 -0700 | [diff] [blame] | 513 | * 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 | */ |
| 520 | int dsi_ctrl_update_host_engine_state_for_cont_splash(struct dsi_ctrl *dsi_ctrl, |
| 521 | enum dsi_engine_state state); |
| 522 | |
| 523 | /** |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 524 | * 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 | */ |
| 533 | int 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 | */ |
| 546 | int 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 | */ |
| 559 | int 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 | */ |
| 572 | int 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 | */ |
| 584 | int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable); |
| 585 | |
| 586 | /** |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 587 | * 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 | */ |
| 595 | int dsi_ctrl_clk_cb_register(struct dsi_ctrl *dsi_ctrl, |
| 596 | struct clk_ctrl_cb *clk_cb); |
| 597 | |
| 598 | /** |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 599 | * dsi_ctrl_set_clamp_state() - set clamp state for DSI phy |
| 600 | * @dsi_ctrl: DSI controller handle. |
| 601 | * @enable: enable/disable clamping. |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 602 | * @ulps_enabled: ulps state. |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 603 | * |
| 604 | * Clamps can be enabled/disabled while DSI contoller is still turned on. |
| 605 | * |
| 606 | * Return: error code. |
| 607 | */ |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 608 | int dsi_ctrl_set_clamp_state(struct dsi_ctrl *dsi_Ctrl, |
| 609 | bool enable, bool ulps_enabled); |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 610 | |
| 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 | */ |
| 620 | int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl, |
| 621 | struct dsi_clk_link_set *source_clks); |
| 622 | |
| 623 | /** |
Clarence Ip | 80ada7f | 2017-05-04 09:55:21 -0700 | [diff] [blame] | 624 | * 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 | */ |
| 629 | void 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 | */ |
| 637 | void dsi_ctrl_disable_status_interrupt( |
| 638 | struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx); |
| 639 | |
| 640 | /** |
Rajkumar Subbiah | 01e6dd64 | 2017-07-05 14:47:47 -0400 | [diff] [blame] | 641 | * 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 | */ |
| 648 | int 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 | */ |
| 658 | u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl); |
| 659 | |
| 660 | /** |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 661 | * dsi_ctrl_drv_register() - register platform driver for dsi controller |
| 662 | */ |
| 663 | void dsi_ctrl_drv_register(void); |
| 664 | |
| 665 | /** |
| 666 | * dsi_ctrl_drv_unregister() - unregister platform driver |
| 667 | */ |
| 668 | void dsi_ctrl_drv_unregister(void); |
| 669 | |
Sandeep Panda | 11b20d8 | 2017-06-19 12:57:27 +0530 | [diff] [blame] | 670 | /** |
| 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 | */ |
| 675 | int 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 | */ |
| 681 | int 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 | */ |
| 688 | int dsi_ctrl_vid_engine_en(struct dsi_ctrl *dsi_ctrl, bool on); |
| 689 | |
Vara Reddy | dbeab89 | 2017-11-17 16:38:16 -0800 | [diff] [blame] | 690 | /** |
| 691 | * @dsi_ctrl: DSI controller handle. |
| 692 | * cmd_len: Length of command. |
| 693 | * flags: Config mode flags. |
| 694 | */ |
| 695 | void 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 | */ |
| 703 | int dsi_message_validate_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len, |
| 704 | u32 *flags); |
| 705 | |
Ajay Singh Parmar | 5c6b486 | 2016-06-22 17:31:21 -0700 | [diff] [blame] | 706 | #endif /* _DSI_CTRL_H_ */ |