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