1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. 3 */ 4 5 #ifndef _DPU_HW_INTERRUPTS_H 6 #define _DPU_HW_INTERRUPTS_H 7 8 #include <linux/types.h> 9 10 #include "dpu_hwio.h" 11 #include "dpu_hw_catalog.h" 12 #include "dpu_hw_util.h" 13 #include "dpu_hw_mdss.h" 14 15 /** 16 * dpu_intr_type - HW Interrupt Type 17 * @DPU_IRQ_TYPE_WB_ROT_COMP: WB rotator done 18 * @DPU_IRQ_TYPE_WB_WFD_COMP: WB WFD done 19 * @DPU_IRQ_TYPE_PING_PONG_COMP: PingPong done 20 * @DPU_IRQ_TYPE_PING_PONG_RD_PTR: PingPong read pointer 21 * @DPU_IRQ_TYPE_PING_PONG_WR_PTR: PingPong write pointer 22 * @DPU_IRQ_TYPE_PING_PONG_AUTO_REF: PingPong auto refresh 23 * @DPU_IRQ_TYPE_PING_PONG_TEAR_CHECK: PingPong Tear check 24 * @DPU_IRQ_TYPE_PING_PONG_TE_CHECK: PingPong TE detection 25 * @DPU_IRQ_TYPE_INTF_UNDER_RUN: INTF underrun 26 * @DPU_IRQ_TYPE_INTF_VSYNC: INTF VSYNC 27 * @DPU_IRQ_TYPE_CWB_OVERFLOW: Concurrent WB overflow 28 * @DPU_IRQ_TYPE_HIST_VIG_DONE: VIG Histogram done 29 * @DPU_IRQ_TYPE_HIST_VIG_RSTSEQ: VIG Histogram reset 30 * @DPU_IRQ_TYPE_HIST_DSPP_DONE: DSPP Histogram done 31 * @DPU_IRQ_TYPE_HIST_DSPP_RSTSEQ: DSPP Histogram reset 32 * @DPU_IRQ_TYPE_WD_TIMER: Watchdog timer 33 * @DPU_IRQ_TYPE_SFI_VIDEO_IN: Video static frame INTR into static 34 * @DPU_IRQ_TYPE_SFI_VIDEO_OUT: Video static frame INTR out-of static 35 * @DPU_IRQ_TYPE_SFI_CMD_0_IN: DSI CMD0 static frame INTR into static 36 * @DPU_IRQ_TYPE_SFI_CMD_0_OUT: DSI CMD0 static frame INTR out-of static 37 * @DPU_IRQ_TYPE_SFI_CMD_1_IN: DSI CMD1 static frame INTR into static 38 * @DPU_IRQ_TYPE_SFI_CMD_1_OUT: DSI CMD1 static frame INTR out-of static 39 * @DPU_IRQ_TYPE_SFI_CMD_2_IN: DSI CMD2 static frame INTR into static 40 * @DPU_IRQ_TYPE_SFI_CMD_2_OUT: DSI CMD2 static frame INTR out-of static 41 * @DPU_IRQ_TYPE_PROG_LINE: Programmable Line interrupt 42 * @DPU_IRQ_TYPE_AD4_BL_DONE: AD4 backlight 43 * @DPU_IRQ_TYPE_CTL_START: Control start 44 * @DPU_IRQ_TYPE_RESERVED: Reserved for expansion 45 */ 46 enum dpu_intr_type { 47 DPU_IRQ_TYPE_WB_ROT_COMP, 48 DPU_IRQ_TYPE_WB_WFD_COMP, 49 DPU_IRQ_TYPE_PING_PONG_COMP, 50 DPU_IRQ_TYPE_PING_PONG_RD_PTR, 51 DPU_IRQ_TYPE_PING_PONG_WR_PTR, 52 DPU_IRQ_TYPE_PING_PONG_AUTO_REF, 53 DPU_IRQ_TYPE_PING_PONG_TEAR_CHECK, 54 DPU_IRQ_TYPE_PING_PONG_TE_CHECK, 55 DPU_IRQ_TYPE_INTF_UNDER_RUN, 56 DPU_IRQ_TYPE_INTF_VSYNC, 57 DPU_IRQ_TYPE_CWB_OVERFLOW, 58 DPU_IRQ_TYPE_HIST_VIG_DONE, 59 DPU_IRQ_TYPE_HIST_VIG_RSTSEQ, 60 DPU_IRQ_TYPE_HIST_DSPP_DONE, 61 DPU_IRQ_TYPE_HIST_DSPP_RSTSEQ, 62 DPU_IRQ_TYPE_WD_TIMER, 63 DPU_IRQ_TYPE_SFI_VIDEO_IN, 64 DPU_IRQ_TYPE_SFI_VIDEO_OUT, 65 DPU_IRQ_TYPE_SFI_CMD_0_IN, 66 DPU_IRQ_TYPE_SFI_CMD_0_OUT, 67 DPU_IRQ_TYPE_SFI_CMD_1_IN, 68 DPU_IRQ_TYPE_SFI_CMD_1_OUT, 69 DPU_IRQ_TYPE_SFI_CMD_2_IN, 70 DPU_IRQ_TYPE_SFI_CMD_2_OUT, 71 DPU_IRQ_TYPE_PROG_LINE, 72 DPU_IRQ_TYPE_AD4_BL_DONE, 73 DPU_IRQ_TYPE_CTL_START, 74 DPU_IRQ_TYPE_RESERVED, 75 }; 76 77 struct dpu_hw_intr; 78 79 /** 80 * Interrupt operations. 81 */ 82 struct dpu_hw_intr_ops { 83 /** 84 * irq_idx_lookup - Lookup IRQ index on the HW interrupt type 85 * Used for all irq related ops 86 * @intr: HW interrupt handle 87 * @intr_type: Interrupt type defined in dpu_intr_type 88 * @instance_idx: HW interrupt block instance 89 * @return: irq_idx or -EINVAL for lookup fail 90 */ 91 int (*irq_idx_lookup)(struct dpu_hw_intr *intr, 92 enum dpu_intr_type intr_type, 93 u32 instance_idx); 94 95 /** 96 * enable_irq - Enable IRQ based on lookup IRQ index 97 * @intr: HW interrupt handle 98 * @irq_idx: Lookup irq index return from irq_idx_lookup 99 * @return: 0 for success, otherwise failure 100 */ 101 int (*enable_irq)( 102 struct dpu_hw_intr *intr, 103 int irq_idx); 104 105 /** 106 * disable_irq - Disable IRQ based on lookup IRQ index 107 * @intr: HW interrupt handle 108 * @irq_idx: Lookup irq index return from irq_idx_lookup 109 * @return: 0 for success, otherwise failure 110 */ 111 int (*disable_irq)( 112 struct dpu_hw_intr *intr, 113 int irq_idx); 114 115 /** 116 * clear_all_irqs - Clears all the interrupts (i.e. acknowledges 117 * any asserted IRQs). Useful during reset. 118 * @intr: HW interrupt handle 119 * @return: 0 for success, otherwise failure 120 */ 121 int (*clear_all_irqs)( 122 struct dpu_hw_intr *intr); 123 124 /** 125 * disable_all_irqs - Disables all the interrupts. Useful during reset. 126 * @intr: HW interrupt handle 127 * @return: 0 for success, otherwise failure 128 */ 129 int (*disable_all_irqs)( 130 struct dpu_hw_intr *intr); 131 132 /** 133 * dispatch_irqs - IRQ dispatcher will call the given callback 134 * function when a matching interrupt status bit is 135 * found in the irq mapping table. 136 * @intr: HW interrupt handle 137 * @cbfunc: Callback function pointer 138 * @arg: Argument to pass back during callback 139 */ 140 void (*dispatch_irqs)( 141 struct dpu_hw_intr *intr, 142 void (*cbfunc)(void *arg, int irq_idx), 143 void *arg); 144 145 /** 146 * get_interrupt_statuses - Gets and store value from all interrupt 147 * status registers that are currently fired. 148 * @intr: HW interrupt handle 149 */ 150 void (*get_interrupt_statuses)( 151 struct dpu_hw_intr *intr); 152 153 /** 154 * clear_intr_status_nolock() - clears the HW interrupts without lock 155 * @intr: HW interrupt handle 156 * @irq_idx: Lookup irq index return from irq_idx_lookup 157 */ 158 void (*clear_intr_status_nolock)( 159 struct dpu_hw_intr *intr, 160 int irq_idx); 161 162 /** 163 * get_interrupt_status - Gets HW interrupt status, and clear if set, 164 * based on given lookup IRQ index. 165 * @intr: HW interrupt handle 166 * @irq_idx: Lookup irq index return from irq_idx_lookup 167 * @clear: True to clear irq after read 168 */ 169 u32 (*get_interrupt_status)( 170 struct dpu_hw_intr *intr, 171 int irq_idx, 172 bool clear); 173 }; 174 175 /** 176 * struct dpu_hw_intr: hw interrupts handling data structure 177 * @hw: virtual address mapping 178 * @ops: function pointer mapping for IRQ handling 179 * @cache_irq_mask: array of IRQ enable masks reg storage created during init 180 * @save_irq_status: array of IRQ status reg storage created during init 181 * @irq_idx_tbl_size: total number of irq_idx mapped in the hw_interrupts 182 * @irq_lock: spinlock for accessing IRQ resources 183 * @obsolete_irq: irq types that are obsolete for a particular target 184 */ 185 struct dpu_hw_intr { 186 struct dpu_hw_blk_reg_map hw; 187 struct dpu_hw_intr_ops ops; 188 u32 *cache_irq_mask; 189 u32 *save_irq_status; 190 u32 irq_idx_tbl_size; 191 spinlock_t irq_lock; 192 unsigned long irq_mask; 193 unsigned long obsolete_irq; 194 }; 195 196 /** 197 * dpu_hw_intr_init(): Initializes the interrupts hw object 198 * @addr: mapped register io address of MDP 199 * @m : pointer to mdss catalog data 200 */ 201 struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr, 202 struct dpu_mdss_cfg *m); 203 204 /** 205 * dpu_hw_intr_destroy(): Cleanup interrutps hw object 206 * @intr: pointer to interrupts hw object 207 */ 208 void dpu_hw_intr_destroy(struct dpu_hw_intr *intr); 209 #endif 210