4 * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD$");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/device.h>
45 #include <machine/autoconf.h>
46 #include <machine/bus.h>
48 #include <evbarm/hdl_g/hdlgreg.h>
49 #include <evbarm/hdl_g/hdlgvar.h>
51 #include <arm/xscale/i80321reg.h>
52 #include <arm/xscale/i80321var.h>
54 #include <dev/pci/pcidevs.h>
55 #include <dev/pci/ppbreg.h>
57 int hdlg_pci_intr_map(struct pci_attach_args
*, pci_intr_handle_t
*);
58 const char *hdlg_pci_intr_string(void *, pci_intr_handle_t
);
59 const struct evcnt
*hdlg_pci_intr_evcnt(void *, pci_intr_handle_t
);
60 void *hdlg_pci_intr_establish(void *, pci_intr_handle_t
,
61 int, int (*func
)(void *), void *);
62 void hdlg_pci_intr_disestablish(void *, void *);
65 hdlg_pci_init(pci_chipset_tag_t pc
, void *cookie
)
68 pc
->pc_intr_v
= cookie
; /* the i80321 softc */
69 pc
->pc_intr_map
= hdlg_pci_intr_map
;
70 pc
->pc_intr_string
= hdlg_pci_intr_string
;
71 pc
->pc_intr_evcnt
= hdlg_pci_intr_evcnt
;
72 pc
->pc_intr_establish
= hdlg_pci_intr_establish
;
73 pc
->pc_intr_disestablish
= hdlg_pci_intr_disestablish
;
77 hdlg_pci_intr_map(struct pci_attach_args
*pa
, pci_intr_handle_t
*ihp
)
79 struct i80321_softc
*sc
= pa
->pa_pc
->pc_intr_v
;
84 * GigaLANDISK's interrupts are routed like so:
86 * XINT0 Intel i82541PI Gig-E
88 * XINT1 ACARD ATP875-A
95 busno
= bus_space_read_4(sc
->sc_st
, sc
->sc_atu_sh
, ATU_PCIXSR
);
96 busno
= PCIXSR_BUSNO(busno
);
100 pci_decompose_tag(pa
->pa_pc
, pa
->pa_intrtag
, &b
, &d
, &f
);
102 /* No mappings for devices not on our bus. */
107 case 1: /* i82541PI Gig-E */
108 if (pa
->pa_intrpin
== 1) {
109 *ihp
= ICU_INT_XINT(0);
114 case 2: /* ATP875-A */
115 if (pa
->pa_intrpin
== 1) {
116 *ihp
= ICU_INT_XINT(1);
121 case 3: /* echi/ochi */
122 switch (pa
->pa_intrpin
) {
126 *ihp
= ICU_INT_XINT(2);
133 printf("hdlg_pci_intr_map: no mapping for %d/%d/%d\n",
134 pa
->pa_bus
, pa
->pa_device
, pa
->pa_function
);
142 hdlg_pci_intr_string(void *v
, pci_intr_handle_t ih
)
145 return i80321_irqnames
[ih
];
149 hdlg_pci_intr_evcnt(void *v
, pci_intr_handle_t ih
)
157 hdlg_pci_intr_establish(void *v
, pci_intr_handle_t ih
, int ipl
,
158 int (*func
)(void *), void *arg
)
161 return i80321_intr_establish(ih
, ipl
, func
, arg
);
165 hdlg_pci_intr_disestablish(void *v
, void *cookie
)
168 i80321_intr_disestablish(cookie
);