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