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 __IRQ_PUBLIC_H_INCLUDED__
17 #define __IRQ_PUBLIC_H_INCLUDED__
18 
19 #include <type_support.h>
20 #include "system_local.h"
21 
22 /*! Write to a control register of IRQ[ID]
23 
24  \param	ID[in]				IRQ identifier
25  \param	reg[in]				register index
26  \param value[in]			The data to be written
27 
28  \return none, IRQ[ID].ctrl[reg] = value
29  */
30 STORAGE_CLASS_IRQ_H void irq_reg_store(
31     const irq_ID_t		ID,
32     const unsigned int	reg,
33     const hrt_data		value);
34 
35 /*! Read from a control register of IRQ[ID]
36 
37  \param	ID[in]				IRQ identifier
38  \param	reg[in]				register index
39  \param value[in]			The data to be written
40 
41  \return IRQ[ID].ctrl[reg]
42  */
43 STORAGE_CLASS_IRQ_H hrt_data irq_reg_load(
44     const irq_ID_t		ID,
45     const unsigned int	reg);
46 
47 /*! Enable an IRQ channel of IRQ[ID] with a mode
48 
49  \param	ID[in]				IRQ (device) identifier
50  \param	irq[in]				IRQ (channel) identifier
51 
52  \return none, enable(IRQ[ID].channel[irq_ID])
53  */
54 void irq_enable_channel(
55     const irq_ID_t				ID,
56     const unsigned int			irq_ID);
57 
58 /*! Enable pulse interrupts for IRQ[ID] with a mode
59 
60  \param	ID[in]				IRQ (device) identifier
61  \param	enable				enable/disable pulse interrupts
62 
63  \return none
64  */
65 void irq_enable_pulse(
66     const irq_ID_t	ID,
67     bool			pulse);
68 
69 /*! Disable an IRQ channel of IRQ[ID]
70 
71  \param	ID[in]				IRQ (device) identifier
72  \param	irq[in]				IRQ (channel) identifier
73 
74  \return none, disable(IRQ[ID].channel[irq_ID])
75  */
76 void irq_disable_channel(
77     const irq_ID_t				ID,
78     const unsigned int			irq);
79 
80 /*! Clear the state of all IRQ channels of IRQ[ID]
81 
82  \param	ID[in]				IRQ (device) identifier
83 
84  \return none, clear(IRQ[ID].channel[])
85  */
86 void irq_clear_all(
87     const irq_ID_t				ID);
88 
89 /*! Return the ID of a signalling IRQ channel of IRQ[ID]
90 
91  \param	ID[in]				IRQ (device) identifier
92  \param irq_id[out]			active IRQ (channel) identifier
93 
94  \Note: This function operates as strtok(), based on the return
95   state the user is informed if there are additional signalling
96   channels
97 
98  \return state(IRQ[ID])
99  */
100 enum hrt_isp_css_irq_status irq_get_channel_id(
101     const irq_ID_t				ID,
102     unsigned int				*irq_id);
103 
104 /*! Raise an interrupt on channel irq_id of device IRQ[ID]
105 
106  \param	ID[in]				IRQ (device) identifier
107  \param	irq_id[in]			IRQ (channel) identifier
108 
109  \return none, signal(IRQ[ID].channel[irq_id])
110  */
111 void irq_raise(
112     const irq_ID_t				ID,
113     const irq_sw_channel_id_t	irq_id);
114 
115 /*! Test if any IRQ channel of the virtual super IRQ has raised a signal
116 
117  \return any(VIRQ.channel[irq_ID] != 0)
118  */
119 bool any_virq_signal(void);
120 
121 /*! Enable an IRQ channel of the virtual super IRQ
122 
123  \param	irq[in]				IRQ (channel) identifier
124  \param	en[in]				predicate channel enable
125 
126  \return none, VIRQ.channel[irq_ID].enable = en
127  */
128 void cnd_virq_enable_channel(
129     const enum virq_id				irq_ID,
130     const bool					en);
131 
132 /*! Clear the state of all IRQ channels of the virtual super IRQ
133 
134  \return none, clear(VIRQ.channel[])
135  */
136 void virq_clear_all(void);
137 
138 /*! Clear the IRQ info state of the virtual super IRQ
139 
140  \param irq_info[in/out]	The IRQ (channel) state
141 
142  \return none
143  */
144 void virq_clear_info(struct virq_info *irq_info);
145 
146 /*! Return the ID of a signalling IRQ channel of the virtual super IRQ
147 
148  \param irq_id[out]			active IRQ (channel) identifier
149 
150  \Note: This function operates as strtok(), based on the return
151   state the user is informed if there are additional signalling
152   channels
153 
154  \return state(IRQ[...])
155  */
156 enum hrt_isp_css_irq_status virq_get_channel_id(
157     enum virq_id					*irq_id);
158 
159 /*! Return the IDs of all signaling IRQ channels of the virtual super IRQ
160 
161  \param irq_info[out]		all active IRQ (channel) identifiers
162 
163  \Note: Unlike "irq_get_channel_id()" this function returns all
164   channel signaling info. The new info is OR'd with the current
165   info state. N.B. this is the same as repeatedly calling the function
166   "irq_get_channel_id()" in a (non-blocked) handler routine
167 
168  \return (error(state(IRQ[...]))
169  */
170 enum hrt_isp_css_irq_status
171 virq_get_channel_signals(struct virq_info *irq_info);
172 
173 #endif /* __IRQ_PUBLIC_H_INCLUDED__ */
174