This source file includes following definitions.
- luphymatch
- luphyattach
- luphy_service
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/kernel.h>
47 #include <sys/device.h>
48 #include <sys/socket.h>
49
50 #include <net/if.h>
51 #include <net/if_media.h>
52
53 #include <dev/mii/mii.h>
54 #include <dev/mii/miivar.h>
55 #include <dev/mii/miidevs.h>
56
57 int luphymatch(struct device *, void *, void *);
58 void luphyattach(struct device *, struct device *, void *);
59
60 struct cfattach luphy_ca = {
61 sizeof(struct mii_softc), luphymatch, luphyattach, mii_phy_detach,
62 mii_phy_activate
63 };
64
65 struct cfdriver luphy_cd = {
66 NULL, "luphy", DV_DULL
67 };
68
69 int luphy_service(struct mii_softc *, struct mii_data *, int);
70
71 const struct mii_phy_funcs luphy_funcs = {
72 luphy_service, ukphy_status, mii_phy_reset,
73 };
74
75 static const struct mii_phydesc luphys[] = {
76 { MII_OUI_LUCENT, MII_MODEL_LUCENT_LU6612,
77 MII_STR_LUCENT_LU6612 },
78
79 { 0, 0,
80 NULL },
81 };
82
83 int
84 luphymatch(struct device *parent, void *match, void *aux)
85 {
86 struct mii_attach_args *ma = aux;
87
88 if (mii_phy_match(ma, luphys) != NULL)
89 return (10);
90
91 return (0);
92 }
93
94 void
95 luphyattach(struct device *parent, struct device *self, void *aux)
96 {
97 struct mii_softc *sc = (struct mii_softc *)self;
98 struct mii_attach_args *ma = aux;
99 struct mii_data *mii = ma->mii_data;
100 const struct mii_phydesc *mpd;
101
102 mpd = mii_phy_match(ma, luphys);
103 printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
104
105 sc->mii_inst = mii->mii_instance;
106 sc->mii_phy = ma->mii_phyno;
107 sc->mii_funcs = &luphy_funcs;
108 sc->mii_pdata = mii;
109 sc->mii_flags = ma->mii_flags;
110
111 sc->mii_flags |= MIIF_NOISOLATE;
112
113 PHY_RESET(sc);
114
115 sc->mii_capabilities =
116 PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
117 if (sc->mii_capabilities & BMSR_MEDIAMASK)
118 mii_phy_add_media(sc);
119 }
120
121 int
122 luphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
123 {
124 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
125
126 switch (cmd) {
127 case MII_POLLSTAT:
128
129
130
131 if (IFM_INST(ife->ifm_media) != sc->mii_inst)
132 return (0);
133 break;
134
135 case MII_MEDIACHG:
136
137
138
139
140
141 if (IFM_INST(ife->ifm_media) != sc->mii_inst)
142 return (0);
143
144
145
146
147 if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
148 break;
149
150 mii_phy_setmedia(sc);
151 break;
152
153 case MII_TICK:
154
155
156
157 if (IFM_INST(ife->ifm_media) != sc->mii_inst)
158 return (0);
159
160 if (mii_phy_tick(sc) == EJUSTRETURN)
161 return (0);
162 break;
163
164 case MII_DOWN:
165 mii_phy_down(sc);
166 return (0);
167 }
168
169
170 mii_phy_status(sc);
171
172
173 mii_phy_update(sc, cmd);
174 return (0);
175 }