GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_include / host / irq_public.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14
15 #ifndef __IRQ_PUBLIC_H_INCLUDED__
16 #define __IRQ_PUBLIC_H_INCLUDED__
17
18 #include <type_support.h>
19 #include "system_types.h"
20
21 /*! Read the control registers of IRQ[ID]
22
23  \param ID[in]                          IRQ identifier
24  \param state[out]                      irq controller state structure
25
26  \return none, state = IRQ[ID].state
27  */
28 extern void irq_controller_get_state(
29         const irq_ID_t                          ID,
30         irq_controller_state_t          *state);
31
32 /*! Write to a control register of IRQ[ID]
33
34  \param ID[in]                          IRQ identifier
35  \param reg[in]                         register index
36  \param value[in]                       The data to be written
37
38  \return none, IRQ[ID].ctrl[reg] = value
39  */
40 STORAGE_CLASS_IRQ_H void irq_reg_store(
41         const irq_ID_t          ID,
42         const unsigned int      reg,
43         const hrt_data          value);
44
45 /*! Read from a control register of IRQ[ID]
46
47  \param ID[in]                          IRQ identifier
48  \param reg[in]                         register index
49  \param value[in]                       The data to be written
50
51  \return IRQ[ID].ctrl[reg]
52  */
53 STORAGE_CLASS_IRQ_H hrt_data irq_reg_load(
54         const irq_ID_t          ID,
55         const unsigned int      reg);
56
57 /*! Enable an IRQ channel of IRQ[ID] with a mode
58
59  \param ID[in]                          IRQ (device) identifier
60  \param irq[in]                         IRQ (channel) identifier
61
62  \return none, enable(IRQ[ID].channel[irq_ID])
63  */
64 extern void irq_enable_channel(
65         const irq_ID_t                          ID,
66         const unsigned int                      irq_ID);
67
68 /*! Enable pulse interrupts for IRQ[ID] with a mode
69
70  \param ID[in]                          IRQ (device) identifier
71  \param enable                          enable/disable pulse interrupts
72
73  \return none
74  */
75 extern void irq_enable_pulse(
76         const irq_ID_t  ID,
77         bool                    pulse);
78
79 /*! Disable an IRQ channel of IRQ[ID]
80
81  \param ID[in]                          IRQ (device) identifier
82  \param irq[in]                         IRQ (channel) identifier
83
84  \return none, disable(IRQ[ID].channel[irq_ID])
85  */
86 extern void irq_disable_channel(
87         const irq_ID_t                          ID,
88         const unsigned int                      irq);
89
90 /*! Clear the state of all IRQ channels of IRQ[ID]
91
92  \param ID[in]                          IRQ (device) identifier
93
94  \return none, clear(IRQ[ID].channel[])
95  */
96 extern void irq_clear_all(
97         const irq_ID_t                          ID);
98
99 /*! Return the ID of a signalling IRQ channel of IRQ[ID]
100
101  \param ID[in]                          IRQ (device) identifier
102  \param irq_id[out]                     active IRQ (channel) identifier
103
104  \Note: This function operates as strtok(), based on the return
105   state the user is informed if there are additional signalling
106   channels
107
108  \return state(IRQ[ID])
109  */
110 extern enum hrt_isp_css_irq_status irq_get_channel_id(
111         const irq_ID_t                          ID,
112         unsigned int                            *irq_id);
113
114 /*! Raise an interrupt on channel irq_id of device IRQ[ID]
115
116  \param ID[in]                          IRQ (device) identifier
117  \param irq_id[in]                      IRQ (channel) identifier
118
119  \return none, signal(IRQ[ID].channel[irq_id])
120  */
121 extern void irq_raise(
122         const irq_ID_t                          ID,
123         const irq_sw_channel_id_t       irq_id);
124
125 /*! Test if any IRQ channel of the virtual super IRQ has raised a signal
126
127  \return any(VIRQ.channel[irq_ID] != 0)
128  */
129 extern bool any_virq_signal(void);
130
131 /*! Enable an IRQ channel of the virtual super IRQ
132
133  \param irq[in]                         IRQ (channel) identifier
134  \param en[in]                          predicate channel enable
135
136  \return none, VIRQ.channel[irq_ID].enable = en
137  */
138 extern void cnd_virq_enable_channel(
139         const virq_id_t                         irq_ID,
140         const bool                                      en);
141
142 /*! Clear the state of all IRQ channels of the virtual super IRQ
143
144  \return none, clear(VIRQ.channel[])
145  */
146 extern void virq_clear_all(void);
147
148 /*! Clear the IRQ info state of the virtual super IRQ
149
150  \param irq_info[in/out]        The IRQ (channel) state
151
152  \return none
153  */
154 extern void virq_clear_info(
155         virq_info_t                                     *irq_info);
156
157 /*! Return the ID of a signalling IRQ channel of the virtual super IRQ
158
159  \param irq_id[out]                     active IRQ (channel) identifier
160
161  \Note: This function operates as strtok(), based on the return
162   state the user is informed if there are additional signalling
163   channels
164
165  \return state(IRQ[...])
166  */
167 extern enum hrt_isp_css_irq_status virq_get_channel_id(
168         virq_id_t                                       *irq_id);
169
170 /*! Return the IDs of all signaling IRQ channels of the virtual super IRQ
171
172  \param irq_info[out]           all active IRQ (channel) identifiers
173
174  \Note: Unlike "irq_get_channel_id()" this function returns all
175   channel signaling info. The new info is OR'd with the current
176   info state. N.B. this is the same as repeatedly calling the function
177   "irq_get_channel_id()" in a (non-blocked) handler routine
178
179  \return (error(state(IRQ[...]))
180  */
181 extern enum hrt_isp_css_irq_status virq_get_channel_signals(
182         virq_info_t                                     *irq_info);
183
184 #endif /* __IRQ_PUBLIC_H_INCLUDED__ */