19d4fa1a1SMauro Carvalho Chehab /* 29d4fa1a1SMauro Carvalho Chehab * Support for Intel Camera Imaging ISP subsystem. 39d4fa1a1SMauro Carvalho Chehab * Copyright (c) 2015, Intel Corporation. 49d4fa1a1SMauro Carvalho Chehab * 59d4fa1a1SMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify it 69d4fa1a1SMauro Carvalho Chehab * under the terms and conditions of the GNU General Public License, 79d4fa1a1SMauro Carvalho Chehab * version 2, as published by the Free Software Foundation. 89d4fa1a1SMauro Carvalho Chehab * 99d4fa1a1SMauro Carvalho Chehab * This program is distributed in the hope it will be useful, but WITHOUT 109d4fa1a1SMauro Carvalho Chehab * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 119d4fa1a1SMauro Carvalho Chehab * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 129d4fa1a1SMauro Carvalho Chehab * more details. 139d4fa1a1SMauro Carvalho Chehab */ 149d4fa1a1SMauro Carvalho Chehab 159d4fa1a1SMauro Carvalho Chehab #ifndef __IA_CSS_IRQ_H 169d4fa1a1SMauro Carvalho Chehab #define __IA_CSS_IRQ_H 179d4fa1a1SMauro Carvalho Chehab 189d4fa1a1SMauro Carvalho Chehab /* @file 199d4fa1a1SMauro Carvalho Chehab * This file contains information for Interrupts/IRQs from CSS 209d4fa1a1SMauro Carvalho Chehab */ 219d4fa1a1SMauro Carvalho Chehab 229d4fa1a1SMauro Carvalho Chehab #include "ia_css_err.h" 239d4fa1a1SMauro Carvalho Chehab #include "ia_css_pipe_public.h" 249d4fa1a1SMauro Carvalho Chehab #include "ia_css_input_port.h" 259d4fa1a1SMauro Carvalho Chehab 269d4fa1a1SMauro Carvalho Chehab /* Interrupt types, these enumerate all supported interrupt types. 279d4fa1a1SMauro Carvalho Chehab */ 289d4fa1a1SMauro Carvalho Chehab enum ia_css_irq_type { 299d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_TYPE_EDGE, /** Edge (level) sensitive interrupt */ 309d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_TYPE_PULSE /** Pulse-shaped interrupt */ 319d4fa1a1SMauro Carvalho Chehab }; 329d4fa1a1SMauro Carvalho Chehab 339d4fa1a1SMauro Carvalho Chehab /* Interrupt request type. 349d4fa1a1SMauro Carvalho Chehab * When the CSS hardware generates an interrupt, a function in this API 359d4fa1a1SMauro Carvalho Chehab * needs to be called to retrieve information about the interrupt. 369d4fa1a1SMauro Carvalho Chehab * This interrupt type is part of this information and indicates what 379d4fa1a1SMauro Carvalho Chehab * type of information the interrupt signals. 389d4fa1a1SMauro Carvalho Chehab * 399d4fa1a1SMauro Carvalho Chehab * Note that one interrupt can carry multiple interrupt types. For 409d4fa1a1SMauro Carvalho Chehab * example: the online video ISP will generate only 2 interrupts, one to 419d4fa1a1SMauro Carvalho Chehab * signal that the statistics (3a and DIS) are ready and one to signal 429d4fa1a1SMauro Carvalho Chehab * that all output frames are done (output and viewfinder). 439d4fa1a1SMauro Carvalho Chehab * 449d4fa1a1SMauro Carvalho Chehab * DEPRECATED, this interface is not portable it should only define user 459d4fa1a1SMauro Carvalho Chehab * (SW) interrupts 469d4fa1a1SMauro Carvalho Chehab */ 479d4fa1a1SMauro Carvalho Chehab enum ia_css_irq_info { 489d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_ERROR = 1 << 0, 499d4fa1a1SMauro Carvalho Chehab /** the css receiver has encountered an error */ 509d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_FIFO_OVERFLOW = 1 << 1, 519d4fa1a1SMauro Carvalho Chehab /** the FIFO in the csi receiver has overflown */ 529d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF = 1 << 2, 539d4fa1a1SMauro Carvalho Chehab /** the css receiver received the start of frame */ 549d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_EOF = 1 << 3, 559d4fa1a1SMauro Carvalho Chehab /** the css receiver received the end of frame */ 569d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_SOL = 1 << 4, 579d4fa1a1SMauro Carvalho Chehab /** the css receiver received the start of line */ 589d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_PSYS_EVENTS_READY = 1 << 5, 599d4fa1a1SMauro Carvalho Chehab /** One or more events are available in the PSYS event queue */ 609d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_EVENTS_READY = IA_CSS_IRQ_INFO_PSYS_EVENTS_READY, 619d4fa1a1SMauro Carvalho Chehab /** deprecated{obsolete version of IA_CSS_IRQ_INFO_PSYS_EVENTS_READY, 629d4fa1a1SMauro Carvalho Chehab * same functionality.} */ 639d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_EOL = 1 << 6, 649d4fa1a1SMauro Carvalho Chehab /** the css receiver received the end of line */ 659d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_SIDEBAND_CHANGED = 1 << 7, 669d4fa1a1SMauro Carvalho Chehab /** the css receiver received a change in side band signals */ 679d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_0 = 1 << 8, 689d4fa1a1SMauro Carvalho Chehab /** generic short packets (0) */ 699d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_CSS_RECEIVER_GEN_SHORT_1 = 1 << 9, 709d4fa1a1SMauro Carvalho Chehab /** generic short packets (1) */ 719d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_IF_PRIM_ERROR = 1 << 10, 729d4fa1a1SMauro Carvalho Chehab /** the primary input formatter (A) has encountered an error */ 739d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_IF_PRIM_B_ERROR = 1 << 11, 749d4fa1a1SMauro Carvalho Chehab /** the primary input formatter (B) has encountered an error */ 759d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_IF_SEC_ERROR = 1 << 12, 769d4fa1a1SMauro Carvalho Chehab /** the secondary input formatter has encountered an error */ 779d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_STREAM_TO_MEM_ERROR = 1 << 13, 789d4fa1a1SMauro Carvalho Chehab /** the stream-to-memory device has encountered an error */ 799d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_SW_0 = 1 << 14, 809d4fa1a1SMauro Carvalho Chehab /** software interrupt 0 */ 819d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_SW_1 = 1 << 15, 829d4fa1a1SMauro Carvalho Chehab /** software interrupt 1 */ 839d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_SW_2 = 1 << 16, 849d4fa1a1SMauro Carvalho Chehab /** software interrupt 2 */ 859d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_ISP_BINARY_STATISTICS_READY = 1 << 17, 869d4fa1a1SMauro Carvalho Chehab /** ISP binary statistics are ready */ 879d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR = 1 << 18, 889d4fa1a1SMauro Carvalho Chehab /** the input system in in error */ 899d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_IF_ERROR = 1 << 19, 909d4fa1a1SMauro Carvalho Chehab /** the input formatter in in error */ 919d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_DMA_ERROR = 1 << 20, 929d4fa1a1SMauro Carvalho Chehab /** the dma in in error */ 939d4fa1a1SMauro Carvalho Chehab IA_CSS_IRQ_INFO_ISYS_EVENTS_READY = 1 << 21, 949d4fa1a1SMauro Carvalho Chehab /** end-of-frame events are ready in the isys_event queue */ 959d4fa1a1SMauro Carvalho Chehab }; 969d4fa1a1SMauro Carvalho Chehab 979d4fa1a1SMauro Carvalho Chehab /* CSS receiver error types. Whenever the CSS receiver has encountered 989d4fa1a1SMauro Carvalho Chehab * an error, this enumeration is used to indicate which errors have occurred. 999d4fa1a1SMauro Carvalho Chehab * 1009d4fa1a1SMauro Carvalho Chehab * Note that multiple error flags can be enabled at once and that this is in 1019d4fa1a1SMauro Carvalho Chehab * fact common (whenever an error occurs, it usually results in multiple 1029d4fa1a1SMauro Carvalho Chehab * errors). 1039d4fa1a1SMauro Carvalho Chehab * 1049d4fa1a1SMauro Carvalho Chehab * DEPRECATED: This interface is not portable, different systems have 1059d4fa1a1SMauro Carvalho Chehab * different receiver types, or possibly none in case of tests systems. 1069d4fa1a1SMauro Carvalho Chehab */ 1079d4fa1a1SMauro Carvalho Chehab enum ia_css_rx_irq_info { 1089d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_BUFFER_OVERRUN = 1U << 0, /** buffer overrun */ 1099d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ENTER_SLEEP_MODE = 1U << 1, /** entering sleep mode */ 1109d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_EXIT_SLEEP_MODE = 1U << 2, /** exited sleep mode */ 1119d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ECC_CORRECTED = 1U << 3, /** ECC corrected */ 1129d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_SOT = 1U << 4, 1139d4fa1a1SMauro Carvalho Chehab /** Start of transmission */ 1149d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_SOT_SYNC = 1U << 5, /** SOT sync (??) */ 1159d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_CONTROL = 1U << 6, /** Control (??) */ 1169d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE = 1U << 7, /** Double ECC */ 1179d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_CRC = 1U << 8, /** CRC error */ 1189d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID = 1U << 9, /** Unknown ID */ 1199d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_FRAME_SYNC = 1U << 10,/** Frame sync error */ 1209d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_FRAME_DATA = 1U << 11,/** Frame data error */ 1219d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT = 1U << 12,/** Timeout occurred */ 1229d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC = 1U << 13,/** Unknown escape seq. */ 1239d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_ERR_LINE_SYNC = 1U << 14,/** Line Sync error */ 1249d4fa1a1SMauro Carvalho Chehab IA_CSS_RX_IRQ_INFO_INIT_TIMEOUT = 1U << 15, 1259d4fa1a1SMauro Carvalho Chehab }; 1269d4fa1a1SMauro Carvalho Chehab 1279d4fa1a1SMauro Carvalho Chehab /* Interrupt info structure. This structure contains information about an 1289d4fa1a1SMauro Carvalho Chehab * interrupt. This needs to be used after an interrupt is received on the IA 1299d4fa1a1SMauro Carvalho Chehab * to perform the correct action. 1309d4fa1a1SMauro Carvalho Chehab */ 1319d4fa1a1SMauro Carvalho Chehab struct ia_css_irq { 1329d4fa1a1SMauro Carvalho Chehab enum ia_css_irq_info type; /** Interrupt type. */ 1339d4fa1a1SMauro Carvalho Chehab unsigned int sw_irq_0_val; /** In case of SW interrupt 0, value. */ 1349d4fa1a1SMauro Carvalho Chehab unsigned int sw_irq_1_val; /** In case of SW interrupt 1, value. */ 1359d4fa1a1SMauro Carvalho Chehab unsigned int sw_irq_2_val; /** In case of SW interrupt 2, value. */ 1369d4fa1a1SMauro Carvalho Chehab struct ia_css_pipe *pipe; 1379d4fa1a1SMauro Carvalho Chehab /** The image pipe that generated the interrupt. */ 1389d4fa1a1SMauro Carvalho Chehab }; 1399d4fa1a1SMauro Carvalho Chehab 1409d4fa1a1SMauro Carvalho Chehab /* @brief Obtain interrupt information. 1419d4fa1a1SMauro Carvalho Chehab * 1429d4fa1a1SMauro Carvalho Chehab * @param[out] info Pointer to the interrupt info. The interrupt 1439d4fa1a1SMauro Carvalho Chehab * information wil be written to this info. 1449d4fa1a1SMauro Carvalho Chehab * @return If an error is encountered during the interrupt info 1459d4fa1a1SMauro Carvalho Chehab * and no interrupt could be translated successfully, this 1469d4fa1a1SMauro Carvalho Chehab * will return IA_CSS_INTERNAL_ERROR. Otherwise 14741022d35SMauro Carvalho Chehab * 0. 1489d4fa1a1SMauro Carvalho Chehab * 1499d4fa1a1SMauro Carvalho Chehab * This function is expected to be executed after an interrupt has been sent 1509d4fa1a1SMauro Carvalho Chehab * to the IA from the CSS. This function returns information about the interrupt 1519d4fa1a1SMauro Carvalho Chehab * which is needed by the IA code to properly handle the interrupt. This 1529d4fa1a1SMauro Carvalho Chehab * information includes the image pipe, buffer type etc. 1539d4fa1a1SMauro Carvalho Chehab */ 15441022d35SMauro Carvalho Chehab int 1559d4fa1a1SMauro Carvalho Chehab ia_css_irq_translate(unsigned int *info); 1569d4fa1a1SMauro Carvalho Chehab 1579d4fa1a1SMauro Carvalho Chehab /* @brief Get CSI receiver error info. 1589d4fa1a1SMauro Carvalho Chehab * 1599d4fa1a1SMauro Carvalho Chehab * @param[out] irq_bits Pointer to the interrupt bits. The interrupt 1609d4fa1a1SMauro Carvalho Chehab * bits will be written this info. 1619d4fa1a1SMauro Carvalho Chehab * This will be the error bits that are enabled in the CSI 1629d4fa1a1SMauro Carvalho Chehab * receiver error register. 1639d4fa1a1SMauro Carvalho Chehab * @return None 1649d4fa1a1SMauro Carvalho Chehab * 1659d4fa1a1SMauro Carvalho Chehab * This function should be used whenever a CSI receiver error interrupt is 1669d4fa1a1SMauro Carvalho Chehab * generated. It provides the detailed information (bits) on the exact error 1679d4fa1a1SMauro Carvalho Chehab * that occurred. 1689d4fa1a1SMauro Carvalho Chehab * 1699d4fa1a1SMauro Carvalho Chehab *@deprecated {this function is DEPRECATED since it only works on CSI port 1. 1709d4fa1a1SMauro Carvalho Chehab * Use the function below instead and specify the appropriate port.} 1719d4fa1a1SMauro Carvalho Chehab */ 1729d4fa1a1SMauro Carvalho Chehab void 1739d4fa1a1SMauro Carvalho Chehab ia_css_rx_get_irq_info(unsigned int *irq_bits); 1749d4fa1a1SMauro Carvalho Chehab 1759d4fa1a1SMauro Carvalho Chehab /* @brief Get CSI receiver error info. 1769d4fa1a1SMauro Carvalho Chehab * 1779d4fa1a1SMauro Carvalho Chehab * @param[in] port Input port identifier. 1789d4fa1a1SMauro Carvalho Chehab * @param[out] irq_bits Pointer to the interrupt bits. The interrupt 1799d4fa1a1SMauro Carvalho Chehab * bits will be written this info. 1809d4fa1a1SMauro Carvalho Chehab * This will be the error bits that are enabled in the CSI 1819d4fa1a1SMauro Carvalho Chehab * receiver error register. 1829d4fa1a1SMauro Carvalho Chehab * @return None 1839d4fa1a1SMauro Carvalho Chehab * 1849d4fa1a1SMauro Carvalho Chehab * This function should be used whenever a CSI receiver error interrupt is 1859d4fa1a1SMauro Carvalho Chehab * generated. It provides the detailed information (bits) on the exact error 1869d4fa1a1SMauro Carvalho Chehab * that occurred. 1879d4fa1a1SMauro Carvalho Chehab */ 1889d4fa1a1SMauro Carvalho Chehab void 1899d4fa1a1SMauro Carvalho Chehab ia_css_rx_port_get_irq_info(enum mipi_port_id port, unsigned int *irq_bits); 1909d4fa1a1SMauro Carvalho Chehab 1919d4fa1a1SMauro Carvalho Chehab /* @brief Clear CSI receiver error info. 1929d4fa1a1SMauro Carvalho Chehab * 1939d4fa1a1SMauro Carvalho Chehab * @param[in] irq_bits The bits that should be cleared from the CSI receiver 1949d4fa1a1SMauro Carvalho Chehab * interrupt bits register. 1959d4fa1a1SMauro Carvalho Chehab * @return None 1969d4fa1a1SMauro Carvalho Chehab * 1979d4fa1a1SMauro Carvalho Chehab * This function should be called after ia_css_rx_get_irq_info has been called 1989d4fa1a1SMauro Carvalho Chehab * and the error bits have been interpreted. It is advised to use the return 1999d4fa1a1SMauro Carvalho Chehab * value of that function as the argument to this function to make sure no new 2009d4fa1a1SMauro Carvalho Chehab * error bits get overwritten. 2019d4fa1a1SMauro Carvalho Chehab * 2029d4fa1a1SMauro Carvalho Chehab * @deprecated{this function is DEPRECATED since it only works on CSI port 1. 2039d4fa1a1SMauro Carvalho Chehab * Use the function below instead and specify the appropriate port.} 2049d4fa1a1SMauro Carvalho Chehab */ 2059d4fa1a1SMauro Carvalho Chehab void 2069d4fa1a1SMauro Carvalho Chehab ia_css_rx_clear_irq_info(unsigned int irq_bits); 2079d4fa1a1SMauro Carvalho Chehab 2089d4fa1a1SMauro Carvalho Chehab /* @brief Clear CSI receiver error info. 2099d4fa1a1SMauro Carvalho Chehab * 2109d4fa1a1SMauro Carvalho Chehab * @param[in] port Input port identifier. 2119d4fa1a1SMauro Carvalho Chehab * @param[in] irq_bits The bits that should be cleared from the CSI receiver 2129d4fa1a1SMauro Carvalho Chehab * interrupt bits register. 2139d4fa1a1SMauro Carvalho Chehab * @return None 2149d4fa1a1SMauro Carvalho Chehab * 2159d4fa1a1SMauro Carvalho Chehab * This function should be called after ia_css_rx_get_irq_info has been called 2169d4fa1a1SMauro Carvalho Chehab * and the error bits have been interpreted. It is advised to use the return 2179d4fa1a1SMauro Carvalho Chehab * value of that function as the argument to this function to make sure no new 2189d4fa1a1SMauro Carvalho Chehab * error bits get overwritten. 2199d4fa1a1SMauro Carvalho Chehab */ 2209d4fa1a1SMauro Carvalho Chehab void 2219d4fa1a1SMauro Carvalho Chehab ia_css_rx_port_clear_irq_info(enum mipi_port_id port, unsigned int irq_bits); 2229d4fa1a1SMauro Carvalho Chehab 2239d4fa1a1SMauro Carvalho Chehab /* @brief Enable or disable specific interrupts. 2249d4fa1a1SMauro Carvalho Chehab * 2259d4fa1a1SMauro Carvalho Chehab * @param[in] type The interrupt type that will be enabled/disabled. 2269d4fa1a1SMauro Carvalho Chehab * @param[in] enable enable or disable. 2279d4fa1a1SMauro Carvalho Chehab * @return Returns IA_CSS_INTERNAL_ERROR if this interrupt 2289d4fa1a1SMauro Carvalho Chehab * type cannot be enabled/disabled which is true for 2299d4fa1a1SMauro Carvalho Chehab * CSS internal interrupts. Otherwise returns 23041022d35SMauro Carvalho Chehab * 0. 2319d4fa1a1SMauro Carvalho Chehab */ 23241022d35SMauro Carvalho Chehab int 2339d4fa1a1SMauro Carvalho Chehab ia_css_irq_enable(enum ia_css_irq_info type, bool enable); 2349d4fa1a1SMauro Carvalho Chehab 2359d4fa1a1SMauro Carvalho Chehab #endif /* __IA_CSS_IRQ_H */ 236