1129198Scognet/* 	$NetBSD: intr.h,v 1.7 2003/06/16 20:01:00 thorpej Exp $	*/
2129198Scognet
3139735Simp/*-
4129198Scognet * Copyright (c) 1997 Mark Brinicombe.
5129198Scognet * All rights reserved.
6129198Scognet *
7129198Scognet * Redistribution and use in source and binary forms, with or without
8129198Scognet * modification, are permitted provided that the following conditions
9129198Scognet * are met:
10129198Scognet * 1. Redistributions of source code must retain the above copyright
11129198Scognet *    notice, this list of conditions and the following disclaimer.
12129198Scognet * 2. Redistributions in binary form must reproduce the above copyright
13129198Scognet *    notice, this list of conditions and the following disclaimer in the
14129198Scognet *    documentation and/or other materials provided with the distribution.
15129198Scognet * 3. All advertising materials mentioning features or use of this software
16129198Scognet *    must display the following acknowledgement:
17129198Scognet *	This product includes software developed by Mark Brinicombe
18129198Scognet *	for the NetBSD Project.
19129198Scognet * 4. The name of the company nor the name of the author may be used to
20129198Scognet *    endorse or promote products derived from this software without specific
21129198Scognet *    prior written permission.
22129198Scognet *
23129198Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24129198Scognet * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25129198Scognet * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26129198Scognet * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27129198Scognet * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28129198Scognet * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29129198Scognet * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33129198Scognet * SUCH DAMAGE.
34129198Scognet *
35129198Scognet * $FreeBSD$
36129198Scognet *
37129198Scognet */
38129198Scognet
39129198Scognet#ifndef _MACHINE_INTR_H_
40129198Scognet#define _MACHINE_INTR_H_
41129198Scognet
42276032Sandrew#ifdef FDT
43276032Sandrew#include <dev/ofw/openfirm.h>
44276032Sandrew#endif
45276032Sandrew
46298068Sandrew#ifdef INTRNG
47289529Sian
48289529Sian#ifndef NIRQ
49289529Sian#define	NIRQ		1024	/* XXX - It should be an option. */
50289529Sian#endif
51289529Sian
52295459Sadrian#include <sys/intr.h>
53289529Sian
54296138Sskra#ifdef SMP
55297539Sskratypedef void intr_ipi_send_t(void *, cpuset_t, u_int);
56297230Sskratypedef void intr_ipi_handler_t(void *);
57296138Sskra
58297230Sskravoid intr_ipi_dispatch(u_int, struct trapframe *);
59297230Sskravoid intr_ipi_send(cpuset_t, u_int);
60296138Sskra
61297230Sskravoid intr_ipi_setup(u_int, const char *, intr_ipi_handler_t *, void *,
62297230Sskra    intr_ipi_send_t *, void *);
63297230Sskra
64297230Sskraint intr_pic_ipi_setup(u_int, const char *, intr_ipi_handler_t *, void *);
65296138Sskra#endif
66298068Sandrew#else /* INTRNG */
67289529Sian
68186352Ssam/* XXX move to std.* files? */
69170827Scognet#ifdef CPU_XSCALE_81342
70170827Scognet#define NIRQ		128
71179595Sbenno#elif defined(CPU_XSCALE_PXA2X0)
72179595Sbenno#include <arm/xscale/pxa/pxareg.h>
73179595Sbenno#define	NIRQ		IRQ_GPIO_MAX
74183840Sraj#elif defined(SOC_MV_DISCOVERY)
75183840Sraj#define NIRQ		96
76186352Ssam#elif defined(CPU_ARM9) || defined(SOC_MV_KIRKWOOD) || \
77186352Ssam    defined(CPU_XSCALE_IXP435)
78141820Scognet#define NIRQ		64
79239268Sgonzo#elif defined(CPU_CORTEXA)
80270884Sbr#define NIRQ		1020
81259640Sganbold#elif defined(CPU_KRAIT)
82259640Sganbold#define NIRQ		288
83280824Sandrew#elif defined(CPU_ARM1176)
84239688Sgonzo#define NIRQ		128
85240488Sgber#elif defined(SOC_MV_ARMADAXP)
86240492Sgber#define MAIN_IRQ_NUM		116
87240492Sgber#define ERR_IRQ_NUM		32
88240492Sgber#define ERR_IRQ			(MAIN_IRQ_NUM)
89240492Sgber#define MSI_IRQ_NUM		32
90240492Sgber#define MSI_IRQ			(ERR_IRQ + ERR_IRQ_NUM)
91240492Sgber#define NIRQ			(MAIN_IRQ_NUM + ERR_IRQ_NUM + MSI_IRQ_NUM)
92141820Scognet#else
93135650Scognet#define NIRQ		32
94141820Scognet#endif
95129198Scognet
96193847Smarcelint arm_get_next_irq(int);
97147166Scognetvoid arm_mask_irq(uintptr_t);
98147166Scognetvoid arm_unmask_irq(uintptr_t);
99245637Sianvoid arm_intrnames_init(void);
100236992Simpvoid arm_setup_irqhandler(const char *, int (*)(void*), void (*)(void*),
101236992Simp    void *, int, int, void **);
102182933Srajint arm_remove_irqhandler(int, void *);
103178366Scognetextern void (*arm_post_filter)(void *);
104260161Szbbextern int (*arm_config_irq)(int irq, enum intr_trigger trig,
105260161Szbb    enum intr_polarity pol);
106239268Sgonzo
107292426Sadrianvoid intr_pic_init_secondary(void);
108239268Sgonzo
109276032Sandrew#ifdef FDT
110289548Sianint gic_decode_fdt(phandle_t, pcell_t *, int *, int *, int *);
111292426Sadrianint intr_fdt_map_irq(phandle_t, pcell_t *, int);
112276032Sandrew#endif
113276032Sandrew
114298068Sandrew#endif /* INTRNG */
115289529Sian
116289529Sianvoid arm_irq_memory_barrier(uintptr_t);
117289529Sian
118129198Scognet#endif	/* _MACHINE_INTR_H */
119