This source file includes following definitions.
- pdq_pci_ifintr
- pdq_pci_match
- pdq_pci_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #include <sys/param.h>
39 #include <sys/kernel.h>
40 #include <sys/mbuf.h>
41 #include <sys/protosw.h>
42 #include <sys/socket.h>
43 #include <sys/ioctl.h>
44 #include <sys/errno.h>
45 #include <sys/malloc.h>
46 #include <sys/device.h>
47
48 #include <net/if.h>
49 #include <net/if_types.h>
50 #include <net/if_dl.h>
51 #include <net/route.h>
52
53 #include "bpfilter.h"
54 #if NBPFILTER > 0
55 #include <net/bpf.h>
56 #endif
57
58 #ifdef INET
59 #include <netinet/in.h>
60 #include <netinet/if_ether.h>
61 #endif
62 #include <net/if_fddi.h>
63
64 #include <dev/pci/pcidevs.h>
65 #include <dev/pci/pcivar.h>
66 #include <dev/ic/pdqvar.h>
67 #include <dev/ic/pdqreg.h>
68
69 #define DEFPA_LATENCY 0x88
70 #define DEFPA_CBMA (PCI_MAPREG_START + 0)
71 #define DEFPA_CBIO (PCI_MAPREG_START + 4)
72
73 int pdq_pci_ifintr(void *);
74 int pdq_pci_match(struct device *, void *, void *);
75 void pdq_pci_attach(struct device *, struct device *, void *aux);
76
77 int
78 pdq_pci_ifintr(arg)
79 void *arg;
80 {
81 pdq_softc_t *sc = (pdq_softc_t *)arg;
82 (void) pdq_interrupt(sc->sc_pdq);
83 return (1);
84 }
85
86 int
87 pdq_pci_match(parent, match, aux)
88 struct device *parent;
89 void *match;
90 void *aux;
91 {
92 struct pci_attach_args *pa = (struct pci_attach_args *)aux;
93
94 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DEC &&
95 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DEC_DEFPA)
96 return (1);
97 return (0);
98 }
99
100 void
101 pdq_pci_attach(parent, self, aux)
102 struct device *parent;
103 struct device *self;
104 void *aux;
105 {
106 pdq_softc_t *sc = (pdq_softc_t *)self;
107 struct pci_attach_args *pa = (struct pci_attach_args *)aux;
108 u_int32_t data;
109 pci_intr_handle_t intrhandle;
110 const char *intrstr;
111 bus_size_t csrsize;
112
113 data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
114 if (PCI_LATTIMER(data) < DEFPA_LATENCY) {
115 data &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
116 data |= (DEFPA_LATENCY & PCI_LATTIMER_MASK)
117 << PCI_LATTIMER_SHIFT;
118 pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, data);
119 }
120
121 bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ);
122 sc->sc_if.if_flags = 0;
123 sc->sc_if.if_softc = sc;
124
125
126
127
128
129 #ifdef PDQ_IOMAPPED
130 if (pci_mapreg_map(pa, DEFPA_CBIO, PCI_MAPREG_TYPE_IO, 0,
131 &sc->sc_csrtag, &sc->sc_csrhandle, NULL, &csrsize, 0)) {
132 printf(": can't map I/O space!\n");
133 return;
134 }
135 #else
136 if (pci_mapreg_map(pa, DEFPA_CBMA, PCI_MAPREG_TYPE_MEM, 0,
137 &sc->sc_csrtag, &sc->sc_csrhandle, NULL, &csrsize, 0)) {
138 printf(": can't map memory space!\n");
139 return;
140 }
141 #endif
142
143 if (pci_intr_map(pa, &intrhandle)) {
144 printf(": couldn't map interrupt\n");
145 bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize);
146 return;
147 }
148 intrstr = pci_intr_string(pa->pa_pc, intrhandle);
149 sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_NET,
150 pdq_pci_ifintr, sc, self->dv_xname);
151 if (sc->sc_ih == NULL) {
152 printf(": couldn't establish interrupt");
153 if (intrstr != NULL)
154 printf(" at %s", intrstr);
155 printf("\n");
156 bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize);
157 return;
158 }
159 if (intrstr != NULL)
160 printf(": %s\n", intrstr);
161
162 sc->sc_pdq = pdq_initialize(sc->sc_csrtag, sc->sc_csrhandle,
163 sc->sc_if.if_xname, 0, (void *) sc, PDQ_DEFPA);
164 if (sc->sc_pdq == NULL) {
165 printf(": initialization failed\n");
166 bus_space_unmap(sc->sc_csrtag, sc->sc_csrhandle, csrsize);
167 return;
168 }
169
170 bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
171 sc->sc_arpcom.ac_enaddr, 6);
172 pdq_ifattach(sc, NULL);
173
174 sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset,
175 sc->sc_pdq);
176 if (sc->sc_ats == NULL)
177 printf("%s: warning: couldn't establish shutdown hook\n",
178 self->dv_xname);
179 }
180
181 struct cfattach fpa_ca = {
182 sizeof(pdq_softc_t), pdq_pci_match, pdq_pci_attach
183 };
184
185 struct cfdriver fpa_cd = {
186 0, "fpa", DV_IFNET
187 };