dsi_ctrl.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DSI_CTRL_H_
  6. #define _DSI_CTRL_H_
  7. #include <linux/debugfs.h>
  8. #include "dsi_defs.h"
  9. #include "dsi_ctrl_hw.h"
  10. #include "dsi_clk.h"
  11. #include "dsi_pwr.h"
  12. #include "drm_mipi_dsi.h"
  13. /*
  14. * DSI Command transfer modifiers
  15. * @DSI_CTRL_CMD_READ: The current transfer involves reading data.
  16. * @DSI_CTRL_CMD_BROADCAST: The current transfer needs to be done in
  17. * broadcast mode to multiple slaves.
  18. * @DSI_CTRL_CMD_BROADCAST_MASTER: This controller is the master and the slaves
  19. * sync to this trigger.
  20. * @DSI_CTRL_CMD_DEFER_TRIGGER: Defer the command trigger to later.
  21. * @DSI_CTRL_CMD_FIFO_STORE: Use FIFO for command transfer in place of
  22. * reading data from memory.
  23. * @DSI_CTRL_CMD_FETCH_MEMORY: Fetch command from memory through AXI bus
  24. * and transfer it.
  25. * @DSI_CTRL_CMD_LAST_COMMAND: Trigger the DMA cmd transfer if this is last
  26. * command in the batch.
  27. * @DSI_CTRL_CMD_NON_EMBEDDED_MODE:Transfer cmd packets in non embedded mode.
  28. * @DSI_CTRL_CMD_CUSTOM_DMA_SCHED: Use the dma scheduling line number defined in
  29. * display panel dtsi file instead of default.
  30. */
  31. #define DSI_CTRL_CMD_READ 0x1
  32. #define DSI_CTRL_CMD_BROADCAST 0x2
  33. #define DSI_CTRL_CMD_BROADCAST_MASTER 0x4
  34. #define DSI_CTRL_CMD_DEFER_TRIGGER 0x8
  35. #define DSI_CTRL_CMD_FIFO_STORE 0x10
  36. #define DSI_CTRL_CMD_FETCH_MEMORY 0x20
  37. #define DSI_CTRL_CMD_LAST_COMMAND 0x40
  38. #define DSI_CTRL_CMD_NON_EMBEDDED_MODE 0x80
  39. #define DSI_CTRL_CMD_CUSTOM_DMA_SCHED 0x100
  40. /* DSI embedded mode fifo size
  41. * If the command is greater than 256 bytes it is sent in non-embedded mode.
  42. */
  43. #define DSI_EMBEDDED_MODE_DMA_MAX_SIZE_BYTES 256
  44. /* max size supported for dsi cmd transfer using TPG */
  45. #define DSI_CTRL_MAX_CMD_FIFO_STORE_SIZE 64
  46. /**
  47. * enum dsi_power_state - defines power states for dsi controller.
  48. * @DSI_CTRL_POWER_VREG_OFF: Digital and analog supplies for DSI controller
  49. turned off
  50. * @DSI_CTRL_POWER_VREG_ON: Digital and analog supplies for DSI controller
  51. * @DSI_CTRL_POWER_MAX: Maximum value.
  52. */
  53. enum dsi_power_state {
  54. DSI_CTRL_POWER_VREG_OFF = 0,
  55. DSI_CTRL_POWER_VREG_ON,
  56. DSI_CTRL_POWER_MAX,
  57. };
  58. /**
  59. * enum dsi_engine_state - define engine status for dsi controller.
  60. * @DSI_CTRL_ENGINE_OFF: Engine is turned off.
  61. * @DSI_CTRL_ENGINE_ON: Engine is turned on.
  62. * @DSI_CTRL_ENGINE_MAX: Maximum value.
  63. */
  64. enum dsi_engine_state {
  65. DSI_CTRL_ENGINE_OFF = 0,
  66. DSI_CTRL_ENGINE_ON,
  67. DSI_CTRL_ENGINE_MAX,
  68. };
  69. /**
  70. * struct dsi_ctrl_power_info - digital and analog power supplies for dsi host
  71. * @digital: Digital power supply required to turn on DSI controller hardware.
  72. * @host_pwr: Analog power supplies required to turn on DSI controller hardware.
  73. * Even though DSI controller it self does not require an analog
  74. * power supply, supplies required for PLL can be defined here to
  75. * allow proper control over these supplies.
  76. */
  77. struct dsi_ctrl_power_info {
  78. struct dsi_regulator_info digital;
  79. struct dsi_regulator_info host_pwr;
  80. };
  81. /**
  82. * struct dsi_ctrl_clk_info - clock information for DSI controller
  83. * @core_clks: Core clocks needed to access DSI controller registers.
  84. * @hs_link_clks: Clocks required to transmit high speed data over DSI
  85. * @lp_link_clks: Clocks required to perform low power ops over DSI
  86. * @rcg_clks: Root clock generation clocks generated in MMSS_CC. The
  87. * output of the PLL is set as parent for these root
  88. * clocks. These clocks are specific to controller
  89. * instance.
  90. * @mux_clks: Mux clocks used for Dynamic refresh feature.
  91. * @ext_clks: External byte/pixel clocks from the MMSS block. These
  92. * clocks are set as parent to rcg clocks.
  93. * @pll_op_clks: TODO:
  94. * @shadow_clks: TODO:
  95. */
  96. struct dsi_ctrl_clk_info {
  97. /* Clocks parsed from DT */
  98. struct dsi_core_clk_info core_clks;
  99. struct dsi_link_hs_clk_info hs_link_clks;
  100. struct dsi_link_lp_clk_info lp_link_clks;
  101. struct dsi_clk_link_set rcg_clks;
  102. /* Clocks set by DSI Manager */
  103. struct dsi_clk_link_set mux_clks;
  104. struct dsi_clk_link_set ext_clks;
  105. struct dsi_clk_link_set pll_op_clks;
  106. struct dsi_clk_link_set shadow_clks;
  107. };
  108. /**
  109. * struct dsi_ctrl_bus_scale_info - Bus scale info for msm-bus bandwidth voting
  110. * @bus_scale_table: Bus scale voting usecases.
  111. * @bus_handle: Handle used for voting bandwidth.
  112. */
  113. struct dsi_ctrl_bus_scale_info {
  114. struct msm_bus_scale_pdata *bus_scale_table;
  115. u32 bus_handle;
  116. };
  117. /**
  118. * struct dsi_ctrl_state_info - current driver state information
  119. * @power_state: Status of power states on DSI controller.
  120. * @cmd_engine_state: Status of DSI command engine.
  121. * @vid_engine_state: Status of DSI video engine.
  122. * @controller_state: Status of DSI Controller engine.
  123. * @host_initialized: Boolean to indicate status of DSi host Initialization
  124. * @tpg_enabled: Boolean to indicate whether tpg is enabled.
  125. */
  126. struct dsi_ctrl_state_info {
  127. enum dsi_power_state power_state;
  128. enum dsi_engine_state cmd_engine_state;
  129. enum dsi_engine_state vid_engine_state;
  130. enum dsi_engine_state controller_state;
  131. bool host_initialized;
  132. bool tpg_enabled;
  133. };
  134. /**
  135. * struct dsi_ctrl_interrupts - define interrupt information
  136. * @irq_lock: Spinlock for ISR handler.
  137. * @irq_num: Linux interrupt number associated with device.
  138. * @irq_stat_mask: Hardware mask of currently enabled interrupts.
  139. * @irq_stat_refcount: Number of times each interrupt has been requested.
  140. * @irq_stat_cb: Status IRQ callback definitions.
  141. * @irq_err_cb: IRQ callback definition to handle DSI ERRORs.
  142. * @cmd_dma_done: Completion signal for DSI_CMD_MODE_DMA_DONE interrupt
  143. * @vid_frame_done: Completion signal for DSI_VIDEO_MODE_FRAME_DONE int.
  144. * @cmd_frame_done: Completion signal for DSI_CMD_FRAME_DONE interrupt.
  145. */
  146. struct dsi_ctrl_interrupts {
  147. spinlock_t irq_lock;
  148. int irq_num;
  149. uint32_t irq_stat_mask;
  150. int irq_stat_refcount[DSI_STATUS_INTERRUPT_COUNT];
  151. struct dsi_event_cb_info irq_stat_cb[DSI_STATUS_INTERRUPT_COUNT];
  152. struct dsi_event_cb_info irq_err_cb;
  153. struct completion cmd_dma_done;
  154. struct completion vid_frame_done;
  155. struct completion cmd_frame_done;
  156. struct completion bta_done;
  157. };
  158. /**
  159. * struct dsi_ctrl - DSI controller object
  160. * @pdev: Pointer to platform device.
  161. * @cell_index: Instance cell id.
  162. * @horiz_index: Index in physical horizontal CTRL layout, 0 = leftmost
  163. * @name: Name of the controller instance.
  164. * @refcount: ref counter.
  165. * @ctrl_lock: Mutex for hardware and object access.
  166. * @drm_dev: Pointer to DRM device.
  167. * @version: DSI controller version.
  168. * @hw: DSI controller hardware object.
  169. * @current_state: Current driver and hardware state.
  170. * @clk_cb: Callback for DSI clock control.
  171. * @irq_info: Interrupt information.
  172. * @recovery_cb: Recovery call back to SDE.
  173. * @clk_info: Clock information.
  174. * @clk_freq: DSi Link clock frequency information.
  175. * @pwr_info: Power information.
  176. * @axi_bus_info: AXI bus information.
  177. * @host_config: Current host configuration.
  178. * @mode_bounds: Boundaries of the default mode ROI.
  179. * Origin is at top left of all CTRLs.
  180. * @roi: Partial update region of interest.
  181. * Origin is top left of this CTRL.
  182. * @tx_cmd_buf: Tx command buffer.
  183. * @cmd_buffer_iova: cmd buffer mapped address.
  184. * @cmd_buffer_size: Size of command buffer.
  185. * @vaddr: CPU virtual address of cmd buffer.
  186. * @secure_mode: Indicates if secure-session is in progress
  187. * @esd_check_underway: Indicates if esd status check is in progress
  188. * @debugfs_root: Root for debugfs entries.
  189. * @misr_enable: Frame MISR enable/disable
  190. * @misr_cache: Cached Frame MISR value
  191. * @phy_isolation_enabled: A boolean property allows to isolate the phy from
  192. * dsi controller and run only dsi controller.
  193. * @null_insertion_enabled: A boolean property to allow dsi controller to
  194. * insert null packet.
  195. * @modeupdated: Boolean to send new roi if mode is updated.
  196. */
  197. struct dsi_ctrl {
  198. struct platform_device *pdev;
  199. u32 cell_index;
  200. u32 horiz_index;
  201. const char *name;
  202. u32 refcount;
  203. struct mutex ctrl_lock;
  204. struct drm_device *drm_dev;
  205. enum dsi_ctrl_version version;
  206. struct dsi_ctrl_hw hw;
  207. /* Current state */
  208. struct dsi_ctrl_state_info current_state;
  209. struct clk_ctrl_cb clk_cb;
  210. struct dsi_ctrl_interrupts irq_info;
  211. struct dsi_event_cb_info recovery_cb;
  212. /* Clock and power states */
  213. struct dsi_ctrl_clk_info clk_info;
  214. struct link_clk_freq clk_freq;
  215. struct dsi_ctrl_power_info pwr_info;
  216. struct dsi_ctrl_bus_scale_info axi_bus_info;
  217. struct dsi_host_config host_config;
  218. struct dsi_rect mode_bounds;
  219. struct dsi_rect roi;
  220. /* Command tx and rx */
  221. struct drm_gem_object *tx_cmd_buf;
  222. u32 cmd_buffer_size;
  223. u32 cmd_buffer_iova;
  224. u32 cmd_len;
  225. void *vaddr;
  226. bool secure_mode;
  227. bool esd_check_underway;
  228. /* Debug Information */
  229. struct dentry *debugfs_root;
  230. /* MISR */
  231. bool misr_enable;
  232. u32 misr_cache;
  233. /* Check for spurious interrupts */
  234. unsigned long jiffies_start;
  235. unsigned int error_interrupt_count;
  236. bool phy_isolation_enabled;
  237. bool null_insertion_enabled;
  238. bool modeupdated;
  239. };
  240. /**
  241. * dsi_ctrl_get() - get a dsi_ctrl handle from an of_node
  242. * @of_node: of_node of the DSI controller.
  243. *
  244. * Gets the DSI controller handle for the corresponding of_node. The ref count
  245. * is incremented to one and all subsequent gets will fail until the original
  246. * clients calls a put.
  247. *
  248. * Return: DSI Controller handle.
  249. */
  250. struct dsi_ctrl *dsi_ctrl_get(struct device_node *of_node);
  251. /**
  252. * dsi_ctrl_put() - releases a dsi controller handle.
  253. * @dsi_ctrl: DSI controller handle.
  254. *
  255. * Releases the DSI controller. Driver will clean up all resources and puts back
  256. * the DSI controller into reset state.
  257. */
  258. void dsi_ctrl_put(struct dsi_ctrl *dsi_ctrl);
  259. /**
  260. * dsi_ctrl_drv_init() - initialize dsi controller driver.
  261. * @dsi_ctrl: DSI controller handle.
  262. * @parent: Parent directory for debug fs.
  263. *
  264. * Initializes DSI controller driver. Driver should be initialized after
  265. * dsi_ctrl_get() succeeds.
  266. *
  267. * Return: error code.
  268. */
  269. int dsi_ctrl_drv_init(struct dsi_ctrl *dsi_ctrl, struct dentry *parent);
  270. /**
  271. * dsi_ctrl_drv_deinit() - de-initializes dsi controller driver
  272. * @dsi_ctrl: DSI controller handle.
  273. *
  274. * Releases all resources acquired by dsi_ctrl_drv_init().
  275. *
  276. * Return: error code.
  277. */
  278. int dsi_ctrl_drv_deinit(struct dsi_ctrl *dsi_ctrl);
  279. /**
  280. * dsi_ctrl_validate_timing() - validate a video timing configuration
  281. * @dsi_ctrl: DSI controller handle.
  282. * @timing: Pointer to timing data.
  283. *
  284. * Driver will validate if the timing configuration is supported on the
  285. * controller hardware.
  286. *
  287. * Return: error code if timing is not supported.
  288. */
  289. int dsi_ctrl_validate_timing(struct dsi_ctrl *dsi_ctrl,
  290. struct dsi_mode_info *timing);
  291. /**
  292. * dsi_ctrl_update_host_config() - update dsi host configuration
  293. * @dsi_ctrl: DSI controller handle.
  294. * @config: DSI host configuration.
  295. * @mode: DSI host mode selected.
  296. * @flags: dsi_mode_flags modifying the behavior
  297. * @clk_handle: Clock handle for DSI clocks
  298. *
  299. * Updates driver with new Host configuration to use for host initialization.
  300. * This function call will only update the software context. The stored
  301. * configuration information will be used when the host is initialized.
  302. *
  303. * Return: error code.
  304. */
  305. int dsi_ctrl_update_host_config(struct dsi_ctrl *dsi_ctrl,
  306. struct dsi_host_config *config,
  307. struct dsi_display_mode *mode, int flags,
  308. void *clk_handle);
  309. /**
  310. * dsi_ctrl_timing_db_update() - update only controller Timing DB
  311. * @dsi_ctrl: DSI controller handle.
  312. * @enable: Enable/disable Timing DB register
  313. *
  314. * Update timing db register value during dfps usecases
  315. *
  316. * Return: error code.
  317. */
  318. int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
  319. bool enable);
  320. /**
  321. * dsi_ctrl_async_timing_update() - update only controller timing
  322. * @dsi_ctrl: DSI controller handle.
  323. * @timing: New DSI timing info
  324. *
  325. * Updates host timing values to asynchronously transition to new timing
  326. * For example, to update the porch values in a seamless/dynamic fps switch.
  327. *
  328. * Return: error code.
  329. */
  330. int dsi_ctrl_async_timing_update(struct dsi_ctrl *dsi_ctrl,
  331. struct dsi_mode_info *timing);
  332. /**
  333. * dsi_ctrl_phy_sw_reset() - perform a PHY software reset
  334. * @dsi_ctrl: DSI controller handle.
  335. *
  336. * Performs a PHY software reset on the DSI controller. Reset should be done
  337. * when the controller power state is DSI_CTRL_POWER_CORE_CLK_ON and the PHY is
  338. * not enabled.
  339. *
  340. * This function will fail if driver is in any other state.
  341. *
  342. * Return: error code.
  343. */
  344. int dsi_ctrl_phy_sw_reset(struct dsi_ctrl *dsi_ctrl);
  345. /**
  346. * dsi_ctrl_phy_reset_config() - Mask/unmask propagation of ahb reset signal
  347. * to DSI PHY hardware.
  348. * @dsi_ctrl: DSI controller handle.
  349. * @enable: Mask/unmask the PHY reset signal.
  350. *
  351. * Return: error code.
  352. */
  353. int dsi_ctrl_phy_reset_config(struct dsi_ctrl *dsi_ctrl, bool enable);
  354. /**
  355. * dsi_ctrl_config_clk_gating() - Enable/Disable DSI PHY clk gating
  356. * @dsi_ctrl: DSI controller handle.
  357. * @enable: Enable/disable DSI PHY clk gating
  358. * @clk_selection: clock selection for gating
  359. *
  360. * Return: error code.
  361. */
  362. int dsi_ctrl_config_clk_gating(struct dsi_ctrl *dsi_ctrl, bool enable,
  363. enum dsi_clk_gate_type clk_selection);
  364. /**
  365. * dsi_ctrl_soft_reset() - perform a soft reset on DSI controller
  366. * @dsi_ctrl: DSI controller handle.
  367. *
  368. * The video, command and controller engines will be disabled before the
  369. * reset is triggered. After, the engines will be re-enabled to the same state
  370. * as before the reset.
  371. *
  372. * If the reset is done while MDP timing engine is turned on, the video
  373. * engine should be re-enabled only during the vertical blanking time.
  374. *
  375. * Return: error code
  376. */
  377. int dsi_ctrl_soft_reset(struct dsi_ctrl *dsi_ctrl);
  378. /**
  379. * dsi_ctrl_host_timing_update - reinitialize host with new timing values
  380. * @dsi_ctrl: DSI controller handle.
  381. *
  382. * Reinitialize DSI controller hardware with new display timing values
  383. * when resolution is switched dynamically.
  384. *
  385. * Return: error code
  386. */
  387. int dsi_ctrl_host_timing_update(struct dsi_ctrl *dsi_ctrl);
  388. /**
  389. * dsi_ctrl_host_init() - Initialize DSI host hardware.
  390. * @dsi_ctrl: DSI controller handle.
  391. * @is_splash_enabled: boolean signifying splash status.
  392. *
  393. * Initializes DSI controller hardware with host configuration provided by
  394. * dsi_ctrl_update_host_config(). Initialization can be performed only during
  395. * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
  396. * performed.
  397. *
  398. * Return: error code.
  399. */
  400. int dsi_ctrl_host_init(struct dsi_ctrl *dsi_ctrl, bool is_splash_enabled);
  401. /**
  402. * dsi_ctrl_host_deinit() - De-Initialize DSI host hardware.
  403. * @dsi_ctrl: DSI controller handle.
  404. *
  405. * De-initializes DSI controller hardware. It can be performed only during
  406. * DSI_CTRL_POWER_CORE_CLK_ON state after LINK clocks have been turned off.
  407. *
  408. * Return: error code.
  409. */
  410. int dsi_ctrl_host_deinit(struct dsi_ctrl *dsi_ctrl);
  411. /**
  412. * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
  413. * @dsi_ctrl: DSI controller handle.
  414. * @enable: enable/disable ULPS.
  415. *
  416. * ULPS can be enabled/disabled after DSI host engine is turned on.
  417. *
  418. * Return: error code.
  419. */
  420. int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
  421. /**
  422. * dsi_ctrl_setup() - Setup DSI host hardware while coming out of idle screen.
  423. * @dsi_ctrl: DSI controller handle.
  424. *
  425. * Initializes DSI controller hardware with host configuration provided by
  426. * dsi_ctrl_update_host_config(). Initialization can be performed only during
  427. * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
  428. * performed.
  429. *
  430. * Also used to program the video mode timing values.
  431. *
  432. * Return: error code.
  433. */
  434. int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl);
  435. /**
  436. * dsi_ctrl_set_roi() - Set DSI controller's region of interest
  437. * @dsi_ctrl: DSI controller handle.
  438. * @roi: Region of interest rectangle, must be less than mode bounds
  439. * @changed: Output parameter, set to true of the controller's ROI was
  440. * dirtied by setting the new ROI, and DCS cmd update needed
  441. *
  442. * Return: error code.
  443. */
  444. int dsi_ctrl_set_roi(struct dsi_ctrl *dsi_ctrl, struct dsi_rect *roi,
  445. bool *changed);
  446. /**
  447. * dsi_ctrl_set_tpg_state() - enable/disable test pattern on the controller
  448. * @dsi_ctrl: DSI controller handle.
  449. * @on: enable/disable test pattern.
  450. *
  451. * Test pattern can be enabled only after Video engine (for video mode panels)
  452. * or command engine (for cmd mode panels) is enabled.
  453. *
  454. * Return: error code.
  455. */
  456. int dsi_ctrl_set_tpg_state(struct dsi_ctrl *dsi_ctrl, bool on);
  457. /**
  458. * dsi_ctrl_cmd_transfer() - Transfer commands on DSI link
  459. * @dsi_ctrl: DSI controller handle.
  460. * @msg: Message to transfer on DSI link.
  461. * @flags: Modifiers for message transfer.
  462. *
  463. * Command transfer can be done only when command engine is enabled. The
  464. * transfer API will until either the command transfer finishes or the timeout
  465. * value is reached. If the trigger is deferred, it will return without
  466. * triggering the transfer. Command parameters are programmed to hardware.
  467. *
  468. * Return: error code.
  469. */
  470. int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
  471. const struct mipi_dsi_msg *msg,
  472. u32 flags);
  473. /**
  474. * dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command.
  475. * @dsi_ctrl: DSI controller handle.
  476. * @flags: Modifiers.
  477. *
  478. * Return: error code.
  479. */
  480. int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags);
  481. /**
  482. * dsi_ctrl_update_host_engine_state_for_cont_splash() - update engine
  483. * states for cont splash usecase
  484. * @dsi_ctrl: DSI controller handle.
  485. * @state: DSI engine state
  486. *
  487. * Return: error code.
  488. */
  489. int dsi_ctrl_update_host_engine_state_for_cont_splash(struct dsi_ctrl *dsi_ctrl,
  490. enum dsi_engine_state state);
  491. /**
  492. * dsi_ctrl_set_power_state() - set power state for dsi controller
  493. * @dsi_ctrl: DSI controller handle.
  494. * @state: Power state.
  495. *
  496. * Set power state for DSI controller. Power state can be changed only when
  497. * Controller, Video and Command engines are turned off.
  498. *
  499. * Return: error code.
  500. */
  501. int dsi_ctrl_set_power_state(struct dsi_ctrl *dsi_ctrl,
  502. enum dsi_power_state state);
  503. /**
  504. * dsi_ctrl_set_cmd_engine_state() - set command engine state
  505. * @dsi_ctrl: DSI Controller handle.
  506. * @state: Engine state.
  507. *
  508. * Command engine state can be modified only when DSI controller power state is
  509. * set to DSI_CTRL_POWER_LINK_CLK_ON.
  510. *
  511. * Return: error code.
  512. */
  513. int dsi_ctrl_set_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
  514. enum dsi_engine_state state);
  515. /**
  516. * dsi_ctrl_validate_host_state() - validate DSI ctrl host state
  517. * @dsi_ctrl: DSI Controller handle.
  518. *
  519. * Validate DSI cotroller host state
  520. *
  521. * Return: boolean indicating whether host is not initialized.
  522. */
  523. bool dsi_ctrl_validate_host_state(struct dsi_ctrl *dsi_ctrl);
  524. /**
  525. * dsi_ctrl_set_vid_engine_state() - set video engine state
  526. * @dsi_ctrl: DSI Controller handle.
  527. * @state: Engine state.
  528. *
  529. * Video engine state can be modified only when DSI controller power state is
  530. * set to DSI_CTRL_POWER_LINK_CLK_ON.
  531. *
  532. * Return: error code.
  533. */
  534. int dsi_ctrl_set_vid_engine_state(struct dsi_ctrl *dsi_ctrl,
  535. enum dsi_engine_state state);
  536. /**
  537. * dsi_ctrl_set_host_engine_state() - set host engine state
  538. * @dsi_ctrl: DSI Controller handle.
  539. * @state: Engine state.
  540. *
  541. * Host engine state can be modified only when DSI controller power state is
  542. * set to DSI_CTRL_POWER_LINK_CLK_ON and cmd, video engines are disabled.
  543. *
  544. * Return: error code.
  545. */
  546. int dsi_ctrl_set_host_engine_state(struct dsi_ctrl *dsi_ctrl,
  547. enum dsi_engine_state state);
  548. /**
  549. * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
  550. * @dsi_ctrl: DSI controller handle.
  551. * @enable: enable/disable ULPS.
  552. *
  553. * ULPS can be enabled/disabled after DSI host engine is turned on.
  554. *
  555. * Return: error code.
  556. */
  557. int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
  558. /**
  559. * dsi_ctrl_clk_cb_register() - Register DSI controller clk control callback
  560. * @dsi_ctrl: DSI controller handle.
  561. * @clk__cb: Structure containing callback for clock control.
  562. *
  563. * Register call for DSI clock control
  564. *
  565. * Return: error code.
  566. */
  567. int dsi_ctrl_clk_cb_register(struct dsi_ctrl *dsi_ctrl,
  568. struct clk_ctrl_cb *clk_cb);
  569. /**
  570. * dsi_ctrl_set_clamp_state() - set clamp state for DSI phy
  571. * @dsi_ctrl: DSI controller handle.
  572. * @enable: enable/disable clamping.
  573. * @ulps_enabled: ulps state.
  574. *
  575. * Clamps can be enabled/disabled while DSI controller is still turned on.
  576. *
  577. * Return: error code.
  578. */
  579. int dsi_ctrl_set_clamp_state(struct dsi_ctrl *dsi_Ctrl,
  580. bool enable, bool ulps_enabled);
  581. /**
  582. * dsi_ctrl_set_clock_source() - set clock source fpr dsi link clocks
  583. * @dsi_ctrl: DSI controller handle.
  584. * @source_clks: Source clocks for DSI link clocks.
  585. *
  586. * Clock source should be changed while link clocks are disabled.
  587. *
  588. * Return: error code.
  589. */
  590. int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl,
  591. struct dsi_clk_link_set *source_clks);
  592. /**
  593. * dsi_ctrl_enable_status_interrupt() - enable status interrupts
  594. * @dsi_ctrl: DSI controller handle.
  595. * @intr_idx: Index interrupt to disable.
  596. * @event_info: Pointer to event callback definition
  597. */
  598. void dsi_ctrl_enable_status_interrupt(struct dsi_ctrl *dsi_ctrl,
  599. uint32_t intr_idx, struct dsi_event_cb_info *event_info);
  600. /**
  601. * dsi_ctrl_disable_status_interrupt() - disable status interrupts
  602. * @dsi_ctrl: DSI controller handle.
  603. * @intr_idx: Index interrupt to disable.
  604. */
  605. void dsi_ctrl_disable_status_interrupt(
  606. struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx);
  607. /**
  608. * dsi_ctrl_setup_misr() - Setup frame MISR
  609. * @dsi_ctrl: DSI controller handle.
  610. * @enable: enable/disable MISR.
  611. * @frame_count: Number of frames to accumulate MISR.
  612. *
  613. * Return: error code.
  614. */
  615. int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
  616. bool enable,
  617. u32 frame_count);
  618. /**
  619. * dsi_ctrl_collect_misr() - Read frame MISR
  620. * @dsi_ctrl: DSI controller handle.
  621. *
  622. * Return: MISR value.
  623. */
  624. u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl);
  625. /**
  626. * dsi_ctrl_cache_misr - Cache frame MISR value
  627. * @dsi_ctrl: DSI controller handle.
  628. */
  629. void dsi_ctrl_cache_misr(struct dsi_ctrl *dsi_ctrl);
  630. /**
  631. * dsi_ctrl_drv_register() - register platform driver for dsi controller
  632. */
  633. void dsi_ctrl_drv_register(void);
  634. /**
  635. * dsi_ctrl_drv_unregister() - unregister platform driver
  636. */
  637. void dsi_ctrl_drv_unregister(void);
  638. /**
  639. * dsi_ctrl_reset() - Reset DSI PHY CLK/DATA lane
  640. * @dsi_ctrl: DSI controller handle.
  641. * @mask: Mask to indicate if CLK and/or DATA lane needs reset.
  642. */
  643. int dsi_ctrl_reset(struct dsi_ctrl *dsi_ctrl, int mask);
  644. /**
  645. * dsi_ctrl_get_hw_version() - read dsi controller hw revision
  646. * @dsi_ctrl: DSI controller handle.
  647. */
  648. int dsi_ctrl_get_hw_version(struct dsi_ctrl *dsi_ctrl);
  649. /**
  650. * dsi_ctrl_vid_engine_en() - Control DSI video engine HW state
  651. * @dsi_ctrl: DSI controller handle.
  652. * @on: variable to control video engine ON/OFF.
  653. */
  654. int dsi_ctrl_vid_engine_en(struct dsi_ctrl *dsi_ctrl, bool on);
  655. /**
  656. * dsi_ctrl_setup_avr() - Set/Clear the AVR_SUPPORT_ENABLE bit
  657. * @dsi_ctrl: DSI controller handle.
  658. * @enable: variable to control AVR support ON/OFF.
  659. */
  660. int dsi_ctrl_setup_avr(struct dsi_ctrl *dsi_ctrl, bool enable);
  661. /**
  662. * @dsi_ctrl: DSI controller handle.
  663. * cmd_len: Length of command.
  664. * flags: Config mode flags.
  665. */
  666. void dsi_message_setup_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
  667. u32 *flags);
  668. /**
  669. * @dsi_ctrl: DSI controller handle.
  670. * cmd_len: Length of command.
  671. * flags: Config mode flags.
  672. */
  673. int dsi_message_validate_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
  674. u32 *flags);
  675. /**
  676. * dsi_ctrl_isr_configure() - API to register/deregister dsi isr
  677. * @dsi_ctrl: DSI controller handle.
  678. * @enable: variable to control register/deregister isr
  679. */
  680. void dsi_ctrl_isr_configure(struct dsi_ctrl *dsi_ctrl, bool enable);
  681. /**
  682. * dsi_ctrl_mask_error_status_interrupts() - API to mask dsi ctrl error status
  683. * interrupts
  684. * @dsi_ctrl: DSI controller handle.
  685. * @idx: id indicating which interrupts to enable/disable.
  686. * @mask_enable: boolean to enable/disable masking.
  687. */
  688. void dsi_ctrl_mask_error_status_interrupts(struct dsi_ctrl *dsi_ctrl, u32 idx,
  689. bool mask_enable);
  690. /**
  691. * dsi_ctrl_irq_update() - Put a irq vote to process DSI error
  692. * interrupts at any time.
  693. * @dsi_ctrl: DSI controller handle.
  694. * @enable: variable to control enable/disable irq line
  695. */
  696. void dsi_ctrl_irq_update(struct dsi_ctrl *dsi_ctrl, bool enable);
  697. /**
  698. * dsi_ctrl_get_host_engine_init_state() - Return host init state
  699. */
  700. int dsi_ctrl_get_host_engine_init_state(struct dsi_ctrl *dsi_ctrl,
  701. bool *state);
  702. /**
  703. * dsi_ctrl_wait_for_cmd_mode_mdp_idle() - Wait for command mode engine not to
  704. * be busy sending data from display engine.
  705. * @dsi_ctrl: DSI controller handle.
  706. */
  707. int dsi_ctrl_wait_for_cmd_mode_mdp_idle(struct dsi_ctrl *dsi_ctrl);
  708. /**
  709. * dsi_ctrl_update_host_init_state() - Set the host initialization state
  710. */
  711. int dsi_ctrl_update_host_init_state(struct dsi_ctrl *dsi_ctrl, bool en);
  712. /**
  713. * dsi_ctrl_pixel_format_to_bpp() - returns number of bits per pxl
  714. */
  715. int dsi_ctrl_pixel_format_to_bpp(enum dsi_pixel_format dst_format);
  716. /**
  717. * dsi_ctrl_set_continuous_clk() - API to set/unset force clock lane HS request.
  718. * @dsi_ctrl: DSI controller handle.
  719. * @enable: variable to control continuous clock.
  720. */
  721. void dsi_ctrl_set_continuous_clk(struct dsi_ctrl *dsi_ctrl, bool enable);
  722. /**
  723. * dsi_ctrl_wait4dynamic_refresh_done() - Poll for dynamic refresh done
  724. * interrupt.
  725. * @dsi_ctrl: DSI controller handle.
  726. */
  727. int dsi_ctrl_wait4dynamic_refresh_done(struct dsi_ctrl *ctrl);
  728. #endif /* _DSI_CTRL_H_ */