sde_hw_interrupts.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, 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. * set_mask - Programs the given interrupt register with the
  100. * given interrupt mask. Register value will get overwritten.
  101. * @intr: HW interrupt handle
  102. * @reg_off: MDSS HW register offset
  103. * @irqmask: IRQ mask value
  104. */
  105. void (*set_mask)(
  106. struct sde_hw_intr *intr,
  107. uint32_t reg,
  108. uint32_t irqmask);
  109. /**
  110. * irq_idx_lookup - Lookup IRQ index on the HW interrupt type
  111. * Used for all irq related ops
  112. * @intr: HW interrupt handle
  113. * @intr_type: Interrupt type defined in sde_intr_type
  114. * @instance_idx: HW interrupt block instance
  115. * @return: irq_idx or -EINVAL for lookup fail
  116. */
  117. int (*irq_idx_lookup)(
  118. struct sde_hw_intr *intr,
  119. enum sde_intr_type intr_type,
  120. u32 instance_idx);
  121. /**
  122. * enable_irq_nolock - Enable IRQ based on lookup IRQ index without lock
  123. * @intr: HW interrupt handle
  124. * @irq_idx: Lookup irq index return from irq_idx_lookup
  125. * @return: 0 for success, otherwise failure
  126. */
  127. int (*enable_irq_nolock)(
  128. struct sde_hw_intr *intr,
  129. int irq_idx);
  130. /**
  131. * disable_irq_nolock - Disable IRQ based on IRQ index without lock
  132. * @intr: HW interrupt handle
  133. * @irq_idx: Lookup irq index return from irq_idx_lookup
  134. * @return: 0 for success, otherwise failure
  135. */
  136. int (*disable_irq_nolock)(
  137. struct sde_hw_intr *intr,
  138. int irq_idx);
  139. /**
  140. * clear_all_irqs - Clears all the interrupts (i.e. acknowledges
  141. * any asserted IRQs). Useful during reset.
  142. * @intr: HW interrupt handle
  143. * @return: 0 for success, otherwise failure
  144. */
  145. int (*clear_all_irqs)(
  146. struct sde_hw_intr *intr);
  147. /**
  148. * disable_all_irqs - Disables all the interrupts. Useful during reset.
  149. * @intr: HW interrupt handle
  150. * @return: 0 for success, otherwise failure
  151. */
  152. int (*disable_all_irqs)(
  153. struct sde_hw_intr *intr);
  154. /**
  155. * dispatch_irqs - IRQ dispatcher will call the given callback
  156. * function when a matching interrupt status bit is
  157. * found in the irq mapping table.
  158. * @intr: HW interrupt handle
  159. * @cbfunc: Callback function pointer
  160. * @arg: Argument to pass back during callback
  161. */
  162. void (*dispatch_irqs)(
  163. struct sde_hw_intr *intr,
  164. void (*cbfunc)(void *arg, int irq_idx),
  165. void *arg);
  166. /**
  167. * get_interrupt_statuses - Gets and store value from all interrupt
  168. * status registers that are currently fired.
  169. * @intr: HW interrupt handle
  170. */
  171. void (*get_interrupt_statuses)(
  172. struct sde_hw_intr *intr);
  173. /**
  174. * clear_interrupt_status - Clears HW interrupt status based on given
  175. * lookup IRQ index.
  176. * @intr: HW interrupt handle
  177. * @irq_idx: Lookup irq index return from irq_idx_lookup
  178. */
  179. void (*clear_interrupt_status)(
  180. struct sde_hw_intr *intr,
  181. int irq_idx);
  182. /**
  183. * clear_intr_status_nolock() - clears the HW interrupts without lock
  184. * @intr: HW interrupt handle
  185. * @irq_idx: Lookup irq index return from irq_idx_lookup
  186. */
  187. void (*clear_intr_status_nolock)(
  188. struct sde_hw_intr *intr,
  189. int irq_idx);
  190. /**
  191. * clear_intr_status_force_mask() - clear the HW interrupts
  192. * @intr: HW interrupt handle
  193. * @irq_idx: Lookup irq index return from irq_idx_lookup
  194. * @irq_mask: irq mask to clear
  195. */
  196. void (*clear_intr_status_force_mask)(
  197. struct sde_hw_intr *intr,
  198. int irq_idx,
  199. u32 irq_mask);
  200. /**
  201. * get_interrupt_status - Gets HW interrupt status, and clear if set,
  202. * based on given lookup IRQ index.
  203. * @intr: HW interrupt handle
  204. * @irq_idx: Lookup irq index return from irq_idx_lookup
  205. * @clear: True to clear irq after read
  206. */
  207. u32 (*get_interrupt_status)(
  208. struct sde_hw_intr *intr,
  209. int irq_idx,
  210. bool clear);
  211. /**
  212. * get_intr_status_nolock - nolock version of get_interrupt_status
  213. * @intr: HW interrupt handle
  214. * @irq_idx: Lookup irq index return from irq_idx_lookup
  215. * @clear: True to clear irq after read
  216. */
  217. u32 (*get_intr_status_nolock)(
  218. struct sde_hw_intr *intr,
  219. int irq_idx,
  220. bool clear);
  221. /**
  222. * get_intr_status_nomask - nolock version of get_interrupt_status
  223. * @intr: HW interrupt handle
  224. * @irq_idx: Lookup irq index return from irq_idx_lookup
  225. * @clear: True to clear irq after read
  226. */
  227. u32 (*get_intr_status_nomask)(
  228. struct sde_hw_intr *intr,
  229. int irq_idx,
  230. bool clear);
  231. /**
  232. * get_valid_interrupts - Gets a mask of all valid interrupt sources
  233. * within SDE. These are actually status bits
  234. * within interrupt registers that specify the
  235. * source of the interrupt in IRQs. For example,
  236. * valid interrupt sources can be MDP, DSI,
  237. * HDMI etc.
  238. * @intr: HW interrupt handle
  239. * @mask: Returning the interrupt source MASK
  240. * @return: 0 for success, otherwise failure
  241. */
  242. int (*get_valid_interrupts)(
  243. struct sde_hw_intr *intr,
  244. uint32_t *mask);
  245. /**
  246. * get_interrupt_sources - Gets the bitmask of the SDE interrupt
  247. * source that are currently fired.
  248. * @intr: HW interrupt handle
  249. * @sources: Returning the SDE interrupt source status bit mask
  250. * @return: 0 for success, otherwise failure
  251. */
  252. int (*get_interrupt_sources)(
  253. struct sde_hw_intr *intr,
  254. uint32_t *sources);
  255. };
  256. /**
  257. * struct sde_hw_intr: hw interrupts handling data structure
  258. * @hw: virtual address mapping
  259. * @ops: function pointer mapping for IRQ handling
  260. * @cache_irq_mask: array of IRQ enable masks reg storage created during init
  261. * @save_irq_status: array of IRQ status reg storage created during init
  262. * @irq_lock: spinlock for accessing IRQ resources
  263. * @sde_irq_size: total number of elements of the sde_irq_tbl
  264. * @sde_irq_tbl: table with the registesrs offsets of the sde interrupts
  265. * supported by the hw
  266. * @sde_irq_map_size: total number of elements of the 'sde_irq_map'
  267. * @sde_irq_map: total number of interrupt bits valid within the irq regs
  268. */
  269. struct sde_hw_intr {
  270. struct sde_hw_blk_reg_map hw;
  271. struct sde_hw_intr_ops ops;
  272. u32 *cache_irq_mask;
  273. u32 *save_irq_status;
  274. u32 sde_irq_size;
  275. struct sde_intr_reg *sde_irq_tbl;
  276. u32 sde_irq_map_size;
  277. struct sde_irq_type *sde_irq_map;
  278. spinlock_t irq_lock;
  279. };
  280. /**
  281. * sde_hw_intr_init(): Initializes the interrupts hw object
  282. * @addr: mapped register io address of MDP
  283. * @m : pointer to mdss catalog data
  284. */
  285. struct sde_hw_intr *sde_hw_intr_init(void __iomem *addr,
  286. struct sde_mdss_cfg *m);
  287. /**
  288. * sde_hw_intr_destroy(): Cleanup interrutps hw object
  289. * @intr: pointer to interrupts hw object
  290. */
  291. void sde_hw_intr_destroy(struct sde_hw_intr *intr);
  292. /**
  293. * sde_hw_intr_list_lookup(): get the list entry for a given intr
  294. * @sde_cfg: catalog containing the irq_offset_list
  295. * @type: the sde_intr_hwblk_type to lookup
  296. * @idx: the instance id to lookup for the specified hwblk_type
  297. * @return: pointer to sde_intr_irq_offsets list entry, or NULL if lookup fails
  298. */
  299. static inline struct sde_intr_irq_offsets *sde_hw_intr_list_lookup(
  300. struct sde_mdss_cfg *sde_cfg, enum sde_intr_hwblk_type type, u32 idx)
  301. {
  302. struct sde_intr_irq_offsets *item;
  303. list_for_each_entry(item, &sde_cfg->irq_offset_list, list) {
  304. if (type == item->type && idx == item->instance_idx)
  305. return item;
  306. }
  307. return NULL;
  308. }
  309. #endif