dsi_ctrl.h 33 KB

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