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