This source file includes following definitions.
- gemmatch_sbus
- gemattach_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 #if 0
45 #include <sys/cdefs.h>
46 __KERNEL_RCSID(0, "$NetBSD: if_gem_sbus.c,v 1.1 2006/11/24 13:23:32 martin Exp $");
47 #endif
48
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/syslog.h>
52 #include <sys/device.h>
53 #include <sys/malloc.h>
54 #include <sys/socket.h>
55
56 #include <net/if.h>
57 #include <net/if_dl.h>
58 #include <net/if_media.h>
59
60 #ifdef INET
61 #include <netinet/in.h>
62 #include <netinet/in_systm.h>
63 #include <netinet/in_var.h>
64 #include <netinet/ip.h>
65 #include <netinet/if_ether.h>
66 #endif
67
68 #include <dev/mii/mii.h>
69 #include <dev/mii/miivar.h>
70
71 #include <machine/bus.h>
72 #include <machine/intr.h>
73 #include <machine/autoconf.h>
74
75 #include <dev/sbus/sbusvar.h>
76
77 #include <dev/ic/gemreg.h>
78 #include <dev/ic/gemvar.h>
79
80 #include <dev/ofw/openfirm.h>
81
82 struct gem_sbus_softc {
83 struct gem_softc gsc_gem;
84 };
85
86 int gemmatch_sbus(struct device *, void *, void *);
87 void gemattach_sbus(struct device *, struct device *, void *);
88
89 struct cfattach gem_sbus_ca = {
90 sizeof(struct gem_sbus_softc), gemmatch_sbus, gemattach_sbus
91 };
92
93 int
94 gemmatch_sbus(struct device *parent, void *vcf, void *aux)
95 {
96 struct sbus_attach_args *sa = aux;
97
98 return (strcmp("network", sa->sa_name) == 0);
99 }
100
101 void
102 gemattach_sbus(struct device *parent, struct device *self, void *aux)
103 {
104 struct sbus_attach_args *sa = aux;
105 struct gem_sbus_softc *gsc = (void *)self;
106 struct gem_softc *sc = &gsc->gsc_gem;
107
108 extern void myetheraddr(u_char *);
109
110
111 sc->sc_bustag = sa->sa_bustag;
112 sc->sc_dmatag = sa->sa_dmatag;
113
114 if (sa->sa_nreg < 2) {
115 printf("%s: only %d register sets\n",
116 self->dv_xname, sa->sa_nreg);
117 return;
118 }
119
120
121
122
123
124
125
126
127 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
128 (bus_addr_t)sa->sa_reg[0].sbr_offset,
129 (bus_size_t)sa->sa_reg[0].sbr_size, 0, 0,
130 &sc->sc_h2) != 0) {
131 printf("%s: cannot map registers\n", self->dv_xname);
132 return;
133 }
134 if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
135 (bus_addr_t)sa->sa_reg[1].sbr_offset,
136 (bus_size_t)sa->sa_reg[1].sbr_size, 0, 0,
137 &sc->sc_h1) != 0) {
138 printf("%s: cannot map registers\n", self->dv_xname);
139 return;
140 }
141
142 if (OF_getprop(sa->sa_node, "local-mac-address",
143 sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN) <= 0)
144 myetheraddr(sc->sc_arpcom.ac_enaddr);
145
146
147
148
149 bus_space_write_4(sa->sa_bustag, sc->sc_h2, GEM_SBUS_CONFIG,
150 GEM_SBUS_CFG_PARITY|GEM_SBUS_CFG_BMODE64);
151
152
153 if (sa->sa_nintr != 0)
154 (void)bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_NET, 0,
155 gem_intr, sc, self->dv_xname);
156
157 gem_config(sc);
158 }