dsi_ctrl.h 29 KB

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