dsi_ctrl.h 29 KB

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