This source file includes following definitions.
- txphymatch
- txphyattach
- txphy_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 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/device.h>
37 #include <sys/socket.h>
38 #include <sys/errno.h>
39
40 #include <net/if.h>
41 #include <net/if_media.h>
42
43 #include <dev/mii/mii.h>
44 #include <dev/mii/miivar.h>
45 #include <dev/mii/miidevs.h>
46
47 int txphymatch(struct device *, void *, void *);
48 void txphyattach(struct device *, struct device *, void *);
49
50 struct cfattach txphy_ca = {
51 sizeof(struct mii_softc), txphymatch, txphyattach, mii_phy_detach,
52 mii_phy_activate
53 };
54
55 struct cfdriver txphy_cd = {
56 NULL, "txphy", DV_DULL
57 };
58
59 int txphy_service(struct mii_softc *, struct mii_data *, int);
60
61 const struct mii_phy_funcs txphy_funcs = {
62 txphy_service, ukphy_status, mii_phy_reset,
63 };
64
65 static const struct mii_phydesc txphys[] = {
66 { MII_OUI_xxTI, MII_MODEL_xxTI_TNETE2101,
67 MII_STR_xxTI_TNETE2101 },
68
69 { 0, 0,
70 NULL },
71 };
72
73 int
74 txphymatch(struct device *parent, void *match, void *aux)
75 {
76 struct mii_attach_args *ma = aux;
77
78 if (mii_phy_match(ma, txphys) != NULL)
79 return (10);
80
81 return (0);
82 }
83
84 void
85 txphyattach(struct device *parent, struct device *self, void *aux)
86 {
87 struct mii_softc *sc = (struct mii_softc *)self;
88 struct mii_attach_args *ma = aux;
89 struct mii_data *mii = ma->mii_data;
90 const struct mii_phydesc *mpd;
91
92 mpd = mii_phy_match(ma, txphys);
93 printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
94
95 sc->mii_inst = mii->mii_instance;
96 sc->mii_phy = ma->mii_phyno;
97 sc->mii_funcs = &txphy_funcs;
98 sc->mii_pdata = mii;
99 sc->mii_flags = ma->mii_flags;
100
101 PHY_RESET(sc);
102
103 sc->mii_capabilities =
104 PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
105 if (sc->mii_capabilities & BMSR_MEDIAMASK)
106 mii_phy_add_media(sc);
107 }
108
109 int
110 txphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
111 {
112 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
113
114 if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
115 return (ENXIO);
116
117
118
119
120 if (IFM_INST(ife->ifm_media) != sc->mii_inst)
121 panic("txphy_service: attempt to isolate phy");
122
123 switch (cmd) {
124 case MII_POLLSTAT:
125 break;
126
127 case MII_MEDIACHG:
128
129
130
131 if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
132 break;
133
134 mii_phy_setmedia(sc);
135 break;
136
137 case MII_TICK:
138 if (mii_phy_tick(sc) == EJUSTRETURN)
139 return (0);
140 break;
141
142 case MII_DOWN:
143 mii_phy_down(sc);
144 return (0);
145 }
146
147
148 mii_phy_status(sc);
149
150
151 mii_phy_update(sc, cmd);
152 return (0);
153 }