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