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