This source file includes following definitions.
- hmematch_sbus
- hmeattach_sbus
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
39
40
41
42
43
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/syslog.h>
47 #include <sys/device.h>
48 #include <sys/malloc.h>
49 #include <sys/socket.h>
50
51 #include <net/if.h>
52 #include <net/if_dl.h>
53 #include <net/if_media.h>
54
55 #ifdef INET
56 #include <netinet/in.h>
57 #include <netinet/in_systm.h>
58 #include <netinet/in_var.h>
59 #include <netinet/ip.h>
60 #include <netinet/if_ether.h>
61 #endif
62
63 #include <dev/mii/mii.h>
64 #include <dev/mii/miivar.h>
65
66 #include <machine/bus.h>
67 #include <machine/intr.h>
68 #include <machine/autoconf.h>
69
70 #include <dev/sbus/sbusvar.h>
71 #include <dev/ic/hmevar.h>
72 #include <dev/ofw/openfirm.h>
73
74 struct hmesbus_softc {
75 struct hme_softc hsc_hme;
76 };
77
78 int hmematch_sbus(struct device *, void *, void *);
79 void hmeattach_sbus(struct device *, struct device *, void *);
80
81 struct cfattach hme_sbus_ca = {
82 sizeof(struct hmesbus_softc), hmematch_sbus, hmeattach_sbus
83 };
84
85 int
86 hmematch_sbus(struct device *parent, void *vcf, void *aux)
87 {
88 struct cfdata *cf = vcf;
89 struct sbus_attach_args *sa = aux;
90
91 return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0 ||
92 strcmp("SUNW,qfe", sa->sa_name) == 0 ||
93 strcmp("SUNW,hme", sa->sa_name) == 0);
94 }
95
96 void
97 hmeattach_sbus(struct device *parent, struct device *self, void *aux)
98 {
99 struct sbus_attach_args *sa = aux;
100 struct hmesbus_softc *hsc = (void *)self;
101 struct hme_softc *sc = &hsc->hsc_hme;
102 u_int32_t burst, sbusburst;
103 int node;
104
105 extern void myetheraddr(u_char *);
106
107 node = sa->sa_node;
108
109
110 sc->sc_bustag = sa->sa_bustag;
111 sc->sc_dmatag = sa->sa_dmatag;
112
113 if (sa->sa_nreg < 5) {
114 printf("%s: only %d register sets\n",
115 self->dv_xname, sa->sa_nreg);
116 return;
117 }
118
119
120
121
122
123
124
125
126
127
128
129 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
130 (bus_addr_t)sa->sa_reg[0].sbr_offset,
131 (bus_size_t)sa->sa_reg[0].sbr_size, 0, 0, &sc->sc_seb) != 0) {
132 printf("%s @ sbus: cannot map registers\n", self->dv_xname);
133 return;
134 }
135 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[1].sbr_slot,
136 (bus_addr_t)sa->sa_reg[1].sbr_offset,
137 (bus_size_t)sa->sa_reg[1].sbr_size, 0, 0, &sc->sc_etx) != 0) {
138 printf("%s @ sbus: cannot map registers\n", self->dv_xname);
139 return;
140 }
141 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[2].sbr_slot,
142 (bus_addr_t)sa->sa_reg[2].sbr_offset,
143 (bus_size_t)sa->sa_reg[2].sbr_size, 0, 0, &sc->sc_erx) != 0) {
144 printf("%s @ sbus: cannot map registers\n", self->dv_xname);
145 return;
146 }
147 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[3].sbr_slot,
148 (bus_addr_t)sa->sa_reg[3].sbr_offset,
149 (bus_size_t)sa->sa_reg[3].sbr_size, 0, 0, &sc->sc_mac) != 0) {
150 printf("%s @ sbus: cannot map registers\n", self->dv_xname);
151 return;
152 }
153 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[4].sbr_slot,
154 (bus_addr_t)sa->sa_reg[4].sbr_offset,
155 (bus_size_t)sa->sa_reg[4].sbr_size, 0, 0, &sc->sc_mif) != 0) {
156 printf("%s @ sbus: cannot map registers\n", self->dv_xname);
157 return;
158 }
159
160 if (OF_getprop(sa->sa_node, "local-mac-address",
161 sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN) <= 0)
162 myetheraddr(sc->sc_arpcom.ac_enaddr);
163
164
165
166
167
168 sbusburst = ((struct sbus_softc *)parent)->sc_burst;
169 if (sbusburst == 0)
170 sbusburst = SBUS_BURST_32 - 1;
171
172 burst = getpropint(node, "burst-sizes", -1);
173 if (burst == -1)
174
175 burst = sbusburst;
176
177
178 burst &= sbusburst;
179
180
181 if ((burst & SBUS_BURST_64))
182 sc->sc_burst = 64;
183 else if ((burst & SBUS_BURST_32))
184 sc->sc_burst = 32;
185 else if ((burst & SBUS_BURST_16))
186 sc->sc_burst = 16;
187 else
188 sc->sc_burst = 0;
189
190 sc->sc_pci = 0;
191
192
193 if (sa->sa_nintr != 0)
194 (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0,
195 hme_intr, sc, self->dv_xname);
196
197 hme_config(sc);
198 }