Home | History | Annotate | Line # | Download | only in loongson
      1 /*	$NetBSD: loongson_intr.h,v 1.2 2014/03/29 19:28:28 christos Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _LOONGSON_INTR_H_
     33 #define	_LOONGSON_INTR_H_
     34 
     35 #include <machine/intr.h>
     36 #include <mips/bonito/bonitoreg.h>
     37 #include <sys/evcnt.h>
     38 
     39 LIST_HEAD(bonito_intrhand_head, evbmips_intrhand);
     40 
     41 struct bonito_intrhead {
     42 	struct evcnt intr_count;
     43 	struct bonito_intrhand_head intrhand_head;
     44 	int refcnt;
     45 };
     46 extern struct bonito_intrhead bonito_intrhead[BONITO_NINTS];
     47 
     48 /* interrupt mappings */
     49 struct bonito_irqmap {
     50 	const char *name;
     51 	uint8_t irqidx;
     52 	uint8_t flags;
     53 };
     54 
     55 #define IRQ_F_INVERT	0x80	/* invert polarity */
     56 #define IRQ_F_EDGE	0x40	/* edge trigger */
     57 #define IRQ_F_INT0	0x00	/* INT0 */
     58 #define IRQ_F_INT1	0x01	/* INT1 */
     59 #define IRQ_F_INT2	0x02	/* INT2 */
     60 #define IRQ_F_INT3	0x03	/* INT3 */
     61 #define IRQ_F_INTMASK	0x07	/* INT mask */
     62 
     63 extern const struct bonito_irqmap loongson2e_irqmap[BONITO_NDIRECT];
     64 extern const struct bonito_irqmap loongson2f_irqmap[BONITO_NDIRECT];
     65 
     66 int	loongson_pci_intr_map(const struct pci_attach_args *,
     67 	    pci_intr_handle_t *);
     68 const char *loongson_pci_intr_string(void *, pci_intr_handle_t, char *, size_t);
     69 const struct evcnt *loongson_pci_intr_evcnt(void *, pci_intr_handle_t);
     70 void *	loongson_pci_intr_establish(void *, pci_intr_handle_t, int,
     71 	    int (*)(void *), void *);
     72 void	loongson_pci_intr_disestablish(void *, void *);
     73 void	loongson_pci_conf_interrupt(void *, int, int, int, int, int *);
     74 void *	loongson_pciide_compat_intr_establish(void *,
     75 	    device_t, const struct pci_attach_args *, int,
     76 	    int (*)(void *), void *);
     77 
     78 const char *loongson_intr_string(const struct bonito_config *, int, char *, size_t);
     79 #endif /* ! _LOONGSON_INTR_H_ */
     80