dpu_hw_interrupts.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DPU_HW_INTERRUPTS_H
  13. #define _DPU_HW_INTERRUPTS_H
  14. #include <linux/types.h>
  15. #include "dpu_hwio.h"
  16. #include "dpu_hw_catalog.h"
  17. #include "dpu_hw_util.h"
  18. #include "dpu_hw_mdss.h"
  19. #define IRQ_SOURCE_MDP BIT(0)
  20. #define IRQ_SOURCE_DSI0 BIT(4)
  21. #define IRQ_SOURCE_DSI1 BIT(5)
  22. #define IRQ_SOURCE_HDMI BIT(8)
  23. #define IRQ_SOURCE_EDP BIT(12)
  24. #define IRQ_SOURCE_MHL BIT(16)
  25. /**
  26. * dpu_intr_type - HW Interrupt Type
  27. * @DPU_IRQ_TYPE_WB_ROT_COMP: WB rotator done
  28. * @DPU_IRQ_TYPE_WB_WFD_COMP: WB WFD done
  29. * @DPU_IRQ_TYPE_PING_PONG_COMP: PingPong done
  30. * @DPU_IRQ_TYPE_PING_PONG_RD_PTR: PingPong read pointer
  31. * @DPU_IRQ_TYPE_PING_PONG_WR_PTR: PingPong write pointer
  32. * @DPU_IRQ_TYPE_PING_PONG_AUTO_REF: PingPong auto refresh
  33. * @DPU_IRQ_TYPE_PING_PONG_TEAR_CHECK: PingPong Tear check
  34. * @DPU_IRQ_TYPE_PING_PONG_TE_CHECK: PingPong TE detection
  35. * @DPU_IRQ_TYPE_INTF_UNDER_RUN: INTF underrun
  36. * @DPU_IRQ_TYPE_INTF_VSYNC: INTF VSYNC
  37. * @DPU_IRQ_TYPE_CWB_OVERFLOW: Concurrent WB overflow
  38. * @DPU_IRQ_TYPE_HIST_VIG_DONE: VIG Histogram done
  39. * @DPU_IRQ_TYPE_HIST_VIG_RSTSEQ: VIG Histogram reset
  40. * @DPU_IRQ_TYPE_HIST_DSPP_DONE: DSPP Histogram done
  41. * @DPU_IRQ_TYPE_HIST_DSPP_RSTSEQ: DSPP Histogram reset
  42. * @DPU_IRQ_TYPE_WD_TIMER: Watchdog timer
  43. * @DPU_IRQ_TYPE_SFI_VIDEO_IN: Video static frame INTR into static
  44. * @DPU_IRQ_TYPE_SFI_VIDEO_OUT: Video static frame INTR out-of static
  45. * @DPU_IRQ_TYPE_SFI_CMD_0_IN: DSI CMD0 static frame INTR into static
  46. * @DPU_IRQ_TYPE_SFI_CMD_0_OUT: DSI CMD0 static frame INTR out-of static
  47. * @DPU_IRQ_TYPE_SFI_CMD_1_IN: DSI CMD1 static frame INTR into static
  48. * @DPU_IRQ_TYPE_SFI_CMD_1_OUT: DSI CMD1 static frame INTR out-of static
  49. * @DPU_IRQ_TYPE_SFI_CMD_2_IN: DSI CMD2 static frame INTR into static
  50. * @DPU_IRQ_TYPE_SFI_CMD_2_OUT: DSI CMD2 static frame INTR out-of static
  51. * @DPU_IRQ_TYPE_PROG_LINE: Programmable Line interrupt
  52. * @DPU_IRQ_TYPE_AD4_BL_DONE: AD4 backlight
  53. * @DPU_IRQ_TYPE_CTL_START: Control start
  54. * @DPU_IRQ_TYPE_RESERVED: Reserved for expansion
  55. */
  56. enum dpu_intr_type {
  57. DPU_IRQ_TYPE_WB_ROT_COMP,
  58. DPU_IRQ_TYPE_WB_WFD_COMP,
  59. DPU_IRQ_TYPE_PING_PONG_COMP,
  60. DPU_IRQ_TYPE_PING_PONG_RD_PTR,
  61. DPU_IRQ_TYPE_PING_PONG_WR_PTR,
  62. DPU_IRQ_TYPE_PING_PONG_AUTO_REF,
  63. DPU_IRQ_TYPE_PING_PONG_TEAR_CHECK,
  64. DPU_IRQ_TYPE_PING_PONG_TE_CHECK,
  65. DPU_IRQ_TYPE_INTF_UNDER_RUN,
  66. DPU_IRQ_TYPE_INTF_VSYNC,
  67. DPU_IRQ_TYPE_CWB_OVERFLOW,
  68. DPU_IRQ_TYPE_HIST_VIG_DONE,
  69. DPU_IRQ_TYPE_HIST_VIG_RSTSEQ,
  70. DPU_IRQ_TYPE_HIST_DSPP_DONE,
  71. DPU_IRQ_TYPE_HIST_DSPP_RSTSEQ,
  72. DPU_IRQ_TYPE_WD_TIMER,
  73. DPU_IRQ_TYPE_SFI_VIDEO_IN,
  74. DPU_IRQ_TYPE_SFI_VIDEO_OUT,
  75. DPU_IRQ_TYPE_SFI_CMD_0_IN,
  76. DPU_IRQ_TYPE_SFI_CMD_0_OUT,
  77. DPU_IRQ_TYPE_SFI_CMD_1_IN,
  78. DPU_IRQ_TYPE_SFI_CMD_1_OUT,
  79. DPU_IRQ_TYPE_SFI_CMD_2_IN,
  80. DPU_IRQ_TYPE_SFI_CMD_2_OUT,
  81. DPU_IRQ_TYPE_PROG_LINE,
  82. DPU_IRQ_TYPE_AD4_BL_DONE,
  83. DPU_IRQ_TYPE_CTL_START,
  84. DPU_IRQ_TYPE_RESERVED,
  85. };
  86. struct dpu_hw_intr;
  87. /**
  88. * Interrupt operations.
  89. */
  90. struct dpu_hw_intr_ops {
  91. /**
  92. * set_mask - Programs the given interrupt register with the
  93. * given interrupt mask. Register value will get overwritten.
  94. * @intr: HW interrupt handle
  95. * @reg_off: MDSS HW register offset
  96. * @irqmask: IRQ mask value
  97. */
  98. void (*set_mask)(
  99. struct dpu_hw_intr *intr,
  100. uint32_t reg,
  101. uint32_t irqmask);
  102. /**
  103. * irq_idx_lookup - Lookup IRQ index on the HW interrupt type
  104. * Used for all irq related ops
  105. * @intr_type: Interrupt type defined in dpu_intr_type
  106. * @instance_idx: HW interrupt block instance
  107. * @return: irq_idx or -EINVAL for lookup fail
  108. */
  109. int (*irq_idx_lookup)(
  110. enum dpu_intr_type intr_type,
  111. u32 instance_idx);
  112. /**
  113. * enable_irq - Enable IRQ based on lookup IRQ index
  114. * @intr: HW interrupt handle
  115. * @irq_idx: Lookup irq index return from irq_idx_lookup
  116. * @return: 0 for success, otherwise failure
  117. */
  118. int (*enable_irq)(
  119. struct dpu_hw_intr *intr,
  120. int irq_idx);
  121. /**
  122. * disable_irq - Disable IRQ based on lookup IRQ index
  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 (*disable_irq)(
  128. struct dpu_hw_intr *intr,
  129. int irq_idx);
  130. /**
  131. * clear_all_irqs - Clears all the interrupts (i.e. acknowledges
  132. * any asserted IRQs). Useful during reset.
  133. * @intr: HW interrupt handle
  134. * @return: 0 for success, otherwise failure
  135. */
  136. int (*clear_all_irqs)(
  137. struct dpu_hw_intr *intr);
  138. /**
  139. * disable_all_irqs - Disables all the interrupts. Useful during reset.
  140. * @intr: HW interrupt handle
  141. * @return: 0 for success, otherwise failure
  142. */
  143. int (*disable_all_irqs)(
  144. struct dpu_hw_intr *intr);
  145. /**
  146. * dispatch_irqs - IRQ dispatcher will call the given callback
  147. * function when a matching interrupt status bit is
  148. * found in the irq mapping table.
  149. * @intr: HW interrupt handle
  150. * @cbfunc: Callback function pointer
  151. * @arg: Argument to pass back during callback
  152. */
  153. void (*dispatch_irqs)(
  154. struct dpu_hw_intr *intr,
  155. void (*cbfunc)(void *arg, int irq_idx),
  156. void *arg);
  157. /**
  158. * get_interrupt_statuses - Gets and store value from all interrupt
  159. * status registers that are currently fired.
  160. * @intr: HW interrupt handle
  161. */
  162. void (*get_interrupt_statuses)(
  163. struct dpu_hw_intr *intr);
  164. /**
  165. * clear_interrupt_status - Clears HW interrupt status based on given
  166. * lookup IRQ index.
  167. * @intr: HW interrupt handle
  168. * @irq_idx: Lookup irq index return from irq_idx_lookup
  169. */
  170. void (*clear_interrupt_status)(
  171. struct dpu_hw_intr *intr,
  172. int irq_idx);
  173. /**
  174. * clear_intr_status_nolock() - clears the HW interrupts without lock
  175. * @intr: HW interrupt handle
  176. * @irq_idx: Lookup irq index return from irq_idx_lookup
  177. */
  178. void (*clear_intr_status_nolock)(
  179. struct dpu_hw_intr *intr,
  180. int irq_idx);
  181. /**
  182. * get_interrupt_status - Gets HW interrupt status, and clear if set,
  183. * based on given lookup IRQ index.
  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_interrupt_status)(
  189. struct dpu_hw_intr *intr,
  190. int irq_idx,
  191. bool clear);
  192. /**
  193. * get_valid_interrupts - Gets a mask of all valid interrupt sources
  194. * within DPU. These are actually status bits
  195. * within interrupt registers that specify the
  196. * source of the interrupt in IRQs. For example,
  197. * valid interrupt sources can be MDP, DSI,
  198. * HDMI etc.
  199. * @intr: HW interrupt handle
  200. * @mask: Returning the interrupt source MASK
  201. * @return: 0 for success, otherwise failure
  202. */
  203. int (*get_valid_interrupts)(
  204. struct dpu_hw_intr *intr,
  205. uint32_t *mask);
  206. };
  207. /**
  208. * struct dpu_hw_intr: hw interrupts handling data structure
  209. * @hw: virtual address mapping
  210. * @ops: function pointer mapping for IRQ handling
  211. * @cache_irq_mask: array of IRQ enable masks reg storage created during init
  212. * @save_irq_status: array of IRQ status reg storage created during init
  213. * @irq_idx_tbl_size: total number of irq_idx mapped in the hw_interrupts
  214. * @irq_lock: spinlock for accessing IRQ resources
  215. */
  216. struct dpu_hw_intr {
  217. struct dpu_hw_blk_reg_map hw;
  218. struct dpu_hw_intr_ops ops;
  219. u32 *cache_irq_mask;
  220. u32 *save_irq_status;
  221. u32 irq_idx_tbl_size;
  222. spinlock_t irq_lock;
  223. };
  224. /**
  225. * dpu_hw_intr_init(): Initializes the interrupts hw object
  226. * @addr: mapped register io address of MDP
  227. * @m : pointer to mdss catalog data
  228. */
  229. struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,
  230. struct dpu_mdss_cfg *m);
  231. /**
  232. * dpu_hw_intr_destroy(): Cleanup interrutps hw object
  233. * @intr: pointer to interrupts hw object
  234. */
  235. void dpu_hw_intr_destroy(struct dpu_hw_intr *intr);
  236. #endif