xref: /netbsd-src/sys/arch/mips/rmi/rmixl_intr.h (revision 7c284c02ea4e86a3972778bbcbf3c05464450272)
1*7c284c02Scliff /*	$NetBSD: rmixl_intr.h,v 1.3 2011/04/14 05:16:28 cliff Exp $	*/
23e67b512Smatt /*-
33e67b512Smatt  * Copyright (c) 2010 The NetBSD Foundation, Inc.
43e67b512Smatt  * All rights reserved.
53e67b512Smatt  *
63e67b512Smatt  * This code is derived from software contributed to The NetBSD Foundation
73e67b512Smatt  * by Cliff Neighbors.
83e67b512Smatt  *
93e67b512Smatt  * Redistribution and use in source and binary forms, with or without
103e67b512Smatt  * modification, are permitted provided that the following conditions
113e67b512Smatt  * are met:
123e67b512Smatt  * 1. Redistributions of source code must retain the above copyright
133e67b512Smatt  *    notice, this list of conditions and the following disclaimer.
143e67b512Smatt  * 2. Redistributions in binary form must reproduce the above copyright
153e67b512Smatt  *    notice, this list of conditions and the following disclaimer in the
163e67b512Smatt  *    documentation and/or other materials provided with the distribution.
173e67b512Smatt  *
183e67b512Smatt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
193e67b512Smatt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
203e67b512Smatt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
213e67b512Smatt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
223e67b512Smatt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
233e67b512Smatt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
243e67b512Smatt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
253e67b512Smatt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
263e67b512Smatt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
273e67b512Smatt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
283e67b512Smatt  * POSSIBILITY OF SUCH DAMAGE.
293e67b512Smatt  */
303e67b512Smatt 
313e67b512Smatt #ifndef _MIPS_RMI_RMIXL_INTR_H_
323e67b512Smatt #define _MIPS_RMI_RMIXL_INTR_H_
333e67b512Smatt 
343e67b512Smatt #ifdef _KERNEL_OPT
353e67b512Smatt #include "opt_multiprocessor.h"
363e67b512Smatt #endif
373e67b512Smatt 
383e67b512Smatt /*
393e67b512Smatt  * A 'vector' is bit number in EIRR/EIMR
403e67b512Smatt  * - non-IRT-based interrupts use vectors 0..31
413e67b512Smatt  * - IRT-based interrupts use vectors 32..63
423e67b512Smatt  * - RMIXL_VECTOR_IRT(vec) is used to index into the IRT
433e67b512Smatt  * - IRT entry n always routes to vector RMIXL_IRT_VECTOR(n)
443e67b512Smatt  * - only 1 intrhand_t per vector
453e67b512Smatt  */
463e67b512Smatt #define	NINTRVECS	64	/* bit width of the EIRR */
473e67b512Smatt #define	NIRTS		32	/* #entries in the Interrupt Redirection Table */
483e67b512Smatt 
493e67b512Smatt /*
503e67b512Smatt  * mapping between IRT index and vector number
513e67b512Smatt  */
523e67b512Smatt #define RMIXL_VECTOR_IS_IRT(vec)	((vec) >= 32)
533e67b512Smatt #define RMIXL_IRT_VECTOR(irt)		((irt) + 32)
543e67b512Smatt #define RMIXL_VECTOR_IRT(vec)		((vec) - 32)
553e67b512Smatt 
563e67b512Smatt /*
573e67b512Smatt  * vectors (0 <= vec < 8)  are CAUSE[8..15] (including softintrs and count/compare)
583e67b512Smatt  * vectors (8 <= vec < 31) are for other non-IRT based interrupts
59*7c284c02Scliff  * we use one for FMN, and each IPI currently gets own vector;
60*7c284c02Scliff  * if NIPIS >= (32 - 8 - 1), then redesign so IPIs share vector(s)
613e67b512Smatt  */
62*7c284c02Scliff #if NIPIS >= 23
63*7c284c02Scliff # error too many IPIs
64*7c284c02Scliff #endif
653e67b512Smatt #define RMIXL_INTRVEC_IPI	8
663e67b512Smatt #define RMIXL_INTRVEC_FMN	(RMIXL_INTRVEC_IPI + NIPIS)
673e67b512Smatt 
683e67b512Smatt typedef enum {
693e67b512Smatt 	RMIXL_TRIG_NONE=0,
703e67b512Smatt 	RMIXL_TRIG_EDGE,
713e67b512Smatt 	RMIXL_TRIG_LEVEL,
723e67b512Smatt } rmixl_intr_trigger_t;
733e67b512Smatt 
743e67b512Smatt typedef enum {
753e67b512Smatt 	RMIXL_POLR_NONE=0,
763e67b512Smatt 	RMIXL_POLR_RISING,
773e67b512Smatt 	RMIXL_POLR_HIGH,
783e67b512Smatt 	RMIXL_POLR_FALLING,
793e67b512Smatt 	RMIXL_POLR_LOW,
803e67b512Smatt } rmixl_intr_polarity_t;
813e67b512Smatt 
823e67b512Smatt 
833e67b512Smatt /*
843e67b512Smatt  * iv_list and ref count manage sharing of each vector
853e67b512Smatt  */
863e67b512Smatt typedef struct rmixl_intrhand {
873e67b512Smatt         int (*ih_func)(void *);
883e67b512Smatt         void *ih_arg;
893e67b512Smatt         int ih_mpsafe; 			/* true if does not need kernel lock */
903e67b512Smatt         int ih_vec;			/* vector is bit number in EIRR/EIMR */
913e67b512Smatt         int ih_ipl; 			/* interrupt priority */
923e67b512Smatt         int ih_cpumask; 		/* CPUs which may handle this irpt */
933e67b512Smatt } rmixl_intrhand_t;
943e67b512Smatt 
953e67b512Smatt /*
963e67b512Smatt  * stuff exported from rmixl_spl.S
973e67b512Smatt  */
983e67b512Smatt extern const struct splsw rmixl_splsw;
993e67b512Smatt extern uint64_t ipl_eimr_map[];
1003e67b512Smatt 
1013e67b512Smatt extern void *rmixl_intr_establish(int, int, int,
1023e67b512Smatt 	rmixl_intr_trigger_t, rmixl_intr_polarity_t,
1033e67b512Smatt 	int (*)(void *), void *, bool);
1043e67b512Smatt extern void  rmixl_intr_disestablish(void *);
1053e67b512Smatt extern void *rmixl_vec_establish(int, int, int,
1063e67b512Smatt 	int (*)(void *), void *, bool);
1073e67b512Smatt extern void  rmixl_vec_disestablish(void *);
1083e67b512Smatt extern const char *rmixl_intr_string(int);
1093e67b512Smatt extern void rmixl_intr_init_cpu(struct cpu_info *);
1103e67b512Smatt extern void rmixl_intr_init_clk(void);
1113e67b512Smatt #ifdef MULTIPROCESSOR
1123e67b512Smatt extern void rmixl_intr_init_ipi(void);
1133e67b512Smatt #endif
1143e67b512Smatt 
1153e67b512Smatt #endif	/* _MIPS_RMI_RMIXL_INTR_H_ */
116