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