This source file includes following definitions.
- rl_pci_match
- rl_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 #include "bpfilter.h"
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/sockio.h>
40 #include <sys/mbuf.h>
41 #include <sys/malloc.h>
42 #include <sys/kernel.h>
43 #include <sys/socket.h>
44 #include <sys/device.h>
45 #include <sys/timeout.h>
46
47 #include <net/if.h>
48 #include <net/if_dl.h>
49 #include <net/if_types.h>
50
51 #ifdef INET
52 #include <netinet/in.h>
53 #include <netinet/in_systm.h>
54 #include <netinet/in_var.h>
55 #include <netinet/ip.h>
56 #include <netinet/if_ether.h>
57 #endif
58
59 #include <net/if_media.h>
60
61 #if NBPFILTER > 0
62 #include <net/bpf.h>
63 #endif
64
65 #include <machine/bus.h>
66
67 #include <dev/mii/mii.h>
68 #include <dev/mii/miivar.h>
69 #include <dev/pci/pcireg.h>
70 #include <dev/pci/pcivar.h>
71 #include <dev/pci/pcidevs.h>
72
73
74
75
76
77
78
79
80
81 #define RL_USEIOSPACE
82
83 #include <dev/ic/rtl81x9reg.h>
84
85 int rl_pci_match(struct device *, void *, void *);
86 void rl_pci_attach(struct device *, struct device *, void *);
87
88 struct cfattach rl_pci_ca = {
89 sizeof(struct rl_softc), rl_pci_match, rl_pci_attach,
90 };
91
92 const struct pci_matchid rl_pci_devices[] = {
93 { PCI_VENDOR_ACCTON, PCI_PRODUCT_ACCTON_5030 },
94 { PCI_VENDOR_ADDTRON, PCI_PRODUCT_ADDTRON_8139 },
95 { PCI_VENDOR_DELTA, PCI_PRODUCT_DELTA_8139 },
96 { PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_530TXPLUS },
97 { PCI_VENDOR_NORTEL, PCI_PRODUCT_NORTEL_BS21 },
98 { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8129 }
99 };
100
101 int
102 rl_pci_match(parent, match, aux)
103 struct device *parent;
104 void *match;
105 void *aux;
106 {
107 struct pci_attach_args *pa = aux;
108
109 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_REALTEK &&
110 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_REALTEK_RT8139 &&
111 PCI_REVISION(pa->pa_class) == 0x10)
112 return (1);
113
114 return (pci_matchbyid((struct pci_attach_args *)aux, rl_pci_devices,
115 sizeof(rl_pci_devices)/sizeof(rl_pci_devices[0])));
116 }
117
118 void
119 rl_pci_attach(parent, self, aux)
120 struct device *parent, *self;
121 void *aux;
122 {
123 struct rl_softc *sc = (struct rl_softc *)self;
124 struct pci_attach_args *pa = aux;
125 pci_chipset_tag_t pc = pa->pa_pc;
126 pci_intr_handle_t ih;
127 const char *intrstr = NULL;
128 bus_size_t size;
129
130
131
132
133
134 #ifdef RL_USEIOSPACE
135 if (pci_mapreg_map(pa, RL_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
136 &sc->rl_btag, &sc->rl_bhandle, NULL, &size, 0)) {
137 printf(": can't map i/o space\n");
138 return;
139 }
140 #else
141 if (pci_mapreg_map(pa, RL_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
142 &sc->rl_btag, &sc->rl_bhandle, NULL, &size, 0)){
143 printf(": can't map mem space\n");
144 return;
145 }
146 #endif
147
148
149
150
151 if (pci_intr_map(pa, &ih)) {
152 printf(": couldn't map interrupt\n");
153 bus_space_unmap(sc->rl_btag, sc->rl_bhandle, size);
154 return;
155 }
156
157 intrstr = pci_intr_string(pc, ih);
158 sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, rl_intr, sc,
159 self->dv_xname);
160 if (sc->sc_ih == NULL) {
161 printf(": couldn't establish interrupt");
162 if (intrstr != NULL)
163 printf(" at %s", intrstr);
164 printf("\n");
165 bus_space_unmap(sc->rl_btag, sc->rl_bhandle, size);
166 return;
167 }
168 printf(": %s", intrstr);
169
170 sc->sc_dmat = pa->pa_dmat;
171
172 rl_attach(sc);
173 }