No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbarm / iq31244 / iq31244_pci.c
blob5f58674bb032fbf9a7497045280deb4fdc3753eb
1 /* $NetBSD: iq31244_pci.c,v 1.1.2.3 2004/09/21 13:14:47 skrll Exp $ */
3 /*
4 * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
5 * All rights reserved.
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
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 * 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
23 * written permission.
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.
39 * IQ31244 PCI interrupt support.
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: iq31244_pci.c,v 1.1.2.3 2004/09/21 13:14:47 skrll Exp $");
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/device.h>
49 #include <machine/autoconf.h>
50 #include <machine/bus.h>
52 #include <evbarm/iq80321/iq80321reg.h>
53 #include <evbarm/iq80321/iq80321var.h>
55 #include <arm/xscale/i80321reg.h>
56 #include <arm/xscale/i80321var.h>
58 #include <dev/pci/pcidevs.h>
59 #include <dev/pci/ppbreg.h>
61 int iq80321_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
62 const char *iq80321_pci_intr_string(void *, pci_intr_handle_t);
63 const struct evcnt *iq80321_pci_intr_evcnt(void *, pci_intr_handle_t);
64 void *iq80321_pci_intr_establish(void *, pci_intr_handle_t,
65 int, int (*func)(void *), void *);
66 void iq80321_pci_intr_disestablish(void *, void *);
68 void
69 iq80321_pci_init(pci_chipset_tag_t pc, void *cookie)
72 pc->pc_intr_v = cookie; /* the i80321 softc */
73 pc->pc_intr_map = iq80321_pci_intr_map;
74 pc->pc_intr_string = iq80321_pci_intr_string;
75 pc->pc_intr_evcnt = iq80321_pci_intr_evcnt;
76 pc->pc_intr_establish = iq80321_pci_intr_establish;
77 pc->pc_intr_disestablish = iq80321_pci_intr_disestablish;
80 int
81 iq80321_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
83 struct i80321_softc *sc = pa->pa_pc->pc_intr_v;
84 int b, d, f;
85 uint32_t busno;
87 busno = bus_space_read_4(sc->sc_st, sc->sc_atu_sh, ATU_PCIXSR);
88 busno = PCIXSR_BUSNO(busno);
89 if (busno == 0xff)
90 busno = 0;
92 pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, &b, &d, &f);
94 /* No mappings for devices not on our bus. */
95 if (b != busno)
96 goto no_mapping;
98 switch (d) {
99 case 1: /* PCIX-PCIX bridge */
101 * The S-ATA chips are behind the bridge, and all of
102 * the S-ATA interrupts are wired together.
104 *ihp = ICU_INT_XINT(2);
105 return (0);
107 case 2: /* PCI slot */
108 /* All pins are wired together. */
109 *ihp = ICU_INT_XINT(3);
110 return (0);
112 case 3: /* i82546 dual Gig-E */
113 if (pa->pa_intrpin == 1 || pa->pa_intrpin == 2) {
114 *ihp = ICU_INT_XINT(0);
115 return (0);
117 goto no_mapping;
119 default:
120 no_mapping:
121 printf("iq80321_pci_intr_map: no mapping for %d/%d/%d/%c\n",
122 pa->pa_bus, pa->pa_device, pa->pa_function,
123 '@' + pa->pa_intrpin);
124 return (1);
127 return (0);
130 const char *
131 iq80321_pci_intr_string(void *v, pci_intr_handle_t ih)
134 return (i80321_irqnames[ih]);
137 const struct evcnt *
138 iq80321_pci_intr_evcnt(void *v, pci_intr_handle_t ih)
141 /* XXX For now. */
142 return (NULL);
145 void *
146 iq80321_pci_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
147 int (*func)(void *), void *arg)
150 return (i80321_intr_establish(ih, ipl, func, arg));
153 void
154 iq80321_pci_intr_disestablish(void *v, void *cookie)
157 i80321_intr_disestablish(cookie);