dsi_ctrl.h 32 KB

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