1/*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 */
18#ifndef __HI_COMM_IRQ_H__
19#define __HI_COMM_IRQ_H__
20#include "hi_defines.h"
21
22/* For IRQ */
23#define HI_MAX_STATE_NUM       1
24
25typedef enum {
26    HI_INT_NORMAL = 0,
27    HI_INT_VICAP  = 1,
28    HI_INT_SCD    = 2,
29    HI_INT_VDH    = 3,
30    HI_INT_NNIE   = 4,
31    HI_INT_AIO    = 5,
32    HI_INT_BUTT,
33} hi_int_type;
34
35typedef struct {
36    volatile hi_u32 state_num;                    /* Number of interrupt states */
37    volatile hi_u32 raw_state[HI_MAX_STATE_NUM];  /* raw interrupt states */
38    volatile hi_u32 mask_state[HI_MAX_STATE_NUM]; /* interrupt states after mask */
39} hi_normal_int_state;
40
41typedef struct {
42    volatile unsigned int cap_state;
43    volatile unsigned int pt_state[VI_MAX_DEV_NUM];
44    volatile unsigned int ch_state[VI_MAX_PHY_PIPE_NUM];
45    volatile unsigned int isp_fe_state[VI_MAX_ISP_FE_NUM];
46} hi_vicap_int_state;
47
48typedef struct {
49    unsigned int aio_int_status_state;
50    unsigned int aio_int_raw_state;
51    unsigned int tx_raw_state[AO_DEV_MAX_NUM];
52    unsigned int tx_stat_state[AO_DEV_MAX_NUM];
53    unsigned int rx_raw_state[AI_DEV_MAX_NUM];
54    unsigned int rx_stat_state[AI_DEV_MAX_NUM];
55} hi_aio_int_state;
56
57typedef struct {
58    hi_int_type type;
59    union {
60        hi_normal_int_state normal;
61        hi_vicap_int_state  vicap;
62        hi_aio_int_state    aio;
63    };
64} hi_int_state_info;
65
66typedef struct {
67    hi_void *dev;
68    hi_int_state_info int_info;
69} hi_irq_arg;
70
71
72typedef struct {
73    unsigned int cap_reg;
74    unsigned int pt_reg[VI_MAX_DEV_NUM];
75    unsigned int ch_reg[VI_MAX_PHY_PIPE_NUM];
76    unsigned int isp_fe_reg[VI_MAX_ISP_FE_NUM];
77} hi_vicap_int_reg;
78
79typedef struct {
80    unsigned int aio_int_status_reg;
81    unsigned int aio_int_raw_reg;
82    unsigned int tx_clr_reg[AO_DEV_MAX_NUM];
83    unsigned int tx_raw_reg[AO_DEV_MAX_NUM];
84    unsigned int tx_stat_reg[AO_DEV_MAX_NUM];
85    unsigned int rx_clr_reg[AI_DEV_MAX_NUM];
86    unsigned int rx_raw_reg[AI_DEV_MAX_NUM];
87    unsigned int rx_stat_reg[AI_DEV_MAX_NUM];
88} hi_aio_int_reg;
89
90
91typedef struct {
92    unsigned int reg_num;
93    unsigned int raw_int_reg[HI_MAX_STATE_NUM];   /* raw int state */
94    unsigned int mask_int_reg[HI_MAX_STATE_NUM];  /* int state after mask */
95    unsigned int clr_int_reg[HI_MAX_STATE_NUM];
96} hi_normal_int_reg;
97
98typedef struct {
99    hi_int_type type;
100    union {
101        hi_normal_int_reg normal;
102        hi_vicap_int_reg  vicap;
103        hi_aio_int_reg    aio;
104    };
105} hi_int_reg_info;
106
107#endif /* end of #ifndef __HI_COMM_IRQ_H__ */
108
109