sde_hw_interrupts.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021 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_CHECK: INTF Tear Tear check
  53. * @SDE_IRQ_TYPE_INTF_TEAR_TE_CHECK: INTF Tear TE detection
  54. * @SDE_IRQ_TYPE_LTM_STATS_DONE: LTM stats done interrupt
  55. * @SDE_IRQ_TYPE_LTM_STATS_WB_PB: LTM stats WB push back interrupt
  56. * @SDE_IRQ_TYPE_PROG_LINE: Programmable Line interrupt for WB
  57. * @SDE_IRQ_TYPE_RESERVED: Reserved for expansion
  58. */
  59. enum sde_intr_type {
  60. SDE_IRQ_TYPE_WB_ROT_COMP,
  61. SDE_IRQ_TYPE_WB_WFD_COMP,
  62. SDE_IRQ_TYPE_PING_PONG_COMP,
  63. SDE_IRQ_TYPE_PING_PONG_RD_PTR,
  64. SDE_IRQ_TYPE_PING_PONG_WR_PTR,
  65. SDE_IRQ_TYPE_PING_PONG_AUTO_REF,
  66. SDE_IRQ_TYPE_PING_PONG_TEAR_CHECK,
  67. SDE_IRQ_TYPE_PING_PONG_TE_CHECK,
  68. SDE_IRQ_TYPE_INTF_UNDER_RUN,
  69. SDE_IRQ_TYPE_INTF_VSYNC,
  70. SDE_IRQ_TYPE_CWB_OVERFLOW,
  71. SDE_IRQ_TYPE_HIST_VIG_DONE,
  72. SDE_IRQ_TYPE_HIST_VIG_RSTSEQ,
  73. SDE_IRQ_TYPE_HIST_DSPP_DONE,
  74. SDE_IRQ_TYPE_HIST_DSPP_RSTSEQ,
  75. SDE_IRQ_TYPE_WD_TIMER,
  76. SDE_IRQ_TYPE_SFI_VIDEO_IN,
  77. SDE_IRQ_TYPE_SFI_VIDEO_OUT,
  78. SDE_IRQ_TYPE_SFI_CMD_0_IN,
  79. SDE_IRQ_TYPE_SFI_CMD_0_OUT,
  80. SDE_IRQ_TYPE_SFI_CMD_1_IN,
  81. SDE_IRQ_TYPE_SFI_CMD_1_OUT,
  82. SDE_IRQ_TYPE_SFI_CMD_2_IN,
  83. SDE_IRQ_TYPE_SFI_CMD_2_OUT,
  84. SDE_IRQ_TYPE_PROG_LINE,
  85. SDE_IRQ_TYPE_AD4_BL_DONE,
  86. SDE_IRQ_TYPE_CTL_START,
  87. SDE_IRQ_TYPE_CTL_DONE,
  88. SDE_IRQ_TYPE_INTF_TEAR_RD_PTR,
  89. SDE_IRQ_TYPE_INTF_TEAR_WR_PTR,
  90. SDE_IRQ_TYPE_INTF_TEAR_AUTO_REF,
  91. SDE_IRQ_TYPE_INTF_TEAR_TEAR_CHECK,
  92. SDE_IRQ_TYPE_INTF_TEAR_TE_CHECK,
  93. SDE_IRQ_TYPE_LTM_STATS_DONE,
  94. SDE_IRQ_TYPE_LTM_STATS_WB_PB,
  95. SDE_IRQ_TYPE_WB_PROG_LINE,
  96. SDE_IRQ_TYPE_RESERVED,
  97. };
  98. struct sde_hw_intr;
  99. /**
  100. * Interrupt operations.
  101. */
  102. struct sde_hw_intr_ops {
  103. /**
  104. * irq_idx_lookup - Lookup IRQ index on the HW interrupt type
  105. * Used for all irq related ops
  106. * @intr: HW interrupt handle
  107. * @intr_type: Interrupt type defined in sde_intr_type
  108. * @instance_idx: HW interrupt block instance
  109. * @return: irq_idx or -EINVAL for lookup fail
  110. */
  111. int (*irq_idx_lookup)(
  112. struct sde_hw_intr *intr,
  113. enum sde_intr_type intr_type,
  114. u32 instance_idx);
  115. /**
  116. * enable_irq_nolock - Enable IRQ based on lookup IRQ index without lock
  117. * @intr: HW interrupt handle
  118. * @irq_idx: Lookup irq index return from irq_idx_lookup
  119. * @return: 0 for success, otherwise failure
  120. */
  121. int (*enable_irq_nolock)(
  122. struct sde_hw_intr *intr,
  123. int irq_idx);
  124. /**
  125. * disable_irq_nolock - Disable IRQ based on IRQ index without lock
  126. * @intr: HW interrupt handle
  127. * @irq_idx: Lookup irq index return from irq_idx_lookup
  128. * @return: 0 for success, otherwise failure
  129. */
  130. int (*disable_irq_nolock)(
  131. struct sde_hw_intr *intr,
  132. int irq_idx);
  133. /**
  134. * clear_all_irqs - Clears all the interrupts (i.e. acknowledges
  135. * any asserted IRQs). Useful during reset.
  136. * @intr: HW interrupt handle
  137. * @return: 0 for success, otherwise failure
  138. */
  139. int (*clear_all_irqs)(
  140. struct sde_hw_intr *intr);
  141. /**
  142. * disable_all_irqs - Disables all the interrupts. Useful during reset.
  143. * @intr: HW interrupt handle
  144. * @return: 0 for success, otherwise failure
  145. */
  146. int (*disable_all_irqs)(
  147. struct sde_hw_intr *intr);
  148. /**
  149. * dispatch_irqs - IRQ dispatcher will call the given callback
  150. * function when a matching interrupt status bit is
  151. * found in the irq mapping table.
  152. * @intr: HW interrupt handle
  153. * @cbfunc: Callback function pointer
  154. * @arg: Argument to pass back during callback
  155. */
  156. void (*dispatch_irqs)(
  157. struct sde_hw_intr *intr,
  158. void (*cbfunc)(void *arg, int irq_idx),
  159. void *arg);
  160. /**
  161. * get_interrupt_statuses - Gets and store value from all interrupt
  162. * status registers that are currently fired.
  163. * @intr: HW interrupt handle
  164. */
  165. void (*get_interrupt_statuses)(
  166. struct sde_hw_intr *intr);
  167. /**
  168. * clear_interrupt_status - Clears HW interrupt status based on given
  169. * lookup IRQ index
  170. * @intr: HW interrupt handle
  171. * @irq_idx: Lookup irq index return from irq_idx_lookup
  172. */
  173. void (*clear_interrupt_status)(
  174. struct sde_hw_intr *intr,
  175. int irq_idx);
  176. /**
  177. * clear_intr_status_nolock() - clears the HW interrupts without lock
  178. * @intr: HW interrupt handle
  179. * @irq_idx: Lookup irq index return from irq_idx_lookup
  180. */
  181. void (*clear_intr_status_nolock)(
  182. struct sde_hw_intr *intr,
  183. int irq_idx);
  184. /**
  185. * get_interrupt_status - Gets HW interrupt status, and clear if set,
  186. * based on given lookup IRQ index.
  187. * @intr: HW interrupt handle
  188. * @irq_idx: Lookup irq index return from irq_idx_lookup
  189. * @clear: True to clear irq after read
  190. */
  191. u32 (*get_interrupt_status)(
  192. struct sde_hw_intr *intr,
  193. int irq_idx,
  194. bool clear);
  195. /**
  196. * get_intr_status_nolock - nolock version of get_interrupt_status
  197. * @intr: HW interrupt handle
  198. * @irq_idx: Lookup irq index return from irq_idx_lookup
  199. * @clear: True to clear irq after read
  200. */
  201. u32 (*get_intr_status_nolock)(
  202. struct sde_hw_intr *intr,
  203. int irq_idx,
  204. bool clear);
  205. /**
  206. * get_interrupt_sources - Gets the bitmask of the SDE interrupt
  207. * source that are currently fired.
  208. * @intr: HW interrupt handle
  209. * @sources: Returning the SDE interrupt source status bit mask
  210. * @return: 0 for success, otherwise failure
  211. */
  212. int (*get_interrupt_sources)(
  213. struct sde_hw_intr *intr,
  214. uint32_t *sources);
  215. };
  216. /**
  217. * struct sde_hw_intr: hw interrupts handling data structure
  218. * @hw: virtual address mapping
  219. * @ops: function pointer mapping for IRQ handling
  220. * @cache_irq_mask: array of IRQ enable masks reg storage created during init
  221. * @save_irq_status: array of IRQ status reg storage created during init
  222. * @irq_lock: spinlock for accessing IRQ resources
  223. * @sde_irq_size: total number of elements of the sde_irq_tbl
  224. * @sde_irq_tbl: table with the registesrs offsets of the sde interrupts
  225. * supported by the hw
  226. * @sde_irq_map_size: total number of elements of the 'sde_irq_map'
  227. * @sde_irq_map: total number of interrupt bits valid within the irq regs
  228. */
  229. struct sde_hw_intr {
  230. struct sde_hw_blk_reg_map hw;
  231. struct sde_hw_intr_ops ops;
  232. u32 *cache_irq_mask;
  233. u32 *save_irq_status;
  234. u32 sde_irq_size;
  235. struct sde_intr_reg *sde_irq_tbl;
  236. u32 sde_irq_map_size;
  237. struct sde_irq_type *sde_irq_map;
  238. spinlock_t irq_lock;
  239. };
  240. /**
  241. * sde_hw_intr_init(): Initializes the interrupts hw object
  242. * @addr: mapped register io address of MDP
  243. * @m : pointer to mdss catalog data
  244. */
  245. struct sde_hw_intr *sde_hw_intr_init(void __iomem *addr,
  246. struct sde_mdss_cfg *m);
  247. /**
  248. * sde_hw_intr_destroy(): Cleanup interrutps hw object
  249. * @intr: pointer to interrupts hw object
  250. */
  251. void sde_hw_intr_destroy(struct sde_hw_intr *intr);
  252. /**
  253. * sde_hw_intr_list_lookup(): get the list entry for a given intr
  254. * @sde_cfg: catalog containing the irq_offset_list
  255. * @type: the sde_intr_hwblk_type to lookup
  256. * @idx: the instance id to lookup for the specified hwblk_type
  257. * @return: pointer to sde_intr_irq_offsets list entry, or NULL if lookup fails
  258. */
  259. static inline struct sde_intr_irq_offsets *sde_hw_intr_list_lookup(
  260. struct sde_mdss_cfg *sde_cfg, enum sde_intr_hwblk_type type, u32 idx)
  261. {
  262. struct sde_intr_irq_offsets *item;
  263. list_for_each_entry(item, &sde_cfg->irq_offset_list, list) {
  264. if (type == item->type && idx == item->instance_idx)
  265. return item;
  266. }
  267. return NULL;
  268. }
  269. #endif