ixm1200_pci.c revision 1.3 1 /* $NetBSD: ixm1200_pci.c,v 1.3 2003/02/17 20:51:53 ichiro 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 /*
37 * IXM1200 PCI interrupt support.
38 */
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
43
44 #include <machine/autoconf.h>
45 #include <machine/bus.h>
46
47 #include <evbarm/ixm1200/ixm1200reg.h>
48 #include <evbarm/ixm1200/ixm1200var.h>
49
50 #include <arm/ixp12x0/ixp12x0reg.h>
51 #include <arm/ixp12x0/ixp12x0var.h>
52
53 #include <arm/ixp12x0/ixp12x0_pcireg.h>
54
55 #include <dev/pci/pcidevs.h>
56 #include <dev/pci/ppbreg.h>
57
58 int ixm1200_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
59 const char *ixm1200_pci_intr_string(void *, pci_intr_handle_t);
60 const struct evcnt *ixm1200_pci_intr_evcnt(void *, pci_intr_handle_t);
61 void *ixm1200_pci_intr_establish(void *, pci_intr_handle_t, int,
62 int (*func)(void *), void *);
63 void ixm1200_pci_intr_disestablish(void *, void *);
64
65 void
66 ixm1200_pci_init(pc, cookie)
67 pci_chipset_tag_t pc;
68 void *cookie;
69 {
70 pc->pc_intr_v = cookie;
71 pc->pc_intr_map = ixm1200_pci_intr_map;
72 pc->pc_intr_string = ixm1200_pci_intr_string;
73 pc->pc_intr_evcnt = ixm1200_pci_intr_evcnt;
74 pc->pc_intr_establish = ixm1200_pci_intr_establish;
75 pc->pc_intr_disestablish = ixm1200_pci_intr_disestablish;
76 }
77
78 int
79 ixm1200_pci_intr_map(pa, ihp)
80 struct pci_attach_args *pa;
81 pci_intr_handle_t *ihp;
82 {
83 #ifdef PCI_DEBUG
84 void *v = pa->pa_pc;
85 int pin = pa->pa_intrpin;
86 int line = pa->pa_intrline;
87 int dev=pa->pa_device;
88 pcitag_t intrtag = pa->pa_intrtag;
89
90 printf("ixm1200_pci_intr_map: v=%p, tag=%08lx intrpin=%d line=%d dev=%d\n",
91 v, intrtag, pin, line, dev);
92 #endif
93
94 /* ixp12x0 has only one interrupt line for PCI */
95 *ihp = IXPPCI_INTR_PIL;
96 return (0);
97 }
98
99 const char *
100 ixm1200_pci_intr_string(v, ih)
101 void *v;
102 pci_intr_handle_t ih;
103 {
104 static char irqstr[IRQNAMESIZE];
105
106 sprintf(irqstr, "IXM1200 irq %ld", ih);
107 return (irqstr);
108 }
109
110 const struct evcnt *
111 ixm1200_pci_intr_evcnt(v, ih)
112 void *v;
113 pci_intr_handle_t ih;
114 {
115 return (NULL);
116 }
117
118 void *
119 ixm1200_pci_intr_establish(v, ih, ipl, func, arg)
120 void *v;
121 pci_intr_handle_t ih;
122 int ipl;
123 int (*func)(void *);
124 void *arg;
125 {
126 #ifdef PCI_DEBUG
127 printf("ixm1200_pci_intr_establish(v=%p, irq=%d, ipl=%d, func=%p, arg=%p)\n",
128 v, (int) ih, ipl, func, arg);
129 #endif
130
131 return (ixp12x0_intr_establish(ih, ipl, func, arg));
132 }
133
134 void
135 ixm1200_pci_intr_disestablish(void *v, void *cookie)
136 {
137 #ifdef PCI_DEBUG
138 printf("ixm1200_pci_intr_disestablish(v=%p, cookie=%p)\n",
139 v, cookie);
140 #endif
141
142 ixp12x0_intr_disestablish(cookie);
143 }
144