1 /*        $NetBSD: at91aicvar.h,v 1.5 2012/11/12 18:00:36 skrll Exp $ */
2 
3 /*
4  * Copyright (c) 2007 Embedtronics Oy
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _AT91AICVAR_H_
30 #define _AT91AICVAR_H_
31 
32 struct intrhand {
33           TAILQ_ENTRY(intrhand) ih_list;          /* link on intrq list */
34           int (*ih_func)(void *);                 /* interrupt handler */
35           void *ih_arg;                           /* arg for handler */
36           int ih_ipl;                             /* IPL_* */
37           int ih_irq;                             /* IRQ number */
38 };
39 
40 #define   IRQNAMESIZE         sizeof("aic irq xxx")
41 
42 struct intrq {
43           TAILQ_HEAD(, intrhand) iq_list;         /* handler list */
44           struct evcnt iq_ev;           /* event counter */
45           uint32_t iq_levels;           /* IPL_*'s this IRQ has */
46           char iq_name[IRQNAMESIZE];    /* interrupt name */
47           int iq_type;                            /* interrupt request type: */
48 #define   _INTR_LOW_LEVEL               1                   /* interrupt when signal at low level */
49 #define   INTR_HIGH_LEVEL               2                   /* interrupt when signal at high level */
50 #define   INTR_FALLING_EDGE   4                   /* interrupt on falling edge */
51 #define   INTR_RISING_EDGE    8                   /* interrupt on rising edge */
52 #define   INTR_MASK           0xF
53           volatile int iq_busy;                   /* set if irq is busy */
54 };
55 
56 void at91aic_init(void);
57 void *at91aic_intr_establish(int irq, int ipl, int type, int (*ih_func)(void *), void *arg);
58 void at91aic_intr_disestablish(void *cookie);
59 void at91aic_intr_poll(void *ihp, int flags);
60 void at91aic_intr_dispatch(struct trapframe *frame);
61 
62 #endif /* _AT91AICVAR_H_ */
63