dsi_ctrl.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  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. * enum dsi_ctrl_driver_ops - controller driver ops
  71. */
  72. enum dsi_ctrl_driver_ops {
  73. DSI_CTRL_OP_POWER_STATE_CHANGE,
  74. DSI_CTRL_OP_CMD_ENGINE,
  75. DSI_CTRL_OP_VID_ENGINE,
  76. DSI_CTRL_OP_HOST_ENGINE,
  77. DSI_CTRL_OP_CMD_TX,
  78. DSI_CTRL_OP_HOST_INIT,
  79. DSI_CTRL_OP_TPG,
  80. DSI_CTRL_OP_PHY_SW_RESET,
  81. DSI_CTRL_OP_ASYNC_TIMING,
  82. DSI_CTRL_OP_MAX
  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. * struct dsi_ctrl_clk_info - clock information for DSI controller
  98. * @core_clks: Core clocks needed to access DSI controller registers.
  99. * @hs_link_clks: Clocks required to transmit high speed data over DSI
  100. * @lp_link_clks: Clocks required to perform low power ops over DSI
  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_hs_clk_info hs_link_clks;
  115. struct dsi_link_lp_clk_info lp_link_clks;
  116. struct dsi_clk_link_set rcg_clks;
  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. * struct dsi_ctrl_bus_scale_info - Bus scale info for msm-bus bandwidth voting
  125. * @bus_scale_table: Bus scale voting usecases.
  126. * @bus_handle: Handle used for voting bandwidth.
  127. */
  128. struct dsi_ctrl_bus_scale_info {
  129. struct msm_bus_scale_pdata *bus_scale_table;
  130. u32 bus_handle;
  131. };
  132. /**
  133. * struct dsi_ctrl_state_info - current driver state information
  134. * @power_state: Status of power states on DSI controller.
  135. * @cmd_engine_state: Status of DSI command engine.
  136. * @vid_engine_state: Status of DSI video engine.
  137. * @controller_state: Status of DSI Controller engine.
  138. * @host_initialized: Boolean to indicate status of DSi host Initialization
  139. * @tpg_enabled: Boolean to indicate whether tpg is enabled.
  140. */
  141. struct dsi_ctrl_state_info {
  142. enum dsi_power_state power_state;
  143. enum dsi_engine_state cmd_engine_state;
  144. enum dsi_engine_state vid_engine_state;
  145. enum dsi_engine_state controller_state;
  146. bool host_initialized;
  147. bool tpg_enabled;
  148. };
  149. /**
  150. * struct dsi_ctrl_interrupts - define interrupt information
  151. * @irq_lock: Spinlock for ISR handler.
  152. * @irq_num: Linux interrupt number associated with device.
  153. * @irq_stat_mask: Hardware mask of currently enabled interrupts.
  154. * @irq_stat_refcount: Number of times each interrupt has been requested.
  155. * @irq_stat_cb: Status IRQ callback definitions.
  156. * @irq_err_cb: IRQ callback definition to handle DSI ERRORs.
  157. * @cmd_dma_done: Completion signal for DSI_CMD_MODE_DMA_DONE interrupt
  158. * @vid_frame_done: Completion signal for DSI_VIDEO_MODE_FRAME_DONE int.
  159. * @cmd_frame_done: Completion signal for DSI_CMD_FRAME_DONE interrupt.
  160. */
  161. struct dsi_ctrl_interrupts {
  162. spinlock_t irq_lock;
  163. int irq_num;
  164. uint32_t irq_stat_mask;
  165. int irq_stat_refcount[DSI_STATUS_INTERRUPT_COUNT];
  166. struct dsi_event_cb_info irq_stat_cb[DSI_STATUS_INTERRUPT_COUNT];
  167. struct dsi_event_cb_info irq_err_cb;
  168. struct completion cmd_dma_done;
  169. struct completion vid_frame_done;
  170. struct completion cmd_frame_done;
  171. struct completion bta_done;
  172. };
  173. /**
  174. * struct dsi_ctrl - DSI controller object
  175. * @pdev: Pointer to platform device.
  176. * @cell_index: Instance cell id.
  177. * @horiz_index: Index in physical horizontal CTRL layout, 0 = leftmost
  178. * @name: Name of the controller instance.
  179. * @refcount: ref counter.
  180. * @ctrl_lock: Mutex for hardware and object access.
  181. * @drm_dev: Pointer to DRM device.
  182. * @version: DSI controller version.
  183. * @hw: DSI controller hardware object.
  184. * @current_state: Current driver and hardware state.
  185. * @clk_cb: Callback for DSI clock control.
  186. * @irq_info: Interrupt information.
  187. * @recovery_cb: Recovery call back to SDE.
  188. * @clk_info: Clock information.
  189. * @clk_freq: DSi Link clock frequency information.
  190. * @pwr_info: Power information.
  191. * @axi_bus_info: AXI bus information.
  192. * @host_config: Current host configuration.
  193. * @mode_bounds: Boundaries of the default mode ROI.
  194. * Origin is at top left of all CTRLs.
  195. * @roi: Partial update region of interest.
  196. * Origin is top left of this CTRL.
  197. * @tx_cmd_buf: Tx command buffer.
  198. * @cmd_buffer_iova: cmd buffer mapped address.
  199. * @cmd_buffer_size: Size of command buffer.
  200. * @vaddr: CPU virtual address of cmd buffer.
  201. * @secure_mode: Indicates if secure-session is in progress
  202. * @esd_check_underway: Indicates if esd status check is in progress
  203. * @debugfs_root: Root for debugfs entries.
  204. * @misr_enable: Frame MISR enable/disable
  205. * @misr_cache: Cached Frame MISR value
  206. * @frame_threshold_time_us: Frame threshold time in microseconds, where
  207. * dsi data lane will be idle i.e from pingpong done to
  208. * next TE for command mode.
  209. * @phy_isolation_enabled: A boolean property allows to isolate the phy from
  210. * dsi controller and run only dsi controller.
  211. * @null_insertion_enabled: A boolean property to allow dsi controller to
  212. * insert null packet.
  213. * @modeupdated: Boolean to send new roi if mode is updated.
  214. * @split_link_supported: Boolean to check if hw supports split link.
  215. */
  216. struct dsi_ctrl {
  217. struct platform_device *pdev;
  218. u32 cell_index;
  219. u32 horiz_index;
  220. const char *name;
  221. u32 refcount;
  222. struct mutex ctrl_lock;
  223. struct drm_device *drm_dev;
  224. enum dsi_ctrl_version version;
  225. struct dsi_ctrl_hw hw;
  226. /* Current state */
  227. struct dsi_ctrl_state_info current_state;
  228. struct clk_ctrl_cb clk_cb;
  229. struct dsi_ctrl_interrupts irq_info;
  230. struct dsi_event_cb_info recovery_cb;
  231. /* Clock and power states */
  232. struct dsi_ctrl_clk_info clk_info;
  233. struct link_clk_freq clk_freq;
  234. struct dsi_ctrl_power_info pwr_info;
  235. struct dsi_ctrl_bus_scale_info axi_bus_info;
  236. struct dsi_host_config host_config;
  237. struct dsi_rect mode_bounds;
  238. struct dsi_rect roi;
  239. /* Command tx and rx */
  240. struct drm_gem_object *tx_cmd_buf;
  241. u32 cmd_buffer_size;
  242. u32 cmd_buffer_iova;
  243. u32 cmd_len;
  244. void *vaddr;
  245. bool secure_mode;
  246. bool esd_check_underway;
  247. /* Debug Information */
  248. struct dentry *debugfs_root;
  249. /* MISR */
  250. bool misr_enable;
  251. u32 misr_cache;
  252. u32 frame_threshold_time_us;
  253. /* Check for spurious interrupts */
  254. unsigned long jiffies_start;
  255. unsigned int error_interrupt_count;
  256. bool phy_isolation_enabled;
  257. bool null_insertion_enabled;
  258. bool modeupdated;
  259. bool split_link_supported;
  260. };
  261. /**
  262. * dsi_ctrl_get() - get a dsi_ctrl handle from an of_node
  263. * @of_node: of_node of the DSI controller.
  264. *
  265. * Gets the DSI controller handle for the corresponding of_node. The ref count
  266. * is incremented to one and all subsequent gets will fail until the original
  267. * clients calls a put.
  268. *
  269. * Return: DSI Controller handle.
  270. */
  271. struct dsi_ctrl *dsi_ctrl_get(struct device_node *of_node);
  272. /**
  273. * dsi_ctrl_put() - releases a dsi controller handle.
  274. * @dsi_ctrl: DSI controller handle.
  275. *
  276. * Releases the DSI controller. Driver will clean up all resources and puts back
  277. * the DSI controller into reset state.
  278. */
  279. void dsi_ctrl_put(struct dsi_ctrl *dsi_ctrl);
  280. /**
  281. * dsi_ctrl_drv_init() - initialize dsi controller driver.
  282. * @dsi_ctrl: DSI controller handle.
  283. * @parent: Parent directory for debug fs.
  284. *
  285. * Initializes DSI controller driver. Driver should be initialized after
  286. * dsi_ctrl_get() succeeds.
  287. *
  288. * Return: error code.
  289. */
  290. int dsi_ctrl_drv_init(struct dsi_ctrl *dsi_ctrl, struct dentry *parent);
  291. /**
  292. * dsi_ctrl_drv_deinit() - de-initializes dsi controller driver
  293. * @dsi_ctrl: DSI controller handle.
  294. *
  295. * Releases all resources acquired by dsi_ctrl_drv_init().
  296. *
  297. * Return: error code.
  298. */
  299. int dsi_ctrl_drv_deinit(struct dsi_ctrl *dsi_ctrl);
  300. /**
  301. * dsi_ctrl_validate_timing() - validate a video timing configuration
  302. * @dsi_ctrl: DSI controller handle.
  303. * @timing: Pointer to timing data.
  304. *
  305. * Driver will validate if the timing configuration is supported on the
  306. * controller hardware.
  307. *
  308. * Return: error code if timing is not supported.
  309. */
  310. int dsi_ctrl_validate_timing(struct dsi_ctrl *dsi_ctrl,
  311. struct dsi_mode_info *timing);
  312. /**
  313. * dsi_ctrl_update_host_config() - update dsi host configuration
  314. * @dsi_ctrl: DSI controller handle.
  315. * @config: DSI host configuration.
  316. * @mode: DSI host mode selected.
  317. * @flags: dsi_mode_flags modifying the behavior
  318. * @clk_handle: Clock handle for DSI clocks
  319. *
  320. * Updates driver with new Host configuration to use for host initialization.
  321. * This function call will only update the software context. The stored
  322. * configuration information will be used when the host is initialized.
  323. *
  324. * Return: error code.
  325. */
  326. int dsi_ctrl_update_host_config(struct dsi_ctrl *dsi_ctrl,
  327. struct dsi_host_config *config,
  328. struct dsi_display_mode *mode, int flags,
  329. void *clk_handle);
  330. /**
  331. * dsi_ctrl_timing_db_update() - update only controller Timing DB
  332. * @dsi_ctrl: DSI controller handle.
  333. * @enable: Enable/disable Timing DB register
  334. *
  335. * Update timing db register value during dfps usecases
  336. *
  337. * Return: error code.
  338. */
  339. int dsi_ctrl_timing_db_update(struct dsi_ctrl *dsi_ctrl,
  340. bool enable);
  341. /**
  342. * dsi_ctrl_async_timing_update() - update only controller timing
  343. * @dsi_ctrl: DSI controller handle.
  344. * @timing: New DSI timing info
  345. *
  346. * Updates host timing values to asynchronously transition to new timing
  347. * For example, to update the porch values in a seamless/dynamic fps switch.
  348. *
  349. * Return: error code.
  350. */
  351. int dsi_ctrl_async_timing_update(struct dsi_ctrl *dsi_ctrl,
  352. struct dsi_mode_info *timing);
  353. /**
  354. * dsi_ctrl_phy_sw_reset() - perform a PHY software reset
  355. * @dsi_ctrl: DSI controller handle.
  356. *
  357. * Performs a PHY software reset on the DSI controller. Reset should be done
  358. * when the controller power state is DSI_CTRL_POWER_CORE_CLK_ON and the PHY is
  359. * not enabled.
  360. *
  361. * This function will fail if driver is in any other state.
  362. *
  363. * Return: error code.
  364. */
  365. int dsi_ctrl_phy_sw_reset(struct dsi_ctrl *dsi_ctrl);
  366. /**
  367. * dsi_ctrl_phy_reset_config() - Mask/unmask propagation of ahb reset signal
  368. * to DSI PHY hardware.
  369. * @dsi_ctrl: DSI controller handle.
  370. * @enable: Mask/unmask the PHY reset signal.
  371. *
  372. * Return: error code.
  373. */
  374. int dsi_ctrl_phy_reset_config(struct dsi_ctrl *dsi_ctrl, bool enable);
  375. /**
  376. * dsi_ctrl_config_clk_gating() - Enable/Disable DSI PHY clk gating
  377. * @dsi_ctrl: DSI controller handle.
  378. * @enable: Enable/disable DSI PHY clk gating
  379. * @clk_selection: clock selection for gating
  380. *
  381. * Return: error code.
  382. */
  383. int dsi_ctrl_config_clk_gating(struct dsi_ctrl *dsi_ctrl, bool enable,
  384. enum dsi_clk_gate_type clk_selection);
  385. /**
  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. * dsi_ctrl_host_timing_update - reinitialize host with new timing values
  401. * @dsi_ctrl: DSI controller handle.
  402. *
  403. * Reinitialize DSI controller hardware with new display timing values
  404. * when resolution is switched dynamically.
  405. *
  406. * Return: error code
  407. */
  408. int dsi_ctrl_host_timing_update(struct dsi_ctrl *dsi_ctrl);
  409. /**
  410. * dsi_ctrl_host_init() - Initialize DSI host hardware.
  411. * @dsi_ctrl: DSI controller handle.
  412. * @is_splash_enabled: boolean signifying splash status.
  413. *
  414. * Initializes DSI controller hardware with host configuration provided by
  415. * dsi_ctrl_update_host_config(). Initialization can be performed only during
  416. * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
  417. * performed.
  418. *
  419. * Return: error code.
  420. */
  421. int dsi_ctrl_host_init(struct dsi_ctrl *dsi_ctrl, bool is_splash_enabled);
  422. /**
  423. * dsi_ctrl_host_deinit() - De-Initialize DSI host hardware.
  424. * @dsi_ctrl: DSI controller handle.
  425. *
  426. * De-initializes DSI controller hardware. It can be performed only during
  427. * DSI_CTRL_POWER_CORE_CLK_ON state after LINK clocks have been turned off.
  428. *
  429. * Return: error code.
  430. */
  431. int dsi_ctrl_host_deinit(struct dsi_ctrl *dsi_ctrl);
  432. /**
  433. * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
  434. * @dsi_ctrl: DSI controller handle.
  435. * @enable: enable/disable ULPS.
  436. *
  437. * ULPS can be enabled/disabled after DSI host engine is turned on.
  438. *
  439. * Return: error code.
  440. */
  441. int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
  442. /**
  443. * dsi_ctrl_setup() - Setup DSI host hardware while coming out of idle screen.
  444. * @dsi_ctrl: DSI controller handle.
  445. *
  446. * Initializes DSI controller hardware with host configuration provided by
  447. * dsi_ctrl_update_host_config(). Initialization can be performed only during
  448. * DSI_CTRL_POWER_CORE_CLK_ON state and after the PHY SW reset has been
  449. * performed.
  450. *
  451. * Also used to program the video mode timing values.
  452. *
  453. * Return: error code.
  454. */
  455. int dsi_ctrl_setup(struct dsi_ctrl *dsi_ctrl);
  456. /**
  457. * dsi_ctrl_set_roi() - Set DSI controller's region of interest
  458. * @dsi_ctrl: DSI controller handle.
  459. * @roi: Region of interest rectangle, must be less than mode bounds
  460. * @changed: Output parameter, set to true of the controller's ROI was
  461. * dirtied by setting the new ROI, and DCS cmd update needed
  462. *
  463. * Return: error code.
  464. */
  465. int dsi_ctrl_set_roi(struct dsi_ctrl *dsi_ctrl, struct dsi_rect *roi,
  466. bool *changed);
  467. /**
  468. * dsi_ctrl_set_tpg_state() - enable/disable test pattern on the controller
  469. * @dsi_ctrl: DSI controller handle.
  470. * @on: enable/disable test pattern.
  471. *
  472. * Test pattern can be enabled only after Video engine (for video mode panels)
  473. * or command engine (for cmd mode panels) is enabled.
  474. *
  475. * Return: error code.
  476. */
  477. int dsi_ctrl_set_tpg_state(struct dsi_ctrl *dsi_ctrl, bool on);
  478. /**
  479. * dsi_ctrl_cmd_transfer() - Transfer commands on DSI link
  480. * @dsi_ctrl: DSI controller handle.
  481. * @msg: Message to transfer on DSI link.
  482. * @flags: Modifiers for message transfer.
  483. *
  484. * Command transfer can be done only when command engine is enabled. The
  485. * transfer API will until either the command transfer finishes or the timeout
  486. * value is reached. If the trigger is deferred, it will return without
  487. * triggering the transfer. Command parameters are programmed to hardware.
  488. *
  489. * Return: error code.
  490. */
  491. int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
  492. const struct mipi_dsi_msg *msg,
  493. u32 flags);
  494. /**
  495. * dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command.
  496. * @dsi_ctrl: DSI controller handle.
  497. * @flags: Modifiers.
  498. *
  499. * Return: error code.
  500. */
  501. int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags);
  502. /**
  503. * dsi_ctrl_update_host_engine_state_for_cont_splash() - update engine
  504. * states for cont splash usecase
  505. * @dsi_ctrl: DSI controller handle.
  506. * @state: DSI engine state
  507. *
  508. * Return: error code.
  509. */
  510. int dsi_ctrl_update_host_engine_state_for_cont_splash(struct dsi_ctrl *dsi_ctrl,
  511. enum dsi_engine_state state);
  512. /**
  513. * dsi_ctrl_set_power_state() - set power state for dsi controller
  514. * @dsi_ctrl: DSI controller handle.
  515. * @state: Power state.
  516. *
  517. * Set power state for DSI controller. Power state can be changed only when
  518. * Controller, Video and Command engines are turned off.
  519. *
  520. * Return: error code.
  521. */
  522. int dsi_ctrl_set_power_state(struct dsi_ctrl *dsi_ctrl,
  523. enum dsi_power_state state);
  524. /**
  525. * dsi_ctrl_set_cmd_engine_state() - set command engine state
  526. * @dsi_ctrl: DSI Controller handle.
  527. * @state: Engine state.
  528. *
  529. * Command 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_cmd_engine_state(struct dsi_ctrl *dsi_ctrl,
  535. enum dsi_engine_state state);
  536. /**
  537. * dsi_ctrl_validate_host_state() - validate DSI ctrl host state
  538. * @dsi_ctrl: DSI Controller handle.
  539. *
  540. * Validate DSI cotroller host state
  541. *
  542. * Return: boolean indicating whether host is not initialized.
  543. */
  544. bool dsi_ctrl_validate_host_state(struct dsi_ctrl *dsi_ctrl);
  545. /**
  546. * dsi_ctrl_set_vid_engine_state() - set video engine state
  547. * @dsi_ctrl: DSI Controller handle.
  548. * @state: Engine state.
  549. *
  550. * Video engine state can be modified only when DSI controller power state is
  551. * set to DSI_CTRL_POWER_LINK_CLK_ON.
  552. *
  553. * Return: error code.
  554. */
  555. int dsi_ctrl_set_vid_engine_state(struct dsi_ctrl *dsi_ctrl,
  556. enum dsi_engine_state state);
  557. /**
  558. * dsi_ctrl_set_host_engine_state() - set host engine state
  559. * @dsi_ctrl: DSI Controller handle.
  560. * @state: Engine state.
  561. *
  562. * Host engine state can be modified only when DSI controller power state is
  563. * set to DSI_CTRL_POWER_LINK_CLK_ON and cmd, video engines are disabled.
  564. *
  565. * Return: error code.
  566. */
  567. int dsi_ctrl_set_host_engine_state(struct dsi_ctrl *dsi_ctrl,
  568. enum dsi_engine_state state);
  569. /**
  570. * dsi_ctrl_set_ulps() - set ULPS state for DSI lanes.
  571. * @dsi_ctrl: DSI controller handle.
  572. * @enable: enable/disable ULPS.
  573. *
  574. * ULPS can be enabled/disabled after DSI host engine is turned on.
  575. *
  576. * Return: error code.
  577. */
  578. int dsi_ctrl_set_ulps(struct dsi_ctrl *dsi_ctrl, bool enable);
  579. /**
  580. * dsi_ctrl_clk_cb_register() - Register DSI controller clk control callback
  581. * @dsi_ctrl: DSI controller handle.
  582. * @clk__cb: Structure containing callback for clock control.
  583. *
  584. * Register call for DSI clock control
  585. *
  586. * Return: error code.
  587. */
  588. int dsi_ctrl_clk_cb_register(struct dsi_ctrl *dsi_ctrl,
  589. struct clk_ctrl_cb *clk_cb);
  590. /**
  591. * dsi_ctrl_set_clamp_state() - set clamp state for DSI phy
  592. * @dsi_ctrl: DSI controller handle.
  593. * @enable: enable/disable clamping.
  594. * @ulps_enabled: ulps state.
  595. *
  596. * Clamps can be enabled/disabled while DSI controller is still turned on.
  597. *
  598. * Return: error code.
  599. */
  600. int dsi_ctrl_set_clamp_state(struct dsi_ctrl *dsi_Ctrl,
  601. bool enable, bool ulps_enabled);
  602. /**
  603. * dsi_ctrl_set_clock_source() - set clock source fpr dsi link clocks
  604. * @dsi_ctrl: DSI controller handle.
  605. * @source_clks: Source clocks for DSI link clocks.
  606. *
  607. * Clock source should be changed while link clocks are disabled.
  608. *
  609. * Return: error code.
  610. */
  611. int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl,
  612. struct dsi_clk_link_set *source_clks);
  613. /**
  614. * dsi_ctrl_enable_status_interrupt() - enable status interrupts
  615. * @dsi_ctrl: DSI controller handle.
  616. * @intr_idx: Index interrupt to disable.
  617. * @event_info: Pointer to event callback definition
  618. */
  619. void dsi_ctrl_enable_status_interrupt(struct dsi_ctrl *dsi_ctrl,
  620. uint32_t intr_idx, struct dsi_event_cb_info *event_info);
  621. /**
  622. * dsi_ctrl_disable_status_interrupt() - disable status interrupts
  623. * @dsi_ctrl: DSI controller handle.
  624. * @intr_idx: Index interrupt to disable.
  625. */
  626. void dsi_ctrl_disable_status_interrupt(
  627. struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx);
  628. /**
  629. * dsi_ctrl_setup_misr() - Setup frame MISR
  630. * @dsi_ctrl: DSI controller handle.
  631. * @enable: enable/disable MISR.
  632. * @frame_count: Number of frames to accumulate MISR.
  633. *
  634. * Return: error code.
  635. */
  636. int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
  637. bool enable,
  638. u32 frame_count);
  639. /**
  640. * dsi_ctrl_collect_misr() - Read frame MISR
  641. * @dsi_ctrl: DSI controller handle.
  642. *
  643. * Return: MISR value.
  644. */
  645. u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl);
  646. /**
  647. * dsi_ctrl_cache_misr - Cache frame MISR value
  648. * @dsi_ctrl: DSI controller handle.
  649. */
  650. void dsi_ctrl_cache_misr(struct dsi_ctrl *dsi_ctrl);
  651. /**
  652. * dsi_ctrl_drv_register() - register platform driver for dsi controller
  653. */
  654. void dsi_ctrl_drv_register(void);
  655. /**
  656. * dsi_ctrl_drv_unregister() - unregister platform driver
  657. */
  658. void dsi_ctrl_drv_unregister(void);
  659. /**
  660. * dsi_ctrl_reset() - Reset DSI PHY CLK/DATA lane
  661. * @dsi_ctrl: DSI controller handle.
  662. * @mask: Mask to indicate if CLK and/or DATA lane needs reset.
  663. */
  664. int dsi_ctrl_reset(struct dsi_ctrl *dsi_ctrl, int mask);
  665. /**
  666. * dsi_ctrl_get_hw_version() - read dsi controller hw revision
  667. * @dsi_ctrl: DSI controller handle.
  668. */
  669. int dsi_ctrl_get_hw_version(struct dsi_ctrl *dsi_ctrl);
  670. /**
  671. * dsi_ctrl_vid_engine_en() - Control DSI video engine HW state
  672. * @dsi_ctrl: DSI controller handle.
  673. * @on: variable to control video engine ON/OFF.
  674. */
  675. int dsi_ctrl_vid_engine_en(struct dsi_ctrl *dsi_ctrl, bool on);
  676. /**
  677. * dsi_ctrl_setup_avr() - Set/Clear the AVR_SUPPORT_ENABLE bit
  678. * @dsi_ctrl: DSI controller handle.
  679. * @enable: variable to control AVR support ON/OFF.
  680. */
  681. int dsi_ctrl_setup_avr(struct dsi_ctrl *dsi_ctrl, bool enable);
  682. /**
  683. * @dsi_ctrl: DSI controller handle.
  684. * cmd_len: Length of command.
  685. * flags: Config mode flags.
  686. */
  687. void dsi_message_setup_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
  688. u32 *flags);
  689. /**
  690. * @dsi_ctrl: DSI controller handle.
  691. * cmd_len: Length of command.
  692. * flags: Config mode flags.
  693. */
  694. int dsi_message_validate_tx_mode(struct dsi_ctrl *dsi_ctrl, u32 cmd_len,
  695. u32 *flags);
  696. /**
  697. * dsi_ctrl_isr_configure() - API to register/deregister dsi isr
  698. * @dsi_ctrl: DSI controller handle.
  699. * @enable: variable to control register/deregister isr
  700. */
  701. void dsi_ctrl_isr_configure(struct dsi_ctrl *dsi_ctrl, bool enable);
  702. /**
  703. * dsi_ctrl_mask_error_status_interrupts() - API to mask dsi ctrl error status
  704. * interrupts
  705. * @dsi_ctrl: DSI controller handle.
  706. * @idx: id indicating which interrupts to enable/disable.
  707. * @mask_enable: boolean to enable/disable masking.
  708. */
  709. void dsi_ctrl_mask_error_status_interrupts(struct dsi_ctrl *dsi_ctrl, u32 idx,
  710. bool mask_enable);
  711. /**
  712. * dsi_ctrl_irq_update() - Put a irq vote to process DSI error
  713. * interrupts at any time.
  714. * @dsi_ctrl: DSI controller handle.
  715. * @enable: variable to control enable/disable irq line
  716. */
  717. void dsi_ctrl_irq_update(struct dsi_ctrl *dsi_ctrl, bool enable);
  718. /**
  719. * dsi_ctrl_get_host_engine_init_state() - Return host init state
  720. */
  721. int dsi_ctrl_get_host_engine_init_state(struct dsi_ctrl *dsi_ctrl,
  722. bool *state);
  723. /**
  724. * dsi_ctrl_wait_for_cmd_mode_mdp_idle() - Wait for command mode engine not to
  725. * be busy sending data from display engine.
  726. * @dsi_ctrl: DSI controller handle.
  727. */
  728. int dsi_ctrl_wait_for_cmd_mode_mdp_idle(struct dsi_ctrl *dsi_ctrl);
  729. /**
  730. * dsi_ctrl_update_host_state() - Set the host state
  731. */
  732. int dsi_ctrl_update_host_state(struct dsi_ctrl *dsi_ctrl,
  733. enum dsi_ctrl_driver_ops op, bool en);
  734. /**
  735. * dsi_ctrl_pixel_format_to_bpp() - returns number of bits per pxl
  736. */
  737. int dsi_ctrl_pixel_format_to_bpp(enum dsi_pixel_format dst_format);
  738. /**
  739. * dsi_ctrl_hs_req_sel() - API to enable continuous clk support through phy
  740. * @dsi_ctrl: DSI controller handle.
  741. * @sel_phy: Boolean to control whether to select phy or
  742. * controller
  743. */
  744. void dsi_ctrl_hs_req_sel(struct dsi_ctrl *dsi_ctrl, bool sel_phy);
  745. /**
  746. * dsi_ctrl_set_continuous_clk() - API to set/unset force clock lane HS request.
  747. * @dsi_ctrl: DSI controller handle.
  748. * @enable: variable to control continuous clock.
  749. */
  750. void dsi_ctrl_set_continuous_clk(struct dsi_ctrl *dsi_ctrl, bool enable);
  751. /**
  752. * dsi_ctrl_wait4dynamic_refresh_done() - Poll for dynamic refresh done
  753. * interrupt.
  754. * @dsi_ctrl: DSI controller handle.
  755. */
  756. int dsi_ctrl_wait4dynamic_refresh_done(struct dsi_ctrl *ctrl);
  757. #endif /* _DSI_CTRL_H_ */