dsi_ctrl_hw.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DSI_CTRL_HW_H_
  6. #define _DSI_CTRL_HW_H_
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/bitops.h>
  10. #include <linux/bitmap.h>
  11. #include "dsi_defs.h"
  12. /**
  13. * Modifier flag for command transmission. If this flag is set, command
  14. * information is programmed to hardware and transmission is not triggered.
  15. * Caller should call the trigger_command_dma() to start the transmission. This
  16. * flag is valed for kickoff_command() and kickoff_fifo_command() operations.
  17. */
  18. #define DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER 0x1
  19. /**
  20. * enum dsi_ctrl_version - version of the dsi host controller
  21. * @DSI_CTRL_VERSION_UNKNOWN: Unknown controller version
  22. * @DSI_CTRL_VERSION_1_4: DSI host v1.4 controller
  23. * @DSI_CTRL_VERSION_2_0: DSI host v2.0 controller
  24. * @DSI_CTRL_VERSION_2_2: DSI host v2.2 controller
  25. * @DSI_CTRL_VERSION_2_3: DSI host v2.3 controller
  26. * @DSI_CTRL_VERSION_2_4: DSI host v2.4 controller
  27. * @DSI_CTRL_VERSION_MAX: max version
  28. */
  29. enum dsi_ctrl_version {
  30. DSI_CTRL_VERSION_UNKNOWN,
  31. DSI_CTRL_VERSION_1_4,
  32. DSI_CTRL_VERSION_2_0,
  33. DSI_CTRL_VERSION_2_2,
  34. DSI_CTRL_VERSION_2_3,
  35. DSI_CTRL_VERSION_2_4,
  36. DSI_CTRL_VERSION_MAX
  37. };
  38. /**
  39. * enum dsi_ctrl_hw_features - features supported by dsi host controller
  40. * @DSI_CTRL_VIDEO_TPG: Test pattern support for video mode.
  41. * @DSI_CTRL_CMD_TPG: Test pattern support for command mode.
  42. * @DSI_CTRL_VARIABLE_REFRESH_RATE: variable panel timing
  43. * @DSI_CTRL_DYNAMIC_REFRESH: variable pixel clock rate
  44. * @DSI_CTRL_NULL_PACKET_INSERTION: NULL packet insertion
  45. * @DSI_CTRL_DESKEW_CALIB: Deskew calibration support
  46. * @DSI_CTRL_DPHY: Controller support for DPHY
  47. * @DSI_CTRL_CPHY: Controller support for CPHY
  48. * @DSI_CTRL_MAX_FEATURES:
  49. */
  50. enum dsi_ctrl_hw_features {
  51. DSI_CTRL_VIDEO_TPG,
  52. DSI_CTRL_CMD_TPG,
  53. DSI_CTRL_VARIABLE_REFRESH_RATE,
  54. DSI_CTRL_DYNAMIC_REFRESH,
  55. DSI_CTRL_NULL_PACKET_INSERTION,
  56. DSI_CTRL_DESKEW_CALIB,
  57. DSI_CTRL_DPHY,
  58. DSI_CTRL_CPHY,
  59. DSI_CTRL_MAX_FEATURES
  60. };
  61. /**
  62. * enum dsi_test_pattern - test pattern type
  63. * @DSI_TEST_PATTERN_FIXED: Test pattern is fixed, based on init value.
  64. * @DSI_TEST_PATTERN_INC: Incremental test pattern, base on init value.
  65. * @DSI_TEST_PATTERN_POLY: Pattern generated from polynomial and init val.
  66. * @DSI_TEST_PATTERN_MAX:
  67. */
  68. enum dsi_test_pattern {
  69. DSI_TEST_PATTERN_FIXED = 0,
  70. DSI_TEST_PATTERN_INC,
  71. DSI_TEST_PATTERN_POLY,
  72. DSI_TEST_PATTERN_MAX
  73. };
  74. /**
  75. * enum dsi_status_int_index - index of interrupts generated by DSI controller
  76. * @DSI_SINT_CMD_MODE_DMA_DONE: Command mode DMA packets are sent out.
  77. * @DSI_SINT_CMD_STREAM0_FRAME_DONE: A frame of cmd mode stream0 is sent out.
  78. * @DSI_SINT_CMD_STREAM1_FRAME_DONE: A frame of cmd mode stream1 is sent out.
  79. * @DSI_SINT_CMD_STREAM2_FRAME_DONE: A frame of cmd mode stream2 is sent out.
  80. * @DSI_SINT_VIDEO_MODE_FRAME_DONE: A frame of video mode stream is sent out.
  81. * @DSI_SINT_BTA_DONE: A BTA is completed.
  82. * @DSI_SINT_CMD_FRAME_DONE: A frame of selected cmd mode stream is
  83. * sent out by MDP.
  84. * @DSI_SINT_DYN_REFRESH_DONE: The dynamic refresh operation completed.
  85. * @DSI_SINT_DESKEW_DONE: The deskew calibration operation done.
  86. * @DSI_SINT_DYN_BLANK_DMA_DONE: The dynamic blankin DMA operation has
  87. * completed.
  88. * @DSI_SINT_ERROR: DSI error has happened.
  89. */
  90. enum dsi_status_int_index {
  91. DSI_SINT_CMD_MODE_DMA_DONE = 0,
  92. DSI_SINT_CMD_STREAM0_FRAME_DONE = 1,
  93. DSI_SINT_CMD_STREAM1_FRAME_DONE = 2,
  94. DSI_SINT_CMD_STREAM2_FRAME_DONE = 3,
  95. DSI_SINT_VIDEO_MODE_FRAME_DONE = 4,
  96. DSI_SINT_BTA_DONE = 5,
  97. DSI_SINT_CMD_FRAME_DONE = 6,
  98. DSI_SINT_DYN_REFRESH_DONE = 7,
  99. DSI_SINT_DESKEW_DONE = 8,
  100. DSI_SINT_DYN_BLANK_DMA_DONE = 9,
  101. DSI_SINT_ERROR = 10,
  102. DSI_STATUS_INTERRUPT_COUNT
  103. };
  104. /**
  105. * enum dsi_status_int_type - status interrupts generated by DSI controller
  106. * @DSI_CMD_MODE_DMA_DONE: Command mode DMA packets are sent out.
  107. * @DSI_CMD_STREAM0_FRAME_DONE: A frame of command mode stream0 is sent out.
  108. * @DSI_CMD_STREAM1_FRAME_DONE: A frame of command mode stream1 is sent out.
  109. * @DSI_CMD_STREAM2_FRAME_DONE: A frame of command mode stream2 is sent out.
  110. * @DSI_VIDEO_MODE_FRAME_DONE: A frame of video mode stream is sent out.
  111. * @DSI_BTA_DONE: A BTA is completed.
  112. * @DSI_CMD_FRAME_DONE: A frame of selected command mode stream is
  113. * sent out by MDP.
  114. * @DSI_DYN_REFRESH_DONE: The dynamic refresh operation has completed.
  115. * @DSI_DESKEW_DONE: The deskew calibration operation has completed
  116. * @DSI_DYN_BLANK_DMA_DONE: The dynamic blankin DMA operation has
  117. * completed.
  118. * @DSI_ERROR: DSI error has happened.
  119. */
  120. enum dsi_status_int_type {
  121. DSI_CMD_MODE_DMA_DONE = BIT(DSI_SINT_CMD_MODE_DMA_DONE),
  122. DSI_CMD_STREAM0_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM0_FRAME_DONE),
  123. DSI_CMD_STREAM1_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM1_FRAME_DONE),
  124. DSI_CMD_STREAM2_FRAME_DONE = BIT(DSI_SINT_CMD_STREAM2_FRAME_DONE),
  125. DSI_VIDEO_MODE_FRAME_DONE = BIT(DSI_SINT_VIDEO_MODE_FRAME_DONE),
  126. DSI_BTA_DONE = BIT(DSI_SINT_BTA_DONE),
  127. DSI_CMD_FRAME_DONE = BIT(DSI_SINT_CMD_FRAME_DONE),
  128. DSI_DYN_REFRESH_DONE = BIT(DSI_SINT_DYN_REFRESH_DONE),
  129. DSI_DESKEW_DONE = BIT(DSI_SINT_DESKEW_DONE),
  130. DSI_DYN_BLANK_DMA_DONE = BIT(DSI_SINT_DYN_BLANK_DMA_DONE),
  131. DSI_ERROR = BIT(DSI_SINT_ERROR)
  132. };
  133. /**
  134. * enum dsi_error_int_index - index of error interrupts from DSI controller
  135. * @DSI_EINT_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
  136. * @DSI_EINT_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
  137. * @DSI_EINT_RDBK_CRC_ERR: CRC error in read packet.
  138. * @DSI_EINT_RDBK_INCOMPLETE_PKT: Incomplete read packet.
  139. * @DSI_EINT_PERIPH_ERROR_PKT: Error packet returned from peripheral,
  140. * @DSI_EINT_LP_RX_TIMEOUT: Low power reverse transmission timeout.
  141. * @DSI_EINT_HS_TX_TIMEOUT: High speed fwd transmission timeout.
  142. * @DSI_EINT_BTA_TIMEOUT: BTA timeout.
  143. * @DSI_EINT_PLL_UNLOCK: PLL has unlocked.
  144. * @DSI_EINT_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
  145. * @DSI_EINT_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
  146. * @DSI_EINT_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
  147. * @DSI_EINT_PANEL_SPECIFIC_ERR: DSI Protocol violation error.
  148. * @DSI_EINT_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
  149. * @DSI_EINT_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
  150. * @DSI_EINT_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
  151. * receive one complete line from MDP).
  152. * @DSI_EINT_DLN0_HS_FIFO_OVERFLOW: High speed FIFO data lane 0 overflows.
  153. * @DSI_EINT_DLN1_HS_FIFO_OVERFLOW: High speed FIFO data lane 1 overflows.
  154. * @DSI_EINT_DLN2_HS_FIFO_OVERFLOW: High speed FIFO data lane 2 overflows.
  155. * @DSI_EINT_DLN3_HS_FIFO_OVERFLOW: High speed FIFO data lane 3 overflows.
  156. * @DSI_EINT_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO data lane 0 underflows.
  157. * @DSI_EINT_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO data lane 1 underflows.
  158. * @DSI_EINT_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO data lane 2 underflows.
  159. * @DSI_EINT_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO data lane 3 undeflows.
  160. * @DSI_EINT_DLN0_LP0_CONTENTION: PHY level contention while lane 0 low.
  161. * @DSI_EINT_DLN1_LP0_CONTENTION: PHY level contention while lane 1 low.
  162. * @DSI_EINT_DLN2_LP0_CONTENTION: PHY level contention while lane 2 low.
  163. * @DSI_EINT_DLN3_LP0_CONTENTION: PHY level contention while lane 3 low.
  164. * @DSI_EINT_DLN0_LP1_CONTENTION: PHY level contention while lane 0 high.
  165. * @DSI_EINT_DLN1_LP1_CONTENTION: PHY level contention while lane 1 high.
  166. * @DSI_EINT_DLN2_LP1_CONTENTION: PHY level contention while lane 2 high.
  167. * @DSI_EINT_DLN3_LP1_CONTENTION: PHY level contention while lane 3 high.
  168. */
  169. enum dsi_error_int_index {
  170. DSI_EINT_RDBK_SINGLE_ECC_ERR = 0,
  171. DSI_EINT_RDBK_MULTI_ECC_ERR = 1,
  172. DSI_EINT_RDBK_CRC_ERR = 2,
  173. DSI_EINT_RDBK_INCOMPLETE_PKT = 3,
  174. DSI_EINT_PERIPH_ERROR_PKT = 4,
  175. DSI_EINT_LP_RX_TIMEOUT = 5,
  176. DSI_EINT_HS_TX_TIMEOUT = 6,
  177. DSI_EINT_BTA_TIMEOUT = 7,
  178. DSI_EINT_PLL_UNLOCK = 8,
  179. DSI_EINT_DLN0_ESC_ENTRY_ERR = 9,
  180. DSI_EINT_DLN0_ESC_SYNC_ERR = 10,
  181. DSI_EINT_DLN0_LP_CONTROL_ERR = 11,
  182. DSI_EINT_PANEL_SPECIFIC_ERR = 12,
  183. DSI_EINT_INTERLEAVE_OP_CONTENTION = 13,
  184. DSI_EINT_CMD_DMA_FIFO_UNDERFLOW = 14,
  185. DSI_EINT_CMD_MDP_FIFO_UNDERFLOW = 15,
  186. DSI_EINT_DLN0_HS_FIFO_OVERFLOW = 16,
  187. DSI_EINT_DLN1_HS_FIFO_OVERFLOW = 17,
  188. DSI_EINT_DLN2_HS_FIFO_OVERFLOW = 18,
  189. DSI_EINT_DLN3_HS_FIFO_OVERFLOW = 19,
  190. DSI_EINT_DLN0_HS_FIFO_UNDERFLOW = 20,
  191. DSI_EINT_DLN1_HS_FIFO_UNDERFLOW = 21,
  192. DSI_EINT_DLN2_HS_FIFO_UNDERFLOW = 22,
  193. DSI_EINT_DLN3_HS_FIFO_UNDERFLOW = 23,
  194. DSI_EINT_DLN0_LP0_CONTENTION = 24,
  195. DSI_EINT_DLN1_LP0_CONTENTION = 25,
  196. DSI_EINT_DLN2_LP0_CONTENTION = 26,
  197. DSI_EINT_DLN3_LP0_CONTENTION = 27,
  198. DSI_EINT_DLN0_LP1_CONTENTION = 28,
  199. DSI_EINT_DLN1_LP1_CONTENTION = 29,
  200. DSI_EINT_DLN2_LP1_CONTENTION = 30,
  201. DSI_EINT_DLN3_LP1_CONTENTION = 31,
  202. DSI_ERROR_INTERRUPT_COUNT
  203. };
  204. /**
  205. * enum dsi_error_int_type - error interrupts generated by DSI controller
  206. * @DSI_RDBK_SINGLE_ECC_ERR: Single bit ECC error in read packet.
  207. * @DSI_RDBK_MULTI_ECC_ERR: Multi bit ECC error in read packet.
  208. * @DSI_RDBK_CRC_ERR: CRC error in read packet.
  209. * @DSI_RDBK_INCOMPLETE_PKT: Incomplete read packet.
  210. * @DSI_PERIPH_ERROR_PKT: Error packet returned from peripheral,
  211. * @DSI_LP_RX_TIMEOUT: Low power reverse transmission timeout.
  212. * @DSI_HS_TX_TIMEOUT: High speed forward transmission timeout.
  213. * @DSI_BTA_TIMEOUT: BTA timeout.
  214. * @DSI_PLL_UNLOCK: PLL has unlocked.
  215. * @DSI_DLN0_ESC_ENTRY_ERR: Incorrect LP Rx escape entry.
  216. * @DSI_DLN0_ESC_SYNC_ERR: LP Rx data is not byte aligned.
  217. * @DSI_DLN0_LP_CONTROL_ERR: Incorrect LP Rx state sequence.
  218. * @DSI_PANEL_SPECIFIC_ERR: DSI Protocol violation.
  219. * @DSI_INTERLEAVE_OP_CONTENTION: Interleave operation contention.
  220. * @DSI_CMD_DMA_FIFO_UNDERFLOW: Command mode DMA FIFO underflow.
  221. * @DSI_CMD_MDP_FIFO_UNDERFLOW: Command MDP FIFO underflow (failed to
  222. * receive one complete line from MDP).
  223. * @DSI_DLN0_HS_FIFO_OVERFLOW: High speed FIFO for data lane 0 overflows.
  224. * @DSI_DLN1_HS_FIFO_OVERFLOW: High speed FIFO for data lane 1 overflows.
  225. * @DSI_DLN2_HS_FIFO_OVERFLOW: High speed FIFO for data lane 2 overflows.
  226. * @DSI_DLN3_HS_FIFO_OVERFLOW: High speed FIFO for data lane 3 overflows.
  227. * @DSI_DLN0_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 0 underflows.
  228. * @DSI_DLN1_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 1 underflows.
  229. * @DSI_DLN2_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 2 underflows.
  230. * @DSI_DLN3_HS_FIFO_UNDERFLOW: High speed FIFO for data lane 3 undeflows.
  231. * @DSI_DLN0_LP0_CONTENTION: PHY level contention while lane 0 is low.
  232. * @DSI_DLN1_LP0_CONTENTION: PHY level contention while lane 1 is low.
  233. * @DSI_DLN2_LP0_CONTENTION: PHY level contention while lane 2 is low.
  234. * @DSI_DLN3_LP0_CONTENTION: PHY level contention while lane 3 is low.
  235. * @DSI_DLN0_LP1_CONTENTION: PHY level contention while lane 0 is high.
  236. * @DSI_DLN1_LP1_CONTENTION: PHY level contention while lane 1 is high.
  237. * @DSI_DLN2_LP1_CONTENTION: PHY level contention while lane 2 is high.
  238. * @DSI_DLN3_LP1_CONTENTION: PHY level contention while lane 3 is high.
  239. */
  240. enum dsi_error_int_type {
  241. DSI_RDBK_SINGLE_ECC_ERR = BIT(DSI_EINT_RDBK_SINGLE_ECC_ERR),
  242. DSI_RDBK_MULTI_ECC_ERR = BIT(DSI_EINT_RDBK_MULTI_ECC_ERR),
  243. DSI_RDBK_CRC_ERR = BIT(DSI_EINT_RDBK_CRC_ERR),
  244. DSI_RDBK_INCOMPLETE_PKT = BIT(DSI_EINT_RDBK_INCOMPLETE_PKT),
  245. DSI_PERIPH_ERROR_PKT = BIT(DSI_EINT_PERIPH_ERROR_PKT),
  246. DSI_LP_RX_TIMEOUT = BIT(DSI_EINT_LP_RX_TIMEOUT),
  247. DSI_HS_TX_TIMEOUT = BIT(DSI_EINT_HS_TX_TIMEOUT),
  248. DSI_BTA_TIMEOUT = BIT(DSI_EINT_BTA_TIMEOUT),
  249. DSI_PLL_UNLOCK = BIT(DSI_EINT_PLL_UNLOCK),
  250. DSI_DLN0_ESC_ENTRY_ERR = BIT(DSI_EINT_DLN0_ESC_ENTRY_ERR),
  251. DSI_DLN0_ESC_SYNC_ERR = BIT(DSI_EINT_DLN0_ESC_SYNC_ERR),
  252. DSI_DLN0_LP_CONTROL_ERR = BIT(DSI_EINT_DLN0_LP_CONTROL_ERR),
  253. DSI_PANEL_SPECIFIC_ERR = BIT(DSI_EINT_PANEL_SPECIFIC_ERR),
  254. DSI_INTERLEAVE_OP_CONTENTION = BIT(DSI_EINT_INTERLEAVE_OP_CONTENTION),
  255. DSI_CMD_DMA_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_DMA_FIFO_UNDERFLOW),
  256. DSI_CMD_MDP_FIFO_UNDERFLOW = BIT(DSI_EINT_CMD_MDP_FIFO_UNDERFLOW),
  257. DSI_DLN0_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_OVERFLOW),
  258. DSI_DLN1_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_OVERFLOW),
  259. DSI_DLN2_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_OVERFLOW),
  260. DSI_DLN3_HS_FIFO_OVERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_OVERFLOW),
  261. DSI_DLN0_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN0_HS_FIFO_UNDERFLOW),
  262. DSI_DLN1_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN1_HS_FIFO_UNDERFLOW),
  263. DSI_DLN2_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN2_HS_FIFO_UNDERFLOW),
  264. DSI_DLN3_HS_FIFO_UNDERFLOW = BIT(DSI_EINT_DLN3_HS_FIFO_UNDERFLOW),
  265. DSI_DLN0_LP0_CONTENTION = BIT(DSI_EINT_DLN0_LP0_CONTENTION),
  266. DSI_DLN1_LP0_CONTENTION = BIT(DSI_EINT_DLN1_LP0_CONTENTION),
  267. DSI_DLN2_LP0_CONTENTION = BIT(DSI_EINT_DLN2_LP0_CONTENTION),
  268. DSI_DLN3_LP0_CONTENTION = BIT(DSI_EINT_DLN3_LP0_CONTENTION),
  269. DSI_DLN0_LP1_CONTENTION = BIT(DSI_EINT_DLN0_LP1_CONTENTION),
  270. DSI_DLN1_LP1_CONTENTION = BIT(DSI_EINT_DLN1_LP1_CONTENTION),
  271. DSI_DLN2_LP1_CONTENTION = BIT(DSI_EINT_DLN2_LP1_CONTENTION),
  272. DSI_DLN3_LP1_CONTENTION = BIT(DSI_EINT_DLN3_LP1_CONTENTION),
  273. };
  274. /**
  275. * struct dsi_ctrl_cmd_dma_info - command buffer information
  276. * @offset: IOMMU VA for command buffer address.
  277. * @length: Length of the command buffer.
  278. * @datatype: Datatype of cmd.
  279. * @en_broadcast: Enable broadcast mode if set to true.
  280. * @is_master: Is master in broadcast mode.
  281. * @use_lpm: Use low power mode for command transmission.
  282. */
  283. struct dsi_ctrl_cmd_dma_info {
  284. u32 offset;
  285. u32 length;
  286. u8 datatype;
  287. bool en_broadcast;
  288. bool is_master;
  289. bool use_lpm;
  290. };
  291. /**
  292. * struct dsi_ctrl_cmd_dma_fifo_info - command payload tp be sent using FIFO
  293. * @command: VA for command buffer.
  294. * @size: Size of the command buffer.
  295. * @en_broadcast: Enable broadcast mode if set to true.
  296. * @is_master: Is master in broadcast mode.
  297. * @use_lpm: Use low power mode for command transmission.
  298. */
  299. struct dsi_ctrl_cmd_dma_fifo_info {
  300. u32 *command;
  301. u32 size;
  302. bool en_broadcast;
  303. bool is_master;
  304. bool use_lpm;
  305. };
  306. struct dsi_ctrl_hw;
  307. struct ctrl_ulps_config_ops {
  308. /**
  309. * ulps_request() - request ulps entry for specified lanes
  310. * @ctrl: Pointer to the controller host hardware.
  311. * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
  312. * to enter ULPS.
  313. *
  314. * Caller should check if lanes are in ULPS mode by calling
  315. * get_lanes_in_ulps() operation.
  316. */
  317. void (*ulps_request)(struct dsi_ctrl_hw *ctrl, u32 lanes);
  318. /**
  319. * ulps_exit() - exit ULPS on specified lanes
  320. * @ctrl: Pointer to the controller host hardware.
  321. * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
  322. * to exit ULPS.
  323. *
  324. * Caller should check if lanes are in active mode by calling
  325. * get_lanes_in_ulps() operation.
  326. */
  327. void (*ulps_exit)(struct dsi_ctrl_hw *ctrl, u32 lanes);
  328. /**
  329. * get_lanes_in_ulps() - returns the list of lanes in ULPS mode
  330. * @ctrl: Pointer to the controller host hardware.
  331. *
  332. * Returns an ORed list of lanes (enum dsi_data_lanes) that are in ULPS
  333. * state. If 0 is returned, all the lanes are active.
  334. *
  335. * Return: List of lanes in ULPS state.
  336. */
  337. u32 (*get_lanes_in_ulps)(struct dsi_ctrl_hw *ctrl);
  338. };
  339. /**
  340. * struct dsi_ctrl_hw_ops - operations supported by dsi host hardware
  341. */
  342. struct dsi_ctrl_hw_ops {
  343. /**
  344. * host_setup() - Setup DSI host configuration
  345. * @ctrl: Pointer to controller host hardware.
  346. * @config: Configuration for DSI host controller
  347. */
  348. void (*host_setup)(struct dsi_ctrl_hw *ctrl,
  349. struct dsi_host_common_cfg *config);
  350. /**
  351. * video_engine_en() - enable DSI video engine
  352. * @ctrl: Pointer to controller host hardware.
  353. * @on: Enable/disabel video engine.
  354. */
  355. void (*video_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
  356. /**
  357. * setup_avr() - set the AVR_SUPPORT_ENABLE bit in DSI_VIDEO_MODE_CTRL
  358. * @ctrl: Pointer to controller host hardware.
  359. * @enable: Controls whether this bit is set or cleared
  360. */
  361. void (*setup_avr)(struct dsi_ctrl_hw *ctrl, bool enable);
  362. /**
  363. * video_engine_setup() - Setup dsi host controller for video mode
  364. * @ctrl: Pointer to controller host hardware.
  365. * @common_cfg: Common configuration parameters.
  366. * @cfg: Video mode configuration.
  367. *
  368. * Set up DSI video engine with a specific configuration. Controller and
  369. * video engine are not enabled as part of this function.
  370. */
  371. void (*video_engine_setup)(struct dsi_ctrl_hw *ctrl,
  372. struct dsi_host_common_cfg *common_cfg,
  373. struct dsi_video_engine_cfg *cfg);
  374. /**
  375. * set_video_timing() - set up the timing for video frame
  376. * @ctrl: Pointer to controller host hardware.
  377. * @mode: Video mode information.
  378. *
  379. * Set up the video timing parameters for the DSI video mode operation.
  380. */
  381. void (*set_video_timing)(struct dsi_ctrl_hw *ctrl,
  382. struct dsi_mode_info *mode);
  383. /**
  384. * cmd_engine_setup() - setup dsi host controller for command mode
  385. * @ctrl: Pointer to the controller host hardware.
  386. * @common_cfg: Common configuration parameters.
  387. * @cfg: Command mode configuration.
  388. *
  389. * Setup DSI CMD engine with a specific configuration. Controller and
  390. * command engine are not enabled as part of this function.
  391. */
  392. void (*cmd_engine_setup)(struct dsi_ctrl_hw *ctrl,
  393. struct dsi_host_common_cfg *common_cfg,
  394. struct dsi_cmd_engine_cfg *cfg);
  395. /**
  396. * setup_cmd_stream() - set up parameters for command pixel streams
  397. * @ctrl: Pointer to controller host hardware.
  398. * @mode: Pointer to mode information.
  399. * @h_stride: Horizontal stride in bytes.
  400. * @vc_id: stream_id.
  401. *
  402. * Setup parameters for command mode pixel stream size.
  403. */
  404. void (*setup_cmd_stream)(struct dsi_ctrl_hw *ctrl,
  405. struct dsi_mode_info *mode,
  406. u32 h_stride,
  407. u32 vc_id,
  408. struct dsi_rect *roi);
  409. /**
  410. * ctrl_en() - enable DSI controller engine
  411. * @ctrl: Pointer to the controller host hardware.
  412. * @on: turn on/off the DSI controller engine.
  413. */
  414. void (*ctrl_en)(struct dsi_ctrl_hw *ctrl, bool on);
  415. /**
  416. * cmd_engine_en() - enable DSI controller command engine
  417. * @ctrl: Pointer to the controller host hardware.
  418. * @on: Turn on/off the DSI command engine.
  419. */
  420. void (*cmd_engine_en)(struct dsi_ctrl_hw *ctrl, bool on);
  421. /**
  422. * phy_sw_reset() - perform a soft reset on the PHY.
  423. * @ctrl: Pointer to the controller host hardware.
  424. */
  425. void (*phy_sw_reset)(struct dsi_ctrl_hw *ctrl);
  426. /**
  427. * config_clk_gating() - enable/disable DSI PHY clk gating
  428. * @ctrl: Pointer to the controller host hardware.
  429. * @enable: enable/disable DSI PHY clock gating.
  430. * @clk_selection: clock to enable/disable clock gating.
  431. */
  432. void (*config_clk_gating)(struct dsi_ctrl_hw *ctrl, bool enable,
  433. enum dsi_clk_gate_type clk_selection);
  434. /**
  435. * debug_bus() - get dsi debug bus status.
  436. * @ctrl: Pointer to the controller host hardware.
  437. * @entries: Array of dsi debug bus control values.
  438. * @size: Size of dsi debug bus control array.
  439. */
  440. void (*debug_bus)(struct dsi_ctrl_hw *ctrl, u32 *entries, u32 size);
  441. /**
  442. * soft_reset() - perform a soft reset on DSI controller
  443. * @ctrl: Pointer to the controller host hardware.
  444. *
  445. * The video, command and controller engines will be disabled before the
  446. * reset is triggered. After, the engines will be re-enabled to the same
  447. * state as before the reset.
  448. *
  449. * If the reset is done while MDP timing engine is turned on, the video
  450. * engine should be re-enabled only during the vertical blanking time.
  451. */
  452. void (*soft_reset)(struct dsi_ctrl_hw *ctrl);
  453. /**
  454. * setup_lane_map() - setup mapping between logical and physical lanes
  455. * @ctrl: Pointer to the controller host hardware.
  456. * @lane_map: Structure defining the mapping between DSI logical
  457. * lanes and physical lanes.
  458. */
  459. void (*setup_lane_map)(struct dsi_ctrl_hw *ctrl,
  460. struct dsi_lane_map *lane_map);
  461. /**
  462. * kickoff_command() - transmits commands stored in memory
  463. * @ctrl: Pointer to the controller host hardware.
  464. * @cmd: Command information.
  465. * @flags: Modifiers for command transmission.
  466. *
  467. * The controller hardware is programmed with address and size of the
  468. * command buffer. The transmission is kicked off if
  469. * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
  470. * set, caller should make a separate call to trigger_command_dma() to
  471. * transmit the command.
  472. */
  473. void (*kickoff_command)(struct dsi_ctrl_hw *ctrl,
  474. struct dsi_ctrl_cmd_dma_info *cmd,
  475. u32 flags);
  476. /**
  477. * kickoff_command_non_embedded_mode() - cmd in non embedded mode
  478. * @ctrl: Pointer to the controller host hardware.
  479. * @cmd: Command information.
  480. * @flags: Modifiers for command transmission.
  481. *
  482. * If command length is greater than DMA FIFO size of 256 bytes we use
  483. * this non- embedded mode.
  484. * The controller hardware is programmed with address and size of the
  485. * command buffer. The transmission is kicked off if
  486. * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
  487. * set, caller should make a separate call to trigger_command_dma() to
  488. * transmit the command.
  489. */
  490. void (*kickoff_command_non_embedded_mode)(struct dsi_ctrl_hw *ctrl,
  491. struct dsi_ctrl_cmd_dma_info *cmd,
  492. u32 flags);
  493. /**
  494. * kickoff_fifo_command() - transmits a command using FIFO in dsi
  495. * hardware.
  496. * @ctrl: Pointer to the controller host hardware.
  497. * @cmd: Command information.
  498. * @flags: Modifiers for command transmission.
  499. *
  500. * The controller hardware FIFO is programmed with command header and
  501. * payload. The transmission is kicked off if
  502. * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag is not set. If this flag is
  503. * set, caller should make a separate call to trigger_command_dma() to
  504. * transmit the command.
  505. */
  506. void (*kickoff_fifo_command)(struct dsi_ctrl_hw *ctrl,
  507. struct dsi_ctrl_cmd_dma_fifo_info *cmd,
  508. u32 flags);
  509. void (*reset_cmd_fifo)(struct dsi_ctrl_hw *ctrl);
  510. /**
  511. * trigger_command_dma() - trigger transmission of command buffer.
  512. * @ctrl: Pointer to the controller host hardware.
  513. *
  514. * This trigger can be only used if there was a prior call to
  515. * kickoff_command() of kickoff_fifo_command() with
  516. * DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER flag.
  517. */
  518. void (*trigger_command_dma)(struct dsi_ctrl_hw *ctrl);
  519. /**
  520. * get_cmd_read_data() - get data read from the peripheral
  521. * @ctrl: Pointer to the controller host hardware.
  522. * @rd_buf: Buffer where data will be read into.
  523. * @read_offset: Offset from where to read.
  524. * @rx_byte: Number of bytes to be read.
  525. * @pkt_size: Size of response expected.
  526. * @hw_read_cnt: Actual number of bytes read by HW.
  527. */
  528. u32 (*get_cmd_read_data)(struct dsi_ctrl_hw *ctrl,
  529. u8 *rd_buf,
  530. u32 read_offset,
  531. u32 rx_byte,
  532. u32 pkt_size,
  533. u32 *hw_read_cnt);
  534. /**
  535. * wait_for_lane_idle() - wait for DSI lanes to go to idle state
  536. * @ctrl: Pointer to the controller host hardware.
  537. * @lanes: ORed list of lanes (enum dsi_data_lanes) which need
  538. * to be checked to be in idle state.
  539. */
  540. int (*wait_for_lane_idle)(struct dsi_ctrl_hw *ctrl, u32 lanes);
  541. struct ctrl_ulps_config_ops ulps_ops;
  542. /**
  543. * clamp_enable() - enable DSI clamps
  544. * @ctrl: Pointer to the controller host hardware.
  545. * @lanes: ORed list of lanes which need to have clamps released.
  546. * @enable_ulps: ulps state.
  547. */
  548. /**
  549. * clamp_enable() - enable DSI clamps to keep PHY driving a stable link
  550. * @ctrl: Pointer to the controller host hardware.
  551. * @lanes: ORed list of lanes which need to have clamps released.
  552. * @enable_ulps: TODO:??
  553. */
  554. void (*clamp_enable)(struct dsi_ctrl_hw *ctrl,
  555. u32 lanes,
  556. bool enable_ulps);
  557. /**
  558. * clamp_disable() - disable DSI clamps
  559. * @ctrl: Pointer to the controller host hardware.
  560. * @lanes: ORed list of lanes which need to have clamps released.
  561. * @disable_ulps: ulps state.
  562. */
  563. void (*clamp_disable)(struct dsi_ctrl_hw *ctrl,
  564. u32 lanes,
  565. bool disable_ulps);
  566. /**
  567. * phy_reset_config() - Disable/enable propagation of reset signal
  568. * from ahb domain to DSI PHY
  569. * @ctrl: Pointer to the controller host hardware.
  570. * @enable: True to mask the reset signal, false to unmask
  571. */
  572. void (*phy_reset_config)(struct dsi_ctrl_hw *ctrl,
  573. bool enable);
  574. /**
  575. * get_interrupt_status() - returns the interrupt status
  576. * @ctrl: Pointer to the controller host hardware.
  577. *
  578. * Returns the ORed list of interrupts(enum dsi_status_int_type) that
  579. * are active. This list does not include any error interrupts. Caller
  580. * should call get_error_status for error interrupts.
  581. *
  582. * Return: List of active interrupts.
  583. */
  584. u32 (*get_interrupt_status)(struct dsi_ctrl_hw *ctrl);
  585. /**
  586. * clear_interrupt_status() - clears the specified interrupts
  587. * @ctrl: Pointer to the controller host hardware.
  588. * @ints: List of interrupts to be cleared.
  589. */
  590. void (*clear_interrupt_status)(struct dsi_ctrl_hw *ctrl, u32 ints);
  591. /**
  592. * enable_status_interrupts() - enable the specified interrupts
  593. * @ctrl: Pointer to the controller host hardware.
  594. * @ints: List of interrupts to be enabled.
  595. *
  596. * Enables the specified interrupts. This list will override the
  597. * previous interrupts enabled through this function. Caller has to
  598. * maintain the state of the interrupts enabled. To disable all
  599. * interrupts, set ints to 0.
  600. */
  601. void (*enable_status_interrupts)(struct dsi_ctrl_hw *ctrl, u32 ints);
  602. /**
  603. * get_error_status() - returns the error status
  604. * @ctrl: Pointer to the controller host hardware.
  605. *
  606. * Returns the ORed list of errors(enum dsi_error_int_type) that are
  607. * active. This list does not include any status interrupts. Caller
  608. * should call get_interrupt_status for status interrupts.
  609. *
  610. * Return: List of active error interrupts.
  611. */
  612. u64 (*get_error_status)(struct dsi_ctrl_hw *ctrl);
  613. /**
  614. * clear_error_status() - clears the specified errors
  615. * @ctrl: Pointer to the controller host hardware.
  616. * @errors: List of errors to be cleared.
  617. */
  618. void (*clear_error_status)(struct dsi_ctrl_hw *ctrl, u64 errors);
  619. /**
  620. * enable_error_interrupts() - enable the specified interrupts
  621. * @ctrl: Pointer to the controller host hardware.
  622. * @errors: List of errors to be enabled.
  623. *
  624. * Enables the specified interrupts. This list will override the
  625. * previous interrupts enabled through this function. Caller has to
  626. * maintain the state of the interrupts enabled. To disable all
  627. * interrupts, set errors to 0.
  628. */
  629. void (*enable_error_interrupts)(struct dsi_ctrl_hw *ctrl, u64 errors);
  630. /**
  631. * video_test_pattern_setup() - setup test pattern engine for video mode
  632. * @ctrl: Pointer to the controller host hardware.
  633. * @type: Type of test pattern.
  634. * @init_val: Initial value to use for generating test pattern.
  635. */
  636. void (*video_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
  637. enum dsi_test_pattern type,
  638. u32 init_val);
  639. /**
  640. * cmd_test_pattern_setup() - setup test patttern engine for cmd mode
  641. * @ctrl: Pointer to the controller host hardware.
  642. * @type: Type of test pattern.
  643. * @init_val: Initial value to use for generating test pattern.
  644. * @stream_id: Stream Id on which packets are generated.
  645. */
  646. void (*cmd_test_pattern_setup)(struct dsi_ctrl_hw *ctrl,
  647. enum dsi_test_pattern type,
  648. u32 init_val,
  649. u32 stream_id);
  650. /**
  651. * test_pattern_enable() - enable test pattern engine
  652. * @ctrl: Pointer to the controller host hardware.
  653. * @enable: Enable/Disable test pattern engine.
  654. */
  655. void (*test_pattern_enable)(struct dsi_ctrl_hw *ctrl, bool enable);
  656. /**
  657. * clear_phy0_ln_err() - clear DSI PHY lane-0 errors
  658. * @ctrl: Pointer to the controller host hardware.
  659. */
  660. void (*clear_phy0_ln_err)(struct dsi_ctrl_hw *ctrl);
  661. /**
  662. * trigger_cmd_test_pattern() - trigger a command mode frame update with
  663. * test pattern
  664. * @ctrl: Pointer to the controller host hardware.
  665. * @stream_id: Stream on which frame update is sent.
  666. */
  667. void (*trigger_cmd_test_pattern)(struct dsi_ctrl_hw *ctrl,
  668. u32 stream_id);
  669. ssize_t (*reg_dump_to_buffer)(struct dsi_ctrl_hw *ctrl,
  670. char *buf,
  671. u32 size);
  672. /**
  673. * setup_misr() - Setup frame MISR
  674. * @ctrl: Pointer to the controller host hardware.
  675. * @panel_mode: CMD or VIDEO mode indicator
  676. * @enable: Enable/disable MISR.
  677. * @frame_count: Number of frames to accumulate MISR.
  678. */
  679. void (*setup_misr)(struct dsi_ctrl_hw *ctrl,
  680. enum dsi_op_mode panel_mode,
  681. bool enable, u32 frame_count);
  682. /**
  683. * collect_misr() - Read frame MISR
  684. * @ctrl: Pointer to the controller host hardware.
  685. * @panel_mode: CMD or VIDEO mode indicator
  686. */
  687. u32 (*collect_misr)(struct dsi_ctrl_hw *ctrl,
  688. enum dsi_op_mode panel_mode);
  689. /**
  690. * set_timing_db() - enable/disable Timing DB register
  691. * @ctrl: Pointer to controller host hardware.
  692. * @enable: Enable/Disable flag.
  693. *
  694. * Enable or Disabe the Timing DB register.
  695. */
  696. void (*set_timing_db)(struct dsi_ctrl_hw *ctrl,
  697. bool enable);
  698. /**
  699. * clear_rdbk_register() - Clear and reset read back register
  700. * @ctrl: Pointer to the controller host hardware.
  701. */
  702. void (*clear_rdbk_register)(struct dsi_ctrl_hw *ctrl);
  703. /** schedule_dma_cmd() - Schdeule DMA command transfer on a
  704. * particular blanking line.
  705. * @ctrl: Pointer to the controller host hardware.
  706. * @line_no: Blanking line number on whihch DMA command
  707. * needs to be sent.
  708. */
  709. void (*schedule_dma_cmd)(struct dsi_ctrl_hw *ctrl, int line_no);
  710. /**
  711. * ctrl_reset() - Reset DSI lanes to recover from DSI errors
  712. * @ctrl: Pointer to the controller host hardware.
  713. * @mask: Indicates the error type.
  714. */
  715. int (*ctrl_reset)(struct dsi_ctrl_hw *ctrl, int mask);
  716. /**
  717. * mask_error_int() - Mask/Unmask particular DSI error interrupts
  718. * @ctrl: Pointer to the controller host hardware.
  719. * @idx: Indicates the errors to be masked.
  720. * @en: Bool for mask or unmask of the error
  721. */
  722. void (*mask_error_intr)(struct dsi_ctrl_hw *ctrl, u32 idx, bool en);
  723. /**
  724. * error_intr_ctrl() - Mask/Unmask master DSI error interrupt
  725. * @ctrl: Pointer to the controller host hardware.
  726. * @en: Bool for mask or unmask of DSI error
  727. */
  728. void (*error_intr_ctrl)(struct dsi_ctrl_hw *ctrl, bool en);
  729. /**
  730. * get_error_mask() - get DSI error interrupt mask status
  731. * @ctrl: Pointer to the controller host hardware.
  732. */
  733. u32 (*get_error_mask)(struct dsi_ctrl_hw *ctrl);
  734. /**
  735. * get_hw_version() - get DSI controller hw version
  736. * @ctrl: Pointer to the controller host hardware.
  737. */
  738. u32 (*get_hw_version)(struct dsi_ctrl_hw *ctrl);
  739. /**
  740. * wait_for_cmd_mode_mdp_idle() - wait for command mode engine not to
  741. * be busy sending data from display engine
  742. * @ctrl: Pointer to the controller host hardware.
  743. */
  744. int (*wait_for_cmd_mode_mdp_idle)(struct dsi_ctrl_hw *ctrl);
  745. /**
  746. * hw.ops.set_continuous_clk() - Set continuous clock
  747. * @ctrl: Pointer to the controller host hardware.
  748. * @enable: Bool to control continuous clock request.
  749. */
  750. void (*set_continuous_clk)(struct dsi_ctrl_hw *ctrl, bool enable);
  751. };
  752. /*
  753. * struct dsi_ctrl_hw - DSI controller hardware object specific to an instance
  754. * @base: VA for the DSI controller base address.
  755. * @length: Length of the DSI controller register map.
  756. * @mmss_misc_base: Base address of mmss_misc register map.
  757. * @mmss_misc_length: Length of mmss_misc register map.
  758. * @disp_cc_base: Base address of disp_cc register map.
  759. * @disp_cc_length: Length of disp_cc register map.
  760. * @index: Instance ID of the controller.
  761. * @feature_map: Features supported by the DSI controller.
  762. * @ops: Function pointers to the operations supported by the
  763. * controller.
  764. * @supported_interrupts: Number of supported interrupts.
  765. * @supported_errors: Number of supported errors.
  766. * @phy_isolation_enabled: A boolean property allows to isolate the phy from
  767. * dsi controller and run only dsi controller.
  768. * @null_insertion_enabled: A boolean property to allow dsi controller to
  769. * insert null packet.
  770. */
  771. struct dsi_ctrl_hw {
  772. void __iomem *base;
  773. u32 length;
  774. void __iomem *mmss_misc_base;
  775. u32 mmss_misc_length;
  776. void __iomem *disp_cc_base;
  777. u32 disp_cc_length;
  778. u32 index;
  779. /* features */
  780. DECLARE_BITMAP(feature_map, DSI_CTRL_MAX_FEATURES);
  781. struct dsi_ctrl_hw_ops ops;
  782. /* capabilities */
  783. u32 supported_interrupts;
  784. u64 supported_errors;
  785. bool phy_isolation_enabled;
  786. bool null_insertion_enabled;
  787. };
  788. #endif /* _DSI_CTRL_HW_H_ */