This source file includes following definitions.
- acx_pci_match
- acx_pci_attach
- acx_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
24
25 #include "bpfilter.h"
26
27 #include <sys/param.h>
28 #include <sys/sockio.h>
29 #include <sys/mbuf.h>
30 #include <sys/kernel.h>
31 #include <sys/socket.h>
32 #include <sys/systm.h>
33 #include <sys/malloc.h>
34 #include <sys/timeout.h>
35 #include <sys/device.h>
36
37 #include <machine/bus.h>
38 #include <machine/intr.h>
39
40 #include <net/if.h>
41 #include <net/if_dl.h>
42 #include <net/if_media.h>
43
44 #include <netinet/in.h>
45 #include <netinet/if_ether.h>
46
47 #include <net80211/ieee80211_var.h>
48 #include <net80211/ieee80211_amrr.h>
49 #include <net80211/ieee80211_radiotap.h>
50
51 #include <dev/ic/acxvar.h>
52 #include <dev/ic/acxreg.h>
53
54 #include <dev/pci/pcireg.h>
55 #include <dev/pci/pcivar.h>
56 #include <dev/pci/pcidevs.h>
57
58 struct acx_pci_softc {
59 struct acx_softc sc_acx;
60
61
62 struct acx_opns *sc_opns;
63 pci_chipset_tag_t sc_pc;
64 void *sc_ih;
65 bus_size_t sc_mapsize1;
66 bus_size_t sc_mapsize2;
67 int sc_intrline;
68
69
70 bus_space_tag_t sc_io_bt;
71 bus_space_handle_t sc_io_bh;
72 bus_size_t sc_iomapsize;
73 };
74
75
76 #define ACX_PCI_BAR0 0x10
77 #define ACX_PCI_BAR1 0x14
78 #define ACX_PCI_BAR2 0x18
79
80 int acx_pci_match(struct device *, void *, void *);
81 void acx_pci_attach(struct device *, struct device *, void *);
82 int acx_pci_detach(struct device *, int);
83
84 struct cfattach acx_pci_ca = {
85 sizeof (struct acx_pci_softc), acx_pci_match, acx_pci_attach,
86 acx_pci_detach
87 };
88
89 const struct pci_matchid acx_pci_devices[] = {
90 { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100A },
91 { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100B },
92 { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX111 }
93 };
94
95 int
96 acx_pci_match(struct device *parent, void *match, void *aux)
97 {
98 return (pci_matchbyid((struct pci_attach_args *)aux, acx_pci_devices,
99 sizeof (acx_pci_devices) / sizeof (acx_pci_devices[0])));
100 }
101
102 void
103 acx_pci_attach(struct device *parent, struct device *self, void *aux)
104 {
105 struct acx_pci_softc *psc = (struct acx_pci_softc *)self;
106 struct acx_softc *sc = &psc->sc_acx;
107 struct pci_attach_args *pa = aux;
108 const char *intrstr = NULL;
109 pci_intr_handle_t ih;
110 int error, b1 = ACX_PCI_BAR0, b2 = ACX_PCI_BAR1;
111
112 sc->sc_dmat = pa->pa_dmat;
113 psc->sc_pc = pa->pa_pc;
114
115
116 if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_TI_ACX100A) {
117 error = pci_mapreg_map(pa, ACX_PCI_BAR0,
118 PCI_MAPREG_TYPE_IO, 0, &psc->sc_io_bt,
119 &psc->sc_io_bh, NULL, &psc->sc_iomapsize, 0);
120 if (error != 0) {
121 printf(": could not map i/o space\n");
122 return;
123 }
124 b1 = ACX_PCI_BAR1;
125 b2 = ACX_PCI_BAR2;
126 }
127
128 error = pci_mapreg_map(pa, b1, PCI_MAPREG_TYPE_MEM |
129 PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_mem1_bt,
130 &sc->sc_mem1_bh, NULL, &psc->sc_mapsize1, 0);
131 if (error != 0) {
132 printf(": could not map memory1 space\n");
133 return;
134 }
135
136 error = pci_mapreg_map(pa, b2, PCI_MAPREG_TYPE_MEM |
137 PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_mem2_bt,
138 &sc->sc_mem2_bh, NULL, &psc->sc_mapsize2, 0);
139 if (error != 0) {
140 printf(": could not map memory2 space\n");
141 return;
142 }
143
144 if (pci_intr_map(pa, &ih) != 0) {
145 printf(": could not map interrupt\n");
146 return;
147 }
148
149 intrstr = pci_intr_string(psc->sc_pc, ih);
150 psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET,
151 acx_intr, sc, sc->sc_dev.dv_xname);
152 if (psc->sc_ih == NULL) {
153 printf(": could not establish interrupt");
154 if (intrstr != NULL)
155 printf(" at %s", intrstr);
156 printf("\n");
157 return;
158 }
159 printf(": %s\n", intrstr);
160
161 if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_TI_ACX111)
162 acx111_set_param(sc);
163 else
164 acx100_set_param(sc);
165
166 acx_attach(sc);
167 }
168
169 int
170 acx_pci_detach(struct device *self, int flags)
171 {
172 struct acx_pci_softc *psc = (struct acx_pci_softc *)self;
173 struct acx_softc *sc = &psc->sc_acx;
174
175 acx_detach(sc);
176 pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
177
178 return 0;
179 }