MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / __genphy_auto_neg

Function __genphy_auto_neg

components/drivers/phy/general.c:204–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static void __genphy_auto_neg(struct rt_phy_device *phydev,int mii_reg)
205{
206 rt_uint32_t lpa = 0;
207 int gblpa = 0;
208 rt_uint32_t estatus = 0;
209
210 if (phydev->supported & (RT_SUPPORTED_1000baseT_Full |
211 RT_SUPPORTED_1000baseT_Half))
212 {
213
214 gblpa = rt_phy_read(phydev, RT_MDIO_DEVAD_NONE, RT_MII_STAT1000);
215 if (gblpa < 0)
216 {
217 LOG_D("Could not read RT_MII_STAT1000. Ignoring gigabit capability\n");
218 gblpa = 0;
219 }
220 gblpa &= rt_phy_read(phydev,
221 RT_MDIO_DEVAD_NONE, RT_MII_CTRL1000) << 2;
222 }
223
224 phydev->speed = SPEED_10;
225 phydev->duplex = DUPLEX_HALF;
226
227 if (gblpa & (RT_PHY_1000BTSR_1000FD | RT_PHY_1000BTSR_1000HD))
228 {
229 phydev->speed = SPEED_1000;
230
231 if (gblpa & RT_PHY_1000BTSR_1000FD)
232 phydev->duplex = DUPLEX_FULL;
233
234 return ;
235 }
236
237 lpa = rt_phy_read(phydev, RT_MDIO_DEVAD_NONE, RT_MII_ADVERTISE);
238 lpa &= rt_phy_read(phydev, RT_MDIO_DEVAD_NONE, RT_MII_LPA);
239
240 if (lpa & (RT_LINK_PARTNER__100FULL | RT_LINK_PARTNER__100HALF))
241 {
242 phydev->speed = SPEED_100;
243
244 if (lpa & RT_LINK_PARTNER__100FULL)
245 phydev->duplex = DUPLEX_FULL;
246
247 } else if (lpa & RT_LINK_PARTNER__10FULL)
248 {
249 phydev->duplex = DUPLEX_FULL;
250 }
251
252 if ((mii_reg & RT_BMSR_ESTATEN) && !(mii_reg & RT_BMSR_ERCAP))
253 estatus = rt_phy_read(phydev, RT_MDIO_DEVAD_NONE,
254 RT_MII_ESTATUS);
255
256 if (estatus & (RT_SUPORT_1000B_XFULL | RT_SUPORT_1000B_XHALF |
257 RT_SUPORT_1000B_TFULL | RT_SUPORT_1000B_THALF))
258 {
259 phydev->speed = SPEED_1000;
260 if (estatus & (RT_SUPORT_1000B_XFULL | RT_SUPORT_1000B_TFULL))
261 phydev->duplex = DUPLEX_FULL;

Callers 1

rt_genphy_parse_linkFunction · 0.85

Calls 1

rt_phy_readFunction · 0.70

Tested by

no test coverage detected