ixdp425_pci.c revision 1.1 1 1.1 ichiro /* $NetBSD: ixdp425_pci.c,v 1.1 2003/05/24 01:59:32 ichiro Exp $ */
2 1.1 ichiro /*
3 1.1 ichiro * Copyright (c) 2003
4 1.1 ichiro * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
5 1.1 ichiro * All rights reserved.
6 1.1 ichiro *
7 1.1 ichiro * Redistribution and use in source and binary forms, with or without
8 1.1 ichiro * modification, are permitted provided that the following conditions
9 1.1 ichiro * are met:
10 1.1 ichiro * 1. Redistributions of source code must retain the above copyright
11 1.1 ichiro * notice, this list of conditions and the following disclaimer.
12 1.1 ichiro * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 ichiro * notice, this list of conditions and the following disclaimer in the
14 1.1 ichiro * documentation and/or other materials provided with the distribution.
15 1.1 ichiro * 3. All advertising materials mentioning features or use of this software
16 1.1 ichiro * must display the following acknowledgement:
17 1.1 ichiro * This product includes software developed by Ichiro FUKUHARA.
18 1.1 ichiro * 4. The name of the company nor the name of the author may be used to
19 1.1 ichiro * endorse or promote products derived from this software without specific
20 1.1 ichiro * prior written permission.
21 1.1 ichiro *
22 1.1 ichiro * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
23 1.1 ichiro * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 ichiro * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 ichiro * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
26 1.1 ichiro * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 ichiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 ichiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 ichiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 ichiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 ichiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 ichiro * SUCH DAMAGE.
33 1.1 ichiro */
34 1.1 ichiro
35 1.1 ichiro #include <sys/cdefs.h>
36 1.1 ichiro __KERNEL_RCSID(0, "$NetBSD: ixdp425_pci.c,v 1.1 2003/05/24 01:59:32 ichiro Exp $");
37 1.1 ichiro
38 1.1 ichiro /*
39 1.1 ichiro * IXDP425 PCI interrupt support.
40 1.1 ichiro */
41 1.1 ichiro
42 1.1 ichiro #include <sys/param.h>
43 1.1 ichiro #include <sys/systm.h>
44 1.1 ichiro #include <sys/device.h>
45 1.1 ichiro
46 1.1 ichiro #include <machine/autoconf.h>
47 1.1 ichiro #include <machine/bus.h>
48 1.1 ichiro
49 1.1 ichiro #include <evbarm/ixdp425/ixdp425reg.h>
50 1.1 ichiro #include <evbarm/ixdp425/ixdp425var.h>
51 1.1 ichiro
52 1.1 ichiro #include <arm/xscale/ixp425reg.h>
53 1.1 ichiro #include <arm/xscale/ixp425var.h>
54 1.1 ichiro
55 1.1 ichiro #include <dev/pci/pcidevs.h>
56 1.1 ichiro #include <dev/pci/ppbreg.h>
57 1.1 ichiro
58 1.1 ichiro int ixdp425_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
59 1.1 ichiro const char *ixdp425_pci_intr_string(void *, pci_intr_handle_t);
60 1.1 ichiro const struct evcnt *ixdp425_pci_intr_evcnt(void *, pci_intr_handle_t);
61 1.1 ichiro void *ixdp425_pci_intr_establish(void *, pci_intr_handle_t, int,
62 1.1 ichiro int (*func)(void *), void *);
63 1.1 ichiro void ixdp425_pci_intr_disestablish(void *, void *);
64 1.1 ichiro
65 1.1 ichiro void
66 1.1 ichiro ixdp425_pci_init(pci_chipset_tag_t pc, void *cookie)
67 1.1 ichiro {
68 1.1 ichiro pc->pc_intr_v = cookie;
69 1.1 ichiro pc->pc_intr_map = ixdp425_pci_intr_map;
70 1.1 ichiro pc->pc_intr_string = ixdp425_pci_intr_string;
71 1.1 ichiro pc->pc_intr_evcnt = ixdp425_pci_intr_evcnt;
72 1.1 ichiro pc->pc_intr_establish = ixdp425_pci_intr_establish;
73 1.1 ichiro pc->pc_intr_disestablish = ixdp425_pci_intr_disestablish;
74 1.1 ichiro }
75 1.1 ichiro
76 1.1 ichiro int
77 1.1 ichiro ixdp425_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
78 1.1 ichiro {
79 1.1 ichiro int pin = pa->pa_intrpin;
80 1.1 ichiro
81 1.1 ichiro #ifdef PCI_DEBUG
82 1.1 ichiro void *v = pa->pa_pc;
83 1.1 ichiro int line = pa->pa_intrline;
84 1.1 ichiro int dev=pa->pa_device;
85 1.1 ichiro pcitag_t intrtag = pa->pa_intrtag;
86 1.1 ichiro
87 1.1 ichiro printf("ixdp425_pci_intr_map: v=%p, tag=%08lx intrpin=%d line=%d dev=%d\n",
88 1.1 ichiro v, intrtag, pin, line, dev);
89 1.1 ichiro #endif
90 1.1 ichiro
91 1.1 ichiro switch (pin) {
92 1.1 ichiro case 1:
93 1.1 ichiro *ihp = PCI_INT_A;
94 1.1 ichiro return (0);
95 1.1 ichiro case 2:
96 1.1 ichiro *ihp = PCI_INT_B;
97 1.1 ichiro return (0);
98 1.1 ichiro case 3:
99 1.1 ichiro *ihp = PCI_INT_C;
100 1.1 ichiro return (0);
101 1.1 ichiro case 4:
102 1.1 ichiro *ihp = PCI_INT_D;
103 1.1 ichiro return (0);
104 1.1 ichiro default:
105 1.1 ichiro #ifdef PCI_DEBUG
106 1.1 ichiro printf("ixdp425_pci_intr_map: no mapping for %d/%d/%d\n",
107 1.1 ichiro pa->pa_bus, pa->pa_device, pa->pa_function);
108 1.1 ichiro #endif
109 1.1 ichiro return (1);
110 1.1 ichiro }
111 1.1 ichiro
112 1.1 ichiro return (0);
113 1.1 ichiro }
114 1.1 ichiro
115 1.1 ichiro const char *
116 1.1 ichiro ixdp425_pci_intr_string(void *v, pci_intr_handle_t ih)
117 1.1 ichiro {
118 1.1 ichiro static char irqstr[IRQNAMESIZE];
119 1.1 ichiro
120 1.1 ichiro sprintf(irqstr, "ixp425 irq %ld", ih);
121 1.1 ichiro return (irqstr);
122 1.1 ichiro }
123 1.1 ichiro
124 1.1 ichiro const struct evcnt *
125 1.1 ichiro ixdp425_pci_intr_evcnt(void *v, pci_intr_handle_t ih)
126 1.1 ichiro {
127 1.1 ichiro return (NULL);
128 1.1 ichiro }
129 1.1 ichiro
130 1.1 ichiro void *
131 1.1 ichiro ixdp425_pci_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
132 1.1 ichiro int (*func)(void *), void *arg)
133 1.1 ichiro {
134 1.1 ichiro #ifdef PCI_DEBUG
135 1.1 ichiro printf("ixdp425_pci_intr_establish(v=%p, irq=%d, ipl=%d, func=%p, arg=%p)\n",
136 1.1 ichiro v, (int) ih, ipl, func, arg);
137 1.1 ichiro #endif
138 1.1 ichiro
139 1.1 ichiro return (ixp425_intr_establish(ih, ipl, func, arg));
140 1.1 ichiro }
141 1.1 ichiro
142 1.1 ichiro void
143 1.1 ichiro ixdp425_pci_intr_disestablish(void *v, void *cookie)
144 1.1 ichiro {
145 1.1 ichiro #ifdef PCI_DEBUG
146 1.1 ichiro printf("ixdp425_pci_intr_disestablish(v=%p, cookie=%p)\n",
147 1.1 ichiro v, cookie);
148 1.1 ichiro #endif
149 1.1 ichiro
150 1.1 ichiro ixp425_intr_disestablish(cookie);
151 1.1 ichiro }
152