rmixl_intr.h revision 1.1.2.11 1 /* $NetBSD: rmixl_intr.h,v 1.1.2.11 2011/12/31 08:20:43 matt Exp $ */
2 /*-
3 * Copyright (c) 2010 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Cliff Neighbors.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef _MIPS_RMI_RMIXL_INTR_H_
32 #define _MIPS_RMI_RMIXL_INTR_H_
33
34 #ifdef _KERNEL_OPT
35 #include "opt_multiprocessor.h"
36 #endif
37
38 /*
39 * A 'vector' is bit number in EIRR/EIMR
40 * - IRT or non-IRT interrupts use vectors 8..63
41 * - vector or dynamically assigned (except for IPI and FMN)
42 */
43 #define NINTRVECS 64 /* bit width of the EIRR */
44 #define RMIXLP_NIRTS 160 /* #entries in Interrupt Redirection Table */
45 #define RMIXLR_NIRTS 32 /* #entries in Interrupt Redirection Table */
46 #define RMIXLS_NIRTS 32 /* #entries in Interrupt Redirection Table */
47
48 /*
49 * vectors (0 <= vec < 8) are CAUSE[8..15] (including softintrs and count/compare)
50 */
51 #define RMIXL_INTRVEC_IPI 8
52 #define RMIXL_INTRVEC_FMN (RMIXL_INTRVEC_IPI + NIPIS)
53
54 /*
55 * iv_list and ref count manage sharing of each vector
56 */
57 typedef struct rmixl_intrhand {
58 LIST_ENTRY(rmixl_intrhand) ih_link;
59 int (*ih_func)(void *);
60 void *ih_arg;
61 bool ih_mpsafe; /* true if does not need kernel lock */
62 uint8_t ih_vec; /* vector is bit number in EIRR/EIMR */
63 } rmixl_intrhand_t;
64
65 typedef struct rmixl_intrvec {
66 LIST_HEAD(, rmixl_intrhand) iv_hands;
67 TAILQ_ENTRY(rmixl_intrvec) iv_lruq_link;
68 rmixl_intrhand_t iv_intrhand;
69 uint8_t iv_ipl; /* interrupt priority */
70 } rmixl_intrvec_t;
71
72 typedef TAILQ_HEAD(rmixl_intrvecq, rmixl_intrvec) rmixl_intrvecq_t;
73
74 /*
75 * stuff exported from rmixl_spl.S
76 */
77 extern const struct splsw rmixl_splsw;
78 extern uint64_t ipl_eimr_map[];
79
80 void * rmixl_intr_establish(size_t /* irt */, int /* ipl */, int /* ist */,
81 int (*)(void *), void *, bool);
82 void rmixl_intr_disestablish(void *);
83 void * rmixl_vec_establish(size_t /* vec */, rmixl_intrhand_t *, int /* ipl */,
84 int (*)(void *), void *, bool);
85 void rmixl_vec_disestablish(void *);
86 const char *
87 rmixl_intr_string(size_t);
88 const char *
89 rmixl_irt_string(size_t);
90 void rmixl_intr_init_cpu(struct cpu_info *);
91 void rmixl_intr_init_clk(void);
92 #ifdef MULTIPROCESSOR
93 void rmixl_intr_init_ipi(void);
94 #endif
95
96 void * gpio_intr_establish(size_t /* pin */, int /* ipl */, int /* ist */,
97 int (*)(void *), void *, bool);
98
99 void gpio_intr_disestablish(void *);
100 #endif /* _MIPS_RMI_RMIXL_INTR_H_ */
101