Home | History | Annotate | Line # | Download | only in rmi
rmixl_intr.h revision 1.1.2.4
      1 /*	$NetBSD: rmixl_intr.h,v 1.1.2.4 2010/05/21 23:35:42 cliff 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 /*
     35  * A 'vector' is bit number in EIRR/EIMR
     36  * - non-IRT-based interrupts use vectors 0..31
     37  * - IRT-based interrupts use vectors 32..63
     38  * - RMIXL_VECTOR_IRT(vec) is used to index into the IRT
     39  * - IRT entry n always routes to vector RMIXL_IRT_VECTOR(n)
     40  * - only 1 intrhand_t per vector
     41  */
     42 #define	NINTRVECS	64	/* bit width of the EIRR */
     43 #define	NIRTS		32	/* #entries in the Interrupt Redirection Table */
     44 
     45 /*
     46  * mapping between IRT index and vector number
     47  */
     48 #define RMIXL_VECTOR_IS_IRT(vec)	((vec) >= 32)
     49 #define RMIXL_IRT_VECTOR(irt)		((irt) + 32)
     50 #define RMIXL_VECTOR_IRT(vec)		((vec) - 32)
     51 
     52 /*
     53  * vectors (0 <= vec < 8)  are CAUSE[8..15] (including softintrs and count/compare)
     54  * vectors (8 <= vec < 31) are for other non-IRT based interrupts
     55  */
     56 #define RMIXL_INTRVEC_IPI	8
     57 #define RMIXL_INTRVEC_FMN	9
     58 
     59 typedef enum {
     60 	RMIXL_TRIG_NONE=0,
     61 	RMIXL_TRIG_EDGE,
     62 	RMIXL_TRIG_LEVEL,
     63 } rmixl_intr_trigger_t;
     64 
     65 typedef enum {
     66 	RMIXL_POLR_NONE=0,
     67 	RMIXL_POLR_RISING,
     68 	RMIXL_POLR_HIGH,
     69 	RMIXL_POLR_FALLING,
     70 	RMIXL_POLR_LOW,
     71 } rmixl_intr_polarity_t;
     72 
     73 
     74 /*
     75  * iv_list and ref count manage sharing of each vector
     76  */
     77 typedef struct rmixl_intrhand {
     78         int (*ih_func)(void *);
     79         void *ih_arg;
     80         int ih_mpsafe; 			/* true if does not need kernel lock */
     81         int ih_vec;			/* vector is bit number in EIRR/EIMR */
     82         int ih_ipl; 			/* interrupt priority */
     83         int ih_cpumask; 		/* CPUs which may handle this irpt */
     84 } rmixl_intrhand_t;
     85 
     86 /*
     87  * stuff exported from rmixl_spl.S
     88  */
     89 extern const struct splsw rmixl_splsw;
     90 extern uint64_t ipl_eimr_map[];
     91 
     92 extern void *rmixl_intr_establish(int, int, int,
     93 	rmixl_intr_trigger_t, rmixl_intr_polarity_t,
     94 	int (*)(void *), void *, bool);
     95 extern void  rmixl_intr_disestablish(void *);
     96 extern void *rmixl_vec_establish(int, int, int,
     97 	int (*)(void *), void *, bool);
     98 extern void  rmixl_vec_disestablish(void *);
     99 extern const char *rmixl_intr_string(int);
    100 extern void rmixl_intr_init_cpu(struct cpu_info *);
    101 extern void *rmixl_intr_init_clk(void);
    102 #ifdef MULTIPROCESSOR
    103 extern void *rmixl_intr_init_ipi(void);
    104 #endif
    105 
    106 #endif	/* _MIPS_RMI_RMIXL_INTR_H_ */
    107