sde_hw_interrupts.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _SDE_HW_INTERRUPTS_H
  7. #define _SDE_HW_INTERRUPTS_H
  8. #include <linux/types.h>
  9. #include "sde_hwio.h"
  10. #include "sde_hw_catalog.h"
  11. #include "sde_hw_util.h"
  12. #include "sde_hw_mdss.h"
  13. #define IRQ_SOURCE_MDP BIT(0)
  14. #define IRQ_SOURCE_DSI0 BIT(4)
  15. #define IRQ_SOURCE_DSI1 BIT(5)
  16. #define IRQ_SOURCE_HDMI BIT(8)
  17. #define IRQ_SOURCE_EDP BIT(12)
  18. #define IRQ_SOURCE_MHL BIT(16)
  19. /**
  20. * sde_intr_type - HW Interrupt Type
  21. * @SDE_IRQ_TYPE_WB_ROT_COMP: WB rotator done
  22. * @SDE_IRQ_TYPE_WB_WFD_COMP: WB WFD done
  23. * @SDE_IRQ_TYPE_PING_PONG_COMP: PingPong done
  24. * @SDE_IRQ_TYPE_PING_PONG_RD_PTR: PingPong read pointer
  25. * @SDE_IRQ_TYPE_PING_PONG_WR_PTR: PingPong write pointer
  26. * @SDE_IRQ_TYPE_PING_PONG_AUTO_REF: PingPong auto refresh
  27. * @SDE_IRQ_TYPE_PING_PONG_TEAR_CHECK: PingPong Tear check
  28. * @SDE_IRQ_TYPE_PING_PONG_TE_CHECK: PingPong TE detection
  29. * @SDE_IRQ_TYPE_INTF_UNDER_RUN: INTF underrun
  30. * @SDE_IRQ_TYPE_INTF_VSYNC: INTF VSYNC
  31. * @SDE_IRQ_TYPE_CWB_OVERFLOW: Concurrent WB overflow
  32. * @SDE_IRQ_TYPE_HIST_VIG_DONE: VIG Histogram done
  33. * @SDE_IRQ_TYPE_HIST_VIG_RSTSEQ: VIG Histogram reset
  34. * @SDE_IRQ_TYPE_HIST_DSPP_DONE: DSPP Histogram done
  35. * @SDE_IRQ_TYPE_HIST_DSPP_RSTSEQ: DSPP Histogram reset
  36. * @SDE_IRQ_TYPE_WD_TIMER: Watchdog timer
  37. * @SDE_IRQ_TYPE_SFI_VIDEO_IN: Video static frame INTR into static
  38. * @SDE_IRQ_TYPE_SFI_VIDEO_OUT: Video static frame INTR out-of static
  39. * @SDE_IRQ_TYPE_SFI_CMD_0_IN: DSI CMD0 static frame INTR into static
  40. * @SDE_IRQ_TYPE_SFI_CMD_0_OUT: DSI CMD0 static frame INTR out-of static
  41. * @SDE_IRQ_TYPE_SFI_CMD_1_IN: DSI CMD1 static frame INTR into static
  42. * @SDE_IRQ_TYPE_SFI_CMD_1_OUT: DSI CMD1 static frame INTR out-of static
  43. * @SDE_IRQ_TYPE_SFI_CMD_2_IN: DSI CMD2 static frame INTR into static
  44. * @SDE_IRQ_TYPE_SFI_CMD_2_OUT: DSI CMD2 static frame INTR out-of static
  45. * @SDE_IRQ_TYPE_PROG_LINE: Programmable Line interrupt
  46. * @SDE_IRQ_TYPE_AD4_BL_DONE: AD4 backlight
  47. * @SDE_IRQ_TYPE_CTL_START: Control start
  48. * @SDE_IRQ_TYPE_CTL_DONE: Frame transfer complete
  49. * @SDE_IRQ_TYPE_INTF_TEAR_RD_PTR: INTF Tear read pointer
  50. * @SDE_IRQ_TYPE_INTF_TEAR_WR_PTR: INTF Tear write pointer
  51. * @SDE_IRQ_TYPE_INTF_TEAR_AUTO_REF: INTF Tear auto refresh
  52. * @SDE_IRQ_TYPE_INTF_TEAR_TEAR_DETECT: INTF Tear Tear detection
  53. * @SDE_IRQ_TYPE_INTF_TEAR_TE_ASSERT: INTF Tear TE Assert detection
  54. * @SDE_IRQ_TYPE_INTF_TEAR_TE_DEASSERT: INTF Tear TE Deassert detection
  55. * @SDE_IRQ_TYPE_LTM_STATS_DONE: LTM stats done interrupt
  56. * @SDE_IRQ_TYPE_LTM_STATS_WB_PB: LTM stats WB push back interrupt
  57. * @SDE_IRQ_TYPE_PROG_LINE: Programmable Line interrupt for WB
  58. * @SDE_IRQ_TYPE_RESERVED: Reserved for expansion
  59. */
  60. enum sde_intr_type {
  61. SDE_IRQ_TYPE_WB_ROT_COMP,
  62. SDE_IRQ_TYPE_WB_WFD_COMP,
  63. SDE_IRQ_TYPE_PING_PONG_COMP,
  64. SDE_IRQ_TYPE_PING_PONG_RD_PTR,
  65. SDE_IRQ_TYPE_PING_PONG_WR_PTR,
  66. SDE_IRQ_TYPE_PING_PONG_AUTO_REF,
  67. SDE_IRQ_TYPE_PING_PONG_TEAR_CHECK,
  68. SDE_IRQ_TYPE_PING_PONG_TE_CHECK,
  69. SDE_IRQ_TYPE_INTF_UNDER_RUN,
  70. SDE_IRQ_TYPE_INTF_VSYNC,
  71. SDE_IRQ_TYPE_CWB_OVERFLOW,
  72. SDE_IRQ_TYPE_HIST_VIG_DONE,
  73. SDE_IRQ_TYPE_HIST_VIG_RSTSEQ,
  74. SDE_IRQ_TYPE_HIST_DSPP_DONE,
  75. SDE_IRQ_TYPE_HIST_DSPP_RSTSEQ,
  76. SDE_IRQ_TYPE_WD_TIMER,
  77. SDE_IRQ_TYPE_SFI_VIDEO_IN,
  78. SDE_IRQ_TYPE_SFI_VIDEO_OUT,
  79. SDE_IRQ_TYPE_SFI_CMD_0_IN,
  80. SDE_IRQ_TYPE_SFI_CMD_0_OUT,
  81. SDE_IRQ_TYPE_SFI_CMD_1_IN,
  82. SDE_IRQ_TYPE_SFI_CMD_1_OUT,
  83. SDE_IRQ_TYPE_SFI_CMD_2_IN,
  84. SDE_IRQ_TYPE_SFI_CMD_2_OUT,
  85. SDE_IRQ_TYPE_PROG_LINE,
  86. SDE_IRQ_TYPE_AD4_BL_DONE,
  87. SDE_IRQ_TYPE_CTL_START,
  88. SDE_IRQ_TYPE_CTL_DONE,
  89. SDE_IRQ_TYPE_INTF_TEAR_RD_PTR,
  90. SDE_IRQ_TYPE_INTF_TEAR_WR_PTR,
  91. SDE_IRQ_TYPE_INTF_TEAR_AUTO_REF,
  92. SDE_IRQ_TYPE_INTF_TEAR_TEAR_DETECT,
  93. SDE_IRQ_TYPE_INTF_TEAR_TE_ASSERT,
  94. SDE_IRQ_TYPE_INTF_TEAR_TE_DEASSERT,
  95. SDE_IRQ_TYPE_LTM_STATS_DONE,
  96. SDE_IRQ_TYPE_LTM_STATS_WB_PB,
  97. SDE_IRQ_TYPE_WB_PROG_LINE,
  98. SDE_IRQ_TYPE_RESERVED,
  99. };
  100. struct sde_hw_intr;
  101. /**
  102. * Interrupt operations.
  103. */
  104. struct sde_hw_intr_ops {
  105. /**
  106. * irq_idx_lookup - Lookup IRQ index on the HW interrupt type
  107. * Used for all irq related ops
  108. * @intr: HW interrupt handle
  109. * @intr_type: Interrupt type defined in sde_intr_type
  110. * @instance_idx: HW interrupt block instance
  111. * @return: irq_idx or -EINVAL for lookup fail
  112. */
  113. int (*irq_idx_lookup)(
  114. struct sde_hw_intr *intr,
  115. enum sde_intr_type intr_type,
  116. u32 instance_idx);
  117. /**
  118. * enable_irq_nolock - Enable IRQ based on lookup IRQ index without lock
  119. * @intr: HW interrupt handle
  120. * @irq_idx: Lookup irq index return from irq_idx_lookup
  121. * @return: 0 for success, otherwise failure
  122. */
  123. int (*enable_irq_nolock)(
  124. struct sde_hw_intr *intr,
  125. int irq_idx);
  126. /**
  127. * disable_irq_nolock - Disable IRQ based on IRQ index without lock
  128. * @intr: HW interrupt handle
  129. * @irq_idx: Lookup irq index return from irq_idx_lookup
  130. * @return: 0 for success, otherwise failure
  131. */
  132. int (*disable_irq_nolock)(
  133. struct sde_hw_intr *intr,
  134. int irq_idx);
  135. /**
  136. * clear_all_irqs - Clears all the interrupts (i.e. acknowledges
  137. * any asserted IRQs). Useful during reset.
  138. * @intr: HW interrupt handle
  139. * @return: 0 for success, otherwise failure
  140. */
  141. int (*clear_all_irqs)(
  142. struct sde_hw_intr *intr);
  143. /**
  144. * disable_all_irqs - Disables all the interrupts. Useful during reset.
  145. * @intr: HW interrupt handle
  146. * @return: 0 for success, otherwise failure
  147. */
  148. int (*disable_all_irqs)(
  149. struct sde_hw_intr *intr);
  150. /**
  151. * dispatch_irqs - IRQ dispatcher will call the given callback
  152. * function when a matching interrupt status bit is
  153. * found in the irq mapping table.
  154. * @intr: HW interrupt handle
  155. * @cbfunc: Callback function pointer
  156. * @arg: Argument to pass back during callback
  157. */
  158. void (*dispatch_irqs)(
  159. struct sde_hw_intr *intr,
  160. void (*cbfunc)(void *arg, int irq_idx),
  161. void *arg);
  162. /**
  163. * clear_interrupt_status - Clears HW interrupt status based on given
  164. * lookup IRQ index
  165. * @intr: HW interrupt handle
  166. * @irq_idx: Lookup irq index return from irq_idx_lookup
  167. */
  168. void (*clear_interrupt_status)(
  169. struct sde_hw_intr *intr,
  170. int irq_idx);
  171. /**
  172. * get_interrupt_status - Gets HW interrupt status, and clear if set,
  173. * based on given lookup IRQ index.
  174. * @intr: HW interrupt handle
  175. * @irq_idx: Lookup irq index return from irq_idx_lookup
  176. * @clear: True to clear irq after read
  177. */
  178. u32 (*get_interrupt_status)(
  179. struct sde_hw_intr *intr,
  180. int irq_idx,
  181. bool clear);
  182. /**
  183. * get_intr_status_nolock - nolock version of get_interrupt_status
  184. * @intr: HW interrupt handle
  185. * @irq_idx: Lookup irq index return from irq_idx_lookup
  186. * @clear: True to clear irq after read
  187. */
  188. u32 (*get_intr_status_nolock)(
  189. struct sde_hw_intr *intr,
  190. int irq_idx,
  191. bool clear);
  192. /**
  193. * get_interrupt_sources - Gets the bitmask of the SDE interrupt
  194. * source that are currently fired.
  195. * @intr: HW interrupt handle
  196. * @sources: Returning the SDE interrupt source status bit mask
  197. * @return: 0 for success, otherwise failure
  198. */
  199. int (*get_interrupt_sources)(
  200. struct sde_hw_intr *intr,
  201. uint32_t *sources);
  202. };
  203. /**
  204. * struct sde_hw_intr: hw interrupts handling data structure
  205. * @hw: virtual address mapping
  206. * @ops: function pointer mapping for IRQ handling
  207. * @cache_irq_mask: array of IRQ enable masks reg storage created during init
  208. * @save_irq_status: array of IRQ status reg storage created during init
  209. * @irq_lock: spinlock for accessing IRQ resources
  210. * @sde_irq_size: total number of elements of the sde_irq_tbl
  211. * @sde_irq_tbl: table with the registesrs offsets of the sde interrupts
  212. * supported by the hw
  213. * @sde_irq_map_size: total number of elements of the 'sde_irq_map'
  214. * @sde_irq_map: total number of interrupt bits valid within the irq regs
  215. */
  216. struct sde_hw_intr {
  217. struct sde_hw_blk_reg_map hw;
  218. struct sde_hw_intr_ops ops;
  219. u32 *cache_irq_mask;
  220. u32 *save_irq_status;
  221. u32 sde_irq_size;
  222. struct sde_intr_reg *sde_irq_tbl;
  223. u32 sde_irq_map_size;
  224. struct sde_irq_type *sde_irq_map;
  225. spinlock_t irq_lock;
  226. };
  227. /**
  228. * sde_hw_intr_init(): Initializes the interrupts hw object
  229. * @addr: mapped register io address of MDP
  230. * @m : pointer to mdss catalog data
  231. */
  232. struct sde_hw_intr *sde_hw_intr_init(void __iomem *addr,
  233. struct sde_mdss_cfg *m);
  234. /**
  235. * sde_hw_intr_destroy(): Cleanup interrutps hw object
  236. * @intr: pointer to interrupts hw object
  237. */
  238. void sde_hw_intr_destroy(struct sde_hw_intr *intr);
  239. /**
  240. * sde_hw_intr_list_lookup(): get the list entry for a given intr
  241. * @sde_cfg: catalog containing the irq_offset_list
  242. * @type: the sde_intr_hwblk_type to lookup
  243. * @idx: the instance id to lookup for the specified hwblk_type
  244. * @return: pointer to sde_intr_irq_offsets list entry, or NULL if lookup fails
  245. */
  246. static inline struct sde_intr_irq_offsets *sde_hw_intr_list_lookup(
  247. struct sde_mdss_cfg *sde_cfg, enum sde_intr_hwblk_type type, u32 idx)
  248. {
  249. struct sde_intr_irq_offsets *item;
  250. list_for_each_entry(item, &sde_cfg->irq_offset_list, list) {
  251. if (type == item->type && idx == item->instance_idx)
  252. return item;
  253. }
  254. return NULL;
  255. }
  256. #endif