Deleted Added
full compact
ruephy.c (213893) ruephy.c (221407)
1/*-
2 * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/mii/ruephy.c 213893 2010-10-15 14:52:11Z marius $");
29__FBSDID("$FreeBSD: head/sys/dev/mii/ruephy.c 221407 2011-05-03 19:51:29Z marius $");
30
31/*
32 * driver for RealTek RTL8150 internal PHY
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>

--- 45 unchanged lines hidden (view full) ---

83 * The RealTek RTL8150 internal PHY doesn't have vendor/device ID
84 * registers; rue(4) fakes up a return value of all zeros.
85 */
86static const struct mii_phydesc ruephys[] = {
87 { 0, 0, "RealTek RTL8150 internal media interface" },
88 MII_PHY_END
89};
90
30
31/*
32 * driver for RealTek RTL8150 internal PHY
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>

--- 45 unchanged lines hidden (view full) ---

83 * The RealTek RTL8150 internal PHY doesn't have vendor/device ID
84 * registers; rue(4) fakes up a return value of all zeros.
85 */
86static const struct mii_phydesc ruephys[] = {
87 { 0, 0, "RealTek RTL8150 internal media interface" },
88 MII_PHY_END
89};
90
91static const struct mii_phy_funcs ruephy_funcs = {
92 ruephy_service,
93 ruephy_status,
94 ruephy_reset
95};
96
91static int
92ruephy_probe(device_t dev)
93{
94
95 if (strcmp(device_get_name(device_get_parent(device_get_parent(dev))),
96 "rue") == 0)
97 return (mii_phy_dev_probe(dev, ruephys, BUS_PROBE_DEFAULT));
98 return (ENXIO);
99}
100
101static int
102ruephy_attach(device_t dev)
103{
97static int
98ruephy_probe(device_t dev)
99{
100
101 if (strcmp(device_get_name(device_get_parent(device_get_parent(dev))),
102 "rue") == 0)
103 return (mii_phy_dev_probe(dev, ruephys, BUS_PROBE_DEFAULT));
104 return (ENXIO);
105}
106
107static int
108ruephy_attach(device_t dev)
109{
104 struct mii_softc *sc;
105 struct mii_attach_args *ma;
106 struct mii_data *mii;
107
110
108 sc = device_get_softc(dev);
109 ma = device_get_ivars(dev);
110 sc->mii_dev = device_get_parent(dev);
111 mii = ma->mii_data;
112 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
113
114 sc->mii_flags = miibus_get_flags(dev);
115 sc->mii_inst = mii->mii_instance++;
116 sc->mii_phy = ma->mii_phyno;
117 sc->mii_service = ruephy_service;
118 sc->mii_pdata = mii;
119
120 /*
121 * Apparently, we can neither isolate nor do loopback on this PHY.
122 */
123 sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
124
125 ruephy_reset(sc);
126
127 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
128 device_printf(dev, " ");
129 mii_phy_add_media(sc);
130 printf("\n");
131
132 MIIBUS_MEDIAINIT(sc->mii_dev);
111 mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
112 &ruephy_funcs, 1);
133 return (0);
134}
135
136static int
137ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
138{
139 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
140 int reg;

--- 35 unchanged lines hidden (view full) ---

176 if (reg & RUEPHY_MSR_LINK)
177 break;
178
179 /* Only retry autonegotiation every mii_anegticks seconds. */
180 if (sc->mii_ticks <= sc->mii_anegticks)
181 break;
182
183 sc->mii_ticks = 0;
113 return (0);
114}
115
116static int
117ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
118{
119 struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
120 int reg;

--- 35 unchanged lines hidden (view full) ---

156 if (reg & RUEPHY_MSR_LINK)
157 break;
158
159 /* Only retry autonegotiation every mii_anegticks seconds. */
160 if (sc->mii_ticks <= sc->mii_anegticks)
161 break;
162
163 sc->mii_ticks = 0;
184 ruephy_reset(sc);
164 PHY_RESET(sc);
185 if (mii_phy_auto(sc) == EJUSTRETURN)
186 return (0);
187 break;
188 }
189
190 /* Update the media status. */
165 if (mii_phy_auto(sc) == EJUSTRETURN)
166 return (0);
167 break;
168 }
169
170 /* Update the media status. */
191 ruephy_status(sc);
171 PHY_STATUS(sc);
192
193 /* Callback if something changed. */
194 mii_phy_update(sc, cmd);
195
196 return (0);
197}
198
199static void

--- 39 unchanged lines hidden (view full) ---

239 }
240
241 if (msr & RUEPHY_MSR_SPEED100)
242 mii->mii_media_active |= IFM_100_TX;
243 else
244 mii->mii_media_active |= IFM_10_T;
245
246 if (msr & RUEPHY_MSR_DUPLEX)
172
173 /* Callback if something changed. */
174 mii_phy_update(sc, cmd);
175
176 return (0);
177}
178
179static void

--- 39 unchanged lines hidden (view full) ---

219 }
220
221 if (msr & RUEPHY_MSR_SPEED100)
222 mii->mii_media_active |= IFM_100_TX;
223 else
224 mii->mii_media_active |= IFM_10_T;
225
226 if (msr & RUEPHY_MSR_DUPLEX)
247 mii->mii_media_active |= IFM_FDX;
227 mii->mii_media_active |=
228 IFM_FDX | mii_phy_flowstatus(phy);
248 else
249 mii->mii_media_active |= IFM_HDX;
250 } else
251 mii->mii_media_active = ife->ifm_media;
252}
229 else
230 mii->mii_media_active |= IFM_HDX;
231 } else
232 mii->mii_media_active = ife->ifm_media;
233}