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

Function rt_genphy_config_aneg

components/drivers/phy/general.c:118–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118int rt_genphy_config_aneg(struct rt_phy_device *phydev)
119{
120 int result;
121 int err;
122 int ctl = RT_BMCR_ANRESTART;
123 if (phydev->autoneg != AUTONEG_ENABLE)
124 {
125 phydev->pause = 0;
126
127 if (phydev->speed == SPEED_1000)
128 ctl |= RT_BMCR_SPEED1000;
129 else if (phydev->speed == SPEED_100)
130 ctl |= RT_BMCR_SPEED100;
131
132 if (phydev->duplex == DUPLEX_FULL)
133 ctl |= RT_BMCR_FULLDPLX;
134
135 err = rt_phy_write(phydev, RT_MDIO_DEVAD_NONE, RT_MII_BMCR, ctl);
136
137 return err;
138 }
139
140 result = __genphy_config_advert(phydev);
141
142 if (result < 0)
143 return result;
144
145 if (result == 0)
146 {
147 int ctl = rt_phy_read(phydev, RT_MDIO_DEVAD_NONE, RT_MII_BMCR);
148
149 if (ctl < 0)
150 return ctl;
151
152 if (!(ctl & RT_BMCR_ANENABLE) || (ctl & RT_BMCR_ISOLATE))
153 result = 1;
154 }
155
156 if (result > 0)
157 result = __genphy_restart_aneg(phydev);
158
159 return result;
160}
161
162int rt_genphy_update_link(struct rt_phy_device *phydev)
163{

Callers 1

rt_genphy_configFunction · 0.85

Calls 4

__genphy_config_advertFunction · 0.85
__genphy_restart_anegFunction · 0.85
rt_phy_writeFunction · 0.70
rt_phy_readFunction · 0.70

Tested by

no test coverage detected