This source file includes following definitions.
- pgt_pci_match
- pgt_pci_attach
- pgt_pci_detach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include "bpfilter.h"
24
25 #include <sys/param.h>
26 #include <sys/sockio.h>
27 #include <sys/mbuf.h>
28 #include <sys/kernel.h>
29 #include <sys/socket.h>
30 #include <sys/systm.h>
31 #include <sys/malloc.h>
32 #include <sys/timeout.h>
33 #include <sys/device.h>
34
35 #include <machine/bus.h>
36 #include <machine/intr.h>
37
38 #include <net/if.h>
39 #include <net/if_dl.h>
40 #include <net/if_media.h>
41
42 #include <netinet/in.h>
43 #include <netinet/if_ether.h>
44
45 #include <net80211/ieee80211_var.h>
46 #include <net80211/ieee80211_radiotap.h>
47
48 #include <dev/ic/pgtreg.h>
49 #include <dev/ic/pgtvar.h>
50
51 #include <dev/pci/pcireg.h>
52 #include <dev/pci/pcivar.h>
53 #include <dev/pci/pcidevs.h>
54
55
56 #define PGT_PCI_BAR0 0x10
57
58 int pgt_pci_match(struct device *, void *, void *);
59 void pgt_pci_attach(struct device *, struct device *, void *);
60 int pgt_pci_detach(struct device *, int);
61
62 struct pgt_pci_softc {
63 struct pgt_softc sc_pgt;
64
65 pci_chipset_tag_t sc_pc;
66 void *sc_ih;
67 bus_size_t sc_mapsize;
68 };
69
70 struct cfattach pgt_pci_ca = {
71 sizeof(struct pgt_pci_softc), pgt_pci_match, pgt_pci_attach,
72 pgt_pci_detach
73 };
74
75 const struct pci_matchid pgt_pci_devices[] = {
76 { PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_ISL3877 },
77 { PCI_VENDOR_INTERSIL, PCI_PRODUCT_INTERSIL_ISL3890 }
78 };
79
80 int
81 pgt_pci_match(struct device *parent, void *match, void *aux)
82 {
83 return (pci_matchbyid((struct pci_attach_args *)aux, pgt_pci_devices,
84 sizeof(pgt_pci_devices) / sizeof(pgt_pci_devices[0])));
85 }
86
87 void
88 pgt_pci_attach(struct device *parent, struct device *self, void *aux)
89 {
90 struct pgt_pci_softc *psc = (struct pgt_pci_softc *)self;
91 struct pgt_softc *sc = &psc->sc_pgt;
92 struct pci_attach_args *pa = aux;
93 const char *intrstr = NULL;
94 pci_intr_handle_t ih;
95 int error;
96
97 sc->sc_dmat = pa->pa_dmat;
98 psc->sc_pc = pa->pa_pc;
99
100
101 if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTERSIL_ISL3877)
102 sc->sc_flags |= SC_ISL3877;
103
104
105 error = pci_mapreg_map(pa, PGT_PCI_BAR0,
106 PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
107 &sc->sc_iotag, &sc->sc_iohandle, NULL, &psc->sc_mapsize, 0);
108 if (error != 0) {
109 printf(": could not map memory space\n");
110 return;
111 }
112
113
114 if (pci_intr_map(pa, &ih) != 0) {
115 printf(": could not map interrupt\n");
116 return;
117 }
118
119
120 bus_space_write_4(sc->sc_iotag, sc->sc_iohandle, PGT_REG_INT_EN, 0);
121 (void)bus_space_read_4(sc->sc_iotag, sc->sc_iohandle, PGT_REG_INT_EN);
122 DELAY(PGT_WRITEIO_DELAY);
123
124
125 intrstr = pci_intr_string(psc->sc_pc, ih);
126 psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, pgt_intr, sc,
127 sc->sc_dev.dv_xname);
128 if (psc->sc_ih == NULL) {
129 printf(": could not establish interrupt");
130 if (intrstr != NULL)
131 printf(" at %s", intrstr);
132 printf("\n");
133 return;
134 }
135 printf(": %s\n", intrstr);
136
137 if (rootvp == NULL)
138 mountroothook_establish(pgt_attach, sc);
139 else
140 pgt_attach(sc);
141 }
142
143 int
144 pgt_pci_detach(struct device *self, int flags)
145 {
146 struct pgt_pci_softc *psc = (struct pgt_pci_softc *)self;
147 struct pgt_softc *sc = &psc->sc_pgt;
148
149 pgt_detach(sc);
150 pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
151
152 return (0);
153 }