| 116 | } |
| 117 | |
| 118 | int 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 | |
| 162 | int rt_genphy_update_link(struct rt_phy_device *phydev) |
| 163 | { |
no test coverage detected