sde_hw_interrupts.h 9.2 KB

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