dsi_ctrl.h 31 KB

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