1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #ifndef __IA_CSS_IRQ_H 8 #define __IA_CSS_IRQ_H 9 10 /* @file 11 * This file contains information for Interrupts/IRQs from CSS 12 */ 13 14 #include "ia_css_err.h" 15 #include "ia_css_pipe_public.h" 16 #include "ia_css_input_port.h" 17 #include <linux/bits.h> 18 19 /* Interrupt types, these enumerate all supported interrupt types. 20 */ 21 enum ia_css_irq_type { 22 IA_CSS_IRQ_TYPE_EDGE, /** Edge (level) sensitive interrupt */ 23 IA_CSS_IRQ_TYPE_PULSE /** Pulse-shaped interrupt */ 24 }; 25 26 /* Interrupt request type. 27 * When the CSS hardware generates an interrupt, a function in this API 28 * needs to be called to retrieve information about the interrupt. 29 * This interrupt type is part of this information and indicates what 30 * type of information the interrupt signals. 31 * 32 * Note that one interrupt can carry multiple interrupt types. For 33 * example: the online video ISP will generate only 2 interrupts, one to 34 * signal that the statistics (3a and DIS) are ready and one to signal 35 * that all output frames are done (output and viewfinder). 36 * 37 * DEPRECATED, this interface is not portable it should only define user 38 * (SW) interrupts 39 */ 40 enum ia_css_irq_info { 41 IA_CSS_IRQ_INFO_CSS_RECEIVER_ERROR = BIT(0), 42 /** the css receiver has encountered an error */ 43 IA_CSS_IRQ_INFO_CSS_RECEIVER_FIFO_OVERFLOW = BIT(1), 44 /** the FIFO in the csi receiver has overflown */ 45 IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF = BIT(2), 46 /** the css receiver received the start of frame */ 47 IA_CSS_IRQ_INFO_CSS_RECEIVER_EOF = BIT(3), 48 /** the css receiver received the end of frame */ 49 IA_CSS_IRQ_INFO_CSS_RECEIVER_SOL = BIT(4), 50 /** the css receiver received the start of line */ 51 IA_CSS_IRQ_INFO_EVENTS_READY = BIT(5), 52 /** One or more events are available in the PSYS event queue */ 53 IA_CSS_IRQ_INFO_CSS_RECEIVER_EOL = BIT(6), 54 /** the css receiver received the end of line */ 55 IA_CSS_IRQ_INFO_CSS_RECEIVER_SIDEBAND_CHANGED = BIT(7), 56 /** the css receiver received a change in side band signals */ 57 IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_0 = BIT(8), 58 /** generic short packets (0) */ 59 IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_1 = BIT(9), 60 /** generic short packets (1) */ 61 IA_CSS_IRQ_INFO_IF_PRIM_ERROR = BIT(10), 62 /** the primary input formatter (A) has encountered an error */ 63 IA_CSS_IRQ_INFO_IF_PRIM_B_ERROR = BIT(11), 64 /** the primary input formatter (B) has encountered an error */ 65 IA_CSS_IRQ_INFO_IF_SEC_ERROR = BIT(12), 66 /** the secondary input formatter has encountered an error */ 67 IA_CSS_IRQ_INFO_STREAM_TO_MEM_ERROR = BIT(13), 68 /** the stream-to-memory device has encountered an error */ 69 IA_CSS_IRQ_INFO_SW_0 = BIT(14), 70 /** software interrupt 0 */ 71 IA_CSS_IRQ_INFO_SW_1 = BIT(15), 72 /** software interrupt 1 */ 73 IA_CSS_IRQ_INFO_SW_2 = BIT(16), 74 /** software interrupt 2 */ 75 IA_CSS_IRQ_INFO_ISP_BINARY_STATISTICS_READY = BIT(17), 76 /** ISP binary statistics are ready */ 77 IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR = BIT(18), 78 /** the input system is in error */ 79 IA_CSS_IRQ_INFO_IF_ERROR = BIT(19), 80 /** the input formatter is in error */ 81 IA_CSS_IRQ_INFO_DMA_ERROR = BIT(20), 82 /** the dma is in error */ 83 IA_CSS_IRQ_INFO_ISYS_EVENTS_READY = BIT(21), 84 /** end-of-frame events are ready in the isys_event queue */ 85 }; 86 87 /* CSS receiver error types. Whenever the CSS receiver has encountered 88 * an error, this enumeration is used to indicate which errors have occurred. 89 * 90 * Note that multiple error flags can be enabled at once and that this is in 91 * fact common (whenever an error occurs, it usually results in multiple 92 * errors). 93 * 94 * DEPRECATED: This interface is not portable, different systems have 95 * different receiver types, or possibly none in case of tests systems. 96 */ 97 enum ia_css_rx_irq_info { 98 IA_CSS_RX_IRQ_INFO_BUFFER_OVERRUN = BIT(0), /** buffer overrun */ 99 IA_CSS_RX_IRQ_INFO_ENTER_SLEEP_MODE = BIT(1), /** entering sleep mode */ 100 IA_CSS_RX_IRQ_INFO_EXIT_SLEEP_MODE = BIT(2), /** exited sleep mode */ 101 IA_CSS_RX_IRQ_INFO_ECC_CORRECTED = BIT(3), /** ECC corrected */ 102 IA_CSS_RX_IRQ_INFO_ERR_SOT = BIT(4), 103 /** Start of transmission */ 104 IA_CSS_RX_IRQ_INFO_ERR_SOT_SYNC = BIT(5), /** SOT sync (??) */ 105 IA_CSS_RX_IRQ_INFO_ERR_CONTROL = BIT(6), /** Control (??) */ 106 IA_CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE = BIT(7), /** Double ECC */ 107 IA_CSS_RX_IRQ_INFO_ERR_CRC = BIT(8), /** CRC error */ 108 IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID = BIT(9), /** Unknown ID */ 109 IA_CSS_RX_IRQ_INFO_ERR_FRAME_SYNC = BIT(10), /** Frame sync error */ 110 IA_CSS_RX_IRQ_INFO_ERR_FRAME_DATA = BIT(11), /** Frame data error */ 111 IA_CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT = BIT(12), /** Timeout occurred */ 112 IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC = BIT(13), /** Unknown escape seq. */ 113 IA_CSS_RX_IRQ_INFO_ERR_LINE_SYNC = BIT(14), /** Line Sync error */ 114 IA_CSS_RX_IRQ_INFO_INIT_TIMEOUT = BIT(15), 115 }; 116 117 /* Interrupt info structure. This structure contains information about an 118 * interrupt. This needs to be used after an interrupt is received on the IA 119 * to perform the correct action. 120 */ 121 struct ia_css_irq { 122 enum ia_css_irq_info type; /** Interrupt type. */ 123 unsigned int sw_irq_0_val; /** In case of SW interrupt 0, value. */ 124 unsigned int sw_irq_1_val; /** In case of SW interrupt 1, value. */ 125 unsigned int sw_irq_2_val; /** In case of SW interrupt 2, value. */ 126 struct ia_css_pipe *pipe; 127 /** The image pipe that generated the interrupt. */ 128 }; 129 130 /* @brief Obtain interrupt information. 131 * 132 * @param[out] info Pointer to the interrupt info. The interrupt 133 * information wil be written to this info. 134 * @return If an error is encountered during the interrupt info 135 * and no interrupt could be translated successfully, this 136 * will return IA_CSS_INTERNAL_ERROR. Otherwise 137 * 0. 138 * 139 * This function is expected to be executed after an interrupt has been sent 140 * to the IA from the CSS. This function returns information about the interrupt 141 * which is needed by the IA code to properly handle the interrupt. This 142 * information includes the image pipe, buffer type etc. 143 */ 144 int 145 ia_css_irq_translate(unsigned int *info); 146 147 /* @brief Get CSI receiver error info. 148 * 149 * @param[out] irq_bits Pointer to the interrupt bits. The interrupt 150 * bits will be written this info. 151 * This will be the error bits that are enabled in the CSI 152 * receiver error register. 153 * @return None 154 * 155 * This function should be used whenever a CSI receiver error interrupt is 156 * generated. It provides the detailed information (bits) on the exact error 157 * that occurred. 158 * 159 *@deprecated {this function is DEPRECATED since it only works on CSI port 1. 160 * Use the function below instead and specify the appropriate port.} 161 */ 162 void 163 ia_css_rx_get_irq_info(unsigned int *irq_bits); 164 165 /* @brief Get CSI receiver error info. 166 * 167 * @param[in] port Input port identifier. 168 * @param[out] irq_bits Pointer to the interrupt bits. The interrupt 169 * bits will be written this info. 170 * This will be the error bits that are enabled in the CSI 171 * receiver error register. 172 * @return None 173 * 174 * This function should be used whenever a CSI receiver error interrupt is 175 * generated. It provides the detailed information (bits) on the exact error 176 * that occurred. 177 */ 178 void 179 ia_css_rx_port_get_irq_info(enum mipi_port_id port, unsigned int *irq_bits); 180 181 /* @brief Clear CSI receiver error info. 182 * 183 * @param[in] irq_bits The bits that should be cleared from the CSI receiver 184 * interrupt bits register. 185 * @return None 186 * 187 * This function should be called after ia_css_rx_get_irq_info has been called 188 * and the error bits have been interpreted. It is advised to use the return 189 * value of that function as the argument to this function to make sure no new 190 * error bits get overwritten. 191 * 192 * @deprecated{this function is DEPRECATED since it only works on CSI port 1. 193 * Use the function below instead and specify the appropriate port.} 194 */ 195 void 196 ia_css_rx_clear_irq_info(unsigned int irq_bits); 197 198 /* @brief Clear CSI receiver error info. 199 * 200 * @param[in] port Input port identifier. 201 * @param[in] irq_bits The bits that should be cleared from the CSI receiver 202 * interrupt bits register. 203 * @return None 204 * 205 * This function should be called after ia_css_rx_get_irq_info has been called 206 * and the error bits have been interpreted. It is advised to use the return 207 * value of that function as the argument to this function to make sure no new 208 * error bits get overwritten. 209 */ 210 void 211 ia_css_rx_port_clear_irq_info(enum mipi_port_id port, unsigned int irq_bits); 212 213 /* @brief Enable or disable specific interrupts. 214 * 215 * @param[in] type The interrupt type that will be enabled/disabled. 216 * @param[in] enable enable or disable. 217 * @return Returns IA_CSS_INTERNAL_ERROR if this interrupt 218 * type cannot be enabled/disabled which is true for 219 * CSS internal interrupts. Otherwise returns 220 * 0. 221 */ 222 int 223 ia_css_irq_enable(enum ia_css_irq_info type, bool enable); 224 225 #endif /* __IA_CSS_IRQ_H */ 226