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