summaryrefslogtreecommitdiffstats
path: root/sys/mips/beri/fdt_ic_if.m
blob: e11b8f87c81de94ea2e5374a17efea553815385c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#-
# Copyright (c) 2013 SRI International
# Copyright (c) 1998-2004 Doug Rabson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

#include <sys/types.h>
#include <sys/systm.h>
#include <sys/bus.h>

/**
 * @defgroup FST_IC fdt_ic - KObj methods for interrupt controllers
 * @brief A set of methods required device drivers that are interrupt
 * controllers.  Derived from sys/kern/bus_if.m.
 * @{
 */
INTERFACE fdt_ic;

/**
 * @brief Allocate an interrupt resource
 *
 * This method is called by child devices of an interrupt controller to
 * allocate an interrup. The meaning of the resource-ID field varies
 * from bus to bus and is opaque to the interrupt controller. If a
 * resource was allocated and the caller did not use the RF_ACTIVE
 * to specify that it should be activated immediately, the caller is
 * responsible for calling FDT_IC_ACTIVATE_INTR() when it actually uses
 * the interupt.
 *
 * @param _dev		the interrupt-parent device of @p _child
 * @param _child	the device which is requesting an allocation
 * @param _rid		a pointer to the resource identifier
 * @param _irq		interrupt source to allocate
 * @param _flags	any extra flags to control the resource
 *			allocation - see @c RF_XXX flags in
 *			<sys/rman.h> for details
 * 
 * @returns		the interrupt which was allocated or @c NULL if no
 *			resource could be allocated
 */
METHOD struct resource * alloc_intr {
	device_t	_dev;
	device_t	_child;
	int	       *_rid;
	u_long		_irq;
	u_int		_flags;
};

/**
 * @brief Activate an interrupt
 *
 * Activate an interrupt previously allocated with FDT_IC_ALLOC_INTR().
 *
 * @param _dev		the parent device of @p _child
 * @param _r		interrupt to activate
 */
METHOD int activate_intr {
	device_t	_dev;
	struct resource *_r;
};

/**
 * @brief Deactivate an interrupt
 *
 * Deactivate a resource previously allocated with FDT_IC_ALLOC_INTR().
 *
 * @param _dev		the parent device of @p _child
 * @param _r		the interrupt to deactivate
 */
METHOD int deactivate_intr {
	device_t	_dev;
	struct resource *_r;
};

/**
 * @brief Release an interrupt
 *
 * Free an interupt allocated by the FDT_IC_ALLOC_INTR.
 *
 * @param _dev		the parent device of @p _child
 * @param _r		the resource to release
 */
METHOD int release_intr {
	device_t	_dev;
	struct resource *_res;
};

/**
 * @brief Install an interrupt handler
 *
 * This method is used to associate an interrupt handler function with
 * an irq resource. When the interrupt triggers, the function @p _intr
 * will be called with the value of @p _arg as its single
 * argument. The value returned in @p *_cookiep is used to cancel the
 * interrupt handler - the caller should save this value to use in a
 * future call to FDT_IC_TEARDOWN_INTR().
 * 
 * @param _dev		the interrupt-parent device of @p _child
 * @param _child	the device which allocated the resource
 * @param _irq		the resource representing the interrupt
 * @param _flags	a set of bits from enum intr_type specifying
 *			the class of interrupt
 * @param _intr		the function to call when the interrupt
 *			triggers
 * @param _arg		a value to use as the single argument in calls
 *			to @p _intr
 * @param _cookiep	a pointer to a location to recieve a cookie
 *			value that may be used to remove the interrupt
 *			handler
 */
METHOD int setup_intr {
	device_t	_dev;
	device_t	_child;
	struct resource *_irq;
	int		_flags;
	driver_filter_t	*_filter;
	driver_intr_t	*_intr;
	void		*_arg;
	void		**_cookiep;
};

/**
 * @brief Uninstall an interrupt handler
 *
 * This method is used to disassociate an interrupt handler function
 * with an irq resource. The value of @p _cookie must be the value
 * returned from a previous call to FDT_IC_SETUP_INTR().
 * 
 * @param _dev		the interrupt-parent device of @p _child
 * @param _child	the device which allocated the resource
 * @param _irq		the resource representing the interrupt
 * @param _cookie	the cookie value returned when the interrupt
 *			was originally registered
 */
METHOD int teardown_intr {
	device_t	_dev;
	device_t	_child;
	struct resource	*_irq;
	void		*_cookie;
};

/**
 * @brief Allow drivers to request that an interrupt be bound to a specific
 * CPU.
 * 
 * @param _dev		the interrupt-parent device of @p _child
 * @param _child	the device which allocated the resource
 * @param _irq		the resource representing the interrupt
 * @param _cpu		the CPU to bind the interrupt to
 */
METHOD int bind_intr {
	device_t	_dev;
	device_t	_child;
	struct resource *_irq;
	int		_cpu;
};

/**
 * @brief Allow drivers to specify the trigger mode and polarity
 * of the specified interrupt.
 * 
 * @param _dev		the interrupt-parent device
 * @param _irq		the interrupt number to modify
 * @param _trig		the trigger mode required
 * @param _pol		the interrupt polarity required
 */
METHOD int config_intr {
	device_t	_dev;
	int		_irq;
	enum intr_trigger _trig;
	enum intr_polarity _pol;
};

/**
 * @brief Allow drivers to associate a description with an active
 * interrupt handler.
 *
 * @param _dev		the interrupt-parent device of @p _child
 * @param _child	the device which allocated the resource
 * @param _irq		the resource representing the interrupt
 * @param _cookie	the cookie value returned when the interrupt
 *			was originally registered
 * @param _descr	the description to associate with the interrupt
 */
METHOD int describe_intr {
	device_t	_dev;
	device_t	_child;
	struct resource *_irq;
	void		*_cookie;
	const char	*_descr;
};

/**
 * @brief Notify an ic that specified child's IRQ should be remapped.
 *
 * @param _dev		the interrupt-parent device
 * @param _child	the child device
 * @param _irq		the irq number
 */
METHOD int remap_intr {
	device_t	_dev;
	device_t	_child;
	u_int		_irq;
};

/**
 * @brief Enable an IPI source.
 *
 * @param _dev		the interrupt controller
 * @param _tid		the thread ID (relative to the interrupt controller)
 *			to enable IPIs for
 * @param _ipi_irq	hardware IRQ to send IPIs to
 */
METHOD void setup_ipi {
	device_t	_dev;
	u_int		_tid;
	u_int		_irq;
};

/**
 * @brief Send an IPI to the specified thread.
 *
 * @param _dev		the interrupt controller
 * @param _tid		the thread ID (relative to the interrupt controller)
 *			to send IPIs to
 */
METHOD void send_ipi {
	device_t	_dev;
	u_int		_tid;
};

/**
 * @brief Clear the IPI on the specfied thread.  Only call with the
 * local hardware thread or interrupts may be lost!
 *
 * @param _dev		the interrupt controller
 * @param _tid		the thread ID (relative to the interrupt controller)
 *			to clear the IPI on
 */
METHOD void clear_ipi {
	device_t	_dev;
	u_int		_tid;
};
OpenPOWER on IntegriCloud