Deleted Added
full compact
3c3
< Copyright (c) 2001-2011, Intel Corporation
---
> Copyright (c) 2001-2012, Intel Corporation
33c33
< /*$FreeBSD: head/sys/dev/e1000/e1000_phy.c 228386 2011-12-10 06:55:02Z jfv $*/
---
> /*$FreeBSD: head/sys/dev/e1000/e1000_phy.c 238148 2012-07-05 20:26:57Z jfv $*/
98,99c98,99
< phy->ops.read_i2c_byte = e1000_read_i2c_byte_generic;
< phy->ops.write_i2c_byte = e1000_write_i2c_byte_generic;
---
> phy->ops.read_i2c_byte = e1000_read_i2c_byte_null;
> phy->ops.write_i2c_byte = e1000_write_i2c_byte_null;
153a154,183
> * e1000_read_i2c_byte_null - No-op function, return 0
> * @hw: pointer to hardware structure
> * @byte_offset: byte offset to write
> * @dev_addr: device address
> * @data: data value read
> *
> **/
> s32 e1000_read_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset,
> u8 dev_addr, u8 *data)
> {
> DEBUGFUNC("e1000_read_i2c_byte_null");
> return E1000_SUCCESS;
> }
>
> /**
> * e1000_write_i2c_byte_null - No-op function, return 0
> * @hw: pointer to hardware structure
> * @byte_offset: byte offset to write
> * @dev_addr: device address
> * @data: data value to write
> *
> **/
> s32 e1000_write_i2c_byte_null(struct e1000_hw *hw, u8 byte_offset,
> u8 dev_addr, u8 data)
> {
> DEBUGFUNC("e1000_write_i2c_byte_null");
> return E1000_SUCCESS;
> }
>
> /**
189,190c219,220
< if (!(phy->ops.read_reg))
< goto out;
---
> if (!phy->ops.read_reg)
> return E1000_SUCCESS;
195c225
< goto out;
---
> return ret_val;
201c231
< goto out;
---
> return ret_val;
207c237
< goto out;
---
> return E1000_SUCCESS;
211,212c241,242
< out:
< return ret_val;
---
>
> return E1000_SUCCESS;
223c253
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
227,228c257,258
< if (!(hw->phy.ops.write_reg))
< goto out;
---
> if (!hw->phy.ops.write_reg)
> return E1000_SUCCESS;
232c262
< goto out;
---
> return ret_val;
234,237c264
< ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0);
<
< out:
< return ret_val;
---
> return hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0);
253d279
< s32 ret_val = E1000_SUCCESS;
286,287c312
< ret_val = -E1000_ERR_PHY;
< goto out;
---
> return -E1000_ERR_PHY;
291,292c316
< ret_val = -E1000_ERR_PHY;
< goto out;
---
> return -E1000_ERR_PHY;
303,304c327
< out:
< return ret_val;
---
> return E1000_SUCCESS;
319d341
< s32 ret_val = E1000_SUCCESS;
353,354c375
< ret_val = -E1000_ERR_PHY;
< goto out;
---
> return -E1000_ERR_PHY;
358,359c379
< ret_val = -E1000_ERR_PHY;
< goto out;
---
> return -E1000_ERR_PHY;
369,370c389
< out:
< return ret_val;
---
> return E1000_SUCCESS;
624c643
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
628,629c647,648
< if (!(hw->phy.ops.acquire))
< goto out;
---
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
633c652
< goto out;
---
> return ret_val;
640d658
< out:
655c673
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
659,660c677,678
< if (!(hw->phy.ops.acquire))
< goto out;
---
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
664c682
< goto out;
---
> return ret_val;
671d688
< out:
714,715c731,732
< if (!(hw->phy.ops.acquire))
< goto out;
---
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
719c736
< goto out;
---
> return ret_val;
722c739
< if (offset > MAX_PHY_MULTI_PAGE_REG) {
---
> if (offset > MAX_PHY_MULTI_PAGE_REG)
726,733c743,746
< if (ret_val)
< goto release;
< }
<
< ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
< data);
<
< release:
---
> if (!ret_val)
> ret_val = e1000_read_phy_reg_mdic(hw,
> MAX_PHY_REG_ADDRESS & offset,
> data);
736c749
< out:
---
>
787,788c800,801
< if (!(hw->phy.ops.acquire))
< goto out;
---
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
792c805
< goto out;
---
> return ret_val;
795c808
< if (offset > MAX_PHY_MULTI_PAGE_REG) {
---
> if (offset > MAX_PHY_MULTI_PAGE_REG)
799,806c812,815
< if (ret_val)
< goto release;
< }
<
< ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
< data);
<
< release:
---
> if (!ret_val)
> ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS &
> offset,
> data);
810d818
< out:
857d864
< s32 ret_val = E1000_SUCCESS;
862,863c869
< if (!(hw->phy.ops.acquire))
< goto out;
---
> s32 ret_val = E1000_SUCCESS;
864a871,873
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
>
867c876
< goto out;
---
> return ret_val;
883,884c892
< out:
< return ret_val;
---
> return E1000_SUCCESS;
932d939
< s32 ret_val = E1000_SUCCESS;
937,938c944
< if (!(hw->phy.ops.acquire))
< goto out;
---
> s32 ret_val = E1000_SUCCESS;
939a946,948
> if (!hw->phy.ops.acquire)
> return E1000_SUCCESS;
>
942c951
< goto out;
---
> return ret_val;
955,956c964
< out:
< return ret_val;
---
> return E1000_SUCCESS;
987a996,1035
> * e1000_set_master_slave_mode - Setup PHY for Master/slave mode
> * @hw: pointer to the HW structure
> *
> * Sets up Master/slave mode
> **/
> static s32 e1000_set_master_slave_mode(struct e1000_hw *hw)
> {
> s32 ret_val;
> u16 phy_data;
>
> /* Resolve Master/Slave mode */
> ret_val = hw->phy.ops.read_reg(hw, PHY_1000T_CTRL, &phy_data);
> if (ret_val)
> return ret_val;
>
> /* load defaults for future use */
> hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ?
> ((phy_data & CR_1000T_MS_VALUE) ?
> e1000_ms_force_master :
> e1000_ms_force_slave) : e1000_ms_auto;
>
> switch (hw->phy.ms_type) {
> case e1000_ms_force_master:
> phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
> break;
> case e1000_ms_force_slave:
> phy_data |= CR_1000T_MS_ENABLE;
> phy_data &= ~(CR_1000T_MS_VALUE);
> break;
> case e1000_ms_auto:
> phy_data &= ~CR_1000T_MS_ENABLE;
> /* fall-through */
> default:
> break;
> }
>
> return hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data);
> }
>
> /**
1004c1052
< goto out;
---
> return ret_val;
1011c1059
< goto out;
---
> return ret_val;
1020c1068
< goto out;
---
> return ret_val;
1022,1023c1070,1071
< /* Resolve Master/Slave mode */
< ret_val = hw->phy.ops.read_reg(hw, PHY_1000T_CTRL, &phy_data);
---
> /* Set MDI/MDIX mode */
> ret_val = hw->phy.ops.read_reg(hw, I82577_PHY_CTRL_2, &phy_data);
1025,1035c1073,1082
< goto out;
<
< /* load defaults for future use */
< hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ?
< ((phy_data & CR_1000T_MS_VALUE) ?
< e1000_ms_force_master :
< e1000_ms_force_slave) : e1000_ms_auto;
<
< switch (hw->phy.ms_type) {
< case e1000_ms_force_master:
< phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
---
> return ret_val;
> phy_data &= ~I82577_PHY_CTRL2_MDIX_CFG_MASK;
> /*
> * Options:
> * 0 - Auto (default)
> * 1 - MDI mode
> * 2 - MDI-X mode
> */
> switch (hw->phy.mdix) {
> case 1:
1037,1039c1084,1085
< case e1000_ms_force_slave:
< phy_data |= CR_1000T_MS_ENABLE;
< phy_data &= ~(CR_1000T_MS_VALUE);
---
> case 2:
> phy_data |= I82577_PHY_CTRL2_MANUAL_MDIX;
1041,1042c1087
< case e1000_ms_auto:
< phy_data &= ~CR_1000T_MS_ENABLE;
---
> case 0:
1043a1089
> phy_data |= I82577_PHY_CTRL2_AUTO_MDI_MDIX;
1046,1047c1092
<
< ret_val = hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data);
---
> ret_val = hw->phy.ops.write_reg(hw, I82577_PHY_CTRL_2, phy_data);
1049c1094
< goto out;
---
> return ret_val;
1051,1052c1096
< out:
< return ret_val;
---
> return e1000_set_master_slave_mode(hw);
1074c1118
< goto out;
---
> return ret_val;
1114c1158
< if (phy->disable_polarity_correction == 1)
---
> if (phy->disable_polarity_correction)
1118c1162,1177
< if (phy->type == e1000_phy_bm)
---
> if (phy->type == e1000_phy_bm) {
> /* For 82574/82583, first disable then enable downshift */
> if (phy->id == BME1000_E_PHY_ID_R2) {
> phy_data &= ~BME1000_PSCR_ENABLE_DOWNSHIFT;
> ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL,
> phy_data);
> if (ret_val)
> return ret_val;
> /* Commit the changes. */
> ret_val = phy->ops.commit(hw);
> if (ret_val) {
> DEBUGOUT("Error committing the PHY changes\n");
> return ret_val;
> }
> }
>
1119a1179
> }
1123c1183
< goto out;
---
> return ret_val;
1135c1195
< goto out;
---
> return ret_val;
1154c1214
< goto out;
---
> return ret_val;
1161c1221
< goto out;
---
> return ret_val;
1166c1226
< goto out;
---
> return ret_val;
1173c1233
< goto out;
---
> return ret_val;
1180c1240
< goto out;
---
> return ret_val;
1188c1248
< goto out;
---
> return ret_val;
1191,1192c1251,1257
< out:
< return ret_val;
---
> if (phy->type == e1000_phy_i210) {
> ret_val = e1000_set_master_slave_mode(hw);
> if (ret_val)
> return ret_val;
> }
>
> return E1000_SUCCESS;
1214c1279
< goto out;
---
> return ret_val;
1253c1318
< if (phy->disable_polarity_correction == 1)
---
> if (phy->disable_polarity_correction)
1263c1328
< goto out;
---
> return ret_val;
1269c1334
< goto out;
---
> return ret_val;
1272,1273c1337
< out:
< return ret_val;
---
> return E1000_SUCCESS;
1295c1359
< goto out;
---
> return ret_val;
1313c1377
< goto out;
---
> return ret_val;
1322c1386
< goto out;
---
> return ret_val;
1328c1392
< goto out;
---
> return ret_val;
1346c1410
< goto out;
---
> return ret_val;
1361c1425
< goto out;
---
> return ret_val;
1368c1432
< goto out;
---
> return ret_val;
1373c1437
< goto out;
---
> return ret_val;
1378c1442
< goto out;
---
> return ret_val;
1381,1407c1445
< ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data);
< if (ret_val)
< goto out;
<
< /* load defaults for future use */
< phy->original_ms_type = (data & CR_1000T_MS_ENABLE) ?
< ((data & CR_1000T_MS_VALUE) ?
< e1000_ms_force_master :
< e1000_ms_force_slave) :
< e1000_ms_auto;
<
< switch (phy->ms_type) {
< case e1000_ms_force_master:
< data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
< break;
< case e1000_ms_force_slave:
< data |= CR_1000T_MS_ENABLE;
< data &= ~(CR_1000T_MS_VALUE);
< break;
< case e1000_ms_auto:
< data &= ~CR_1000T_MS_ENABLE;
< default:
< break;
< }
< ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data);
< if (ret_val)
< goto out;
---
> ret_val = e1000_set_master_slave_mode(hw);
1410d1447
< out:
1415,1483d1451
< * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
< * @hw: pointer to the HW structure
< *
< * Performs initial bounds checking on autoneg advertisement parameter, then
< * configure to advertise the full capability. Setup the PHY to autoneg
< * and restart the negotiation process between the link partner. If
< * autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
< **/
< s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
< {
< struct e1000_phy_info *phy = &hw->phy;
< s32 ret_val;
< u16 phy_ctrl;
<
< DEBUGFUNC("e1000_copper_link_autoneg");
<
< /*
< * Perform some bounds checking on the autoneg advertisement
< * parameter.
< */
< phy->autoneg_advertised &= phy->autoneg_mask;
<
< /*
< * If autoneg_advertised is zero, we assume it was not defaulted
< * by the calling code so we set to advertise full capability.
< */
< if (phy->autoneg_advertised == 0)
< phy->autoneg_advertised = phy->autoneg_mask;
<
< DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
< ret_val = e1000_phy_setup_autoneg(hw);
< if (ret_val) {
< DEBUGOUT("Error Setting up Auto-Negotiation\n");
< goto out;
< }
< DEBUGOUT("Restarting Auto-Neg\n");
<
< /*
< * Restart auto-negotiation by setting the Auto Neg Enable bit and
< * the Auto Neg Restart bit in the PHY control register.
< */
< ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl);
< if (ret_val)
< goto out;
<
< phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
< ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl);
< if (ret_val)
< goto out;
<
< /*
< * Does the user want to wait for Auto-Neg to complete here, or
< * check at a later time (for example, callback routine).
< */
< if (phy->autoneg_wait_to_complete) {
< ret_val = hw->mac.ops.wait_autoneg(hw);
< if (ret_val) {
< DEBUGOUT("Error while waiting for autoneg to complete\n");
< goto out;
< }
< }
<
< hw->mac.get_link_status = TRUE;
<
< out:
< return ret_val;
< }
<
< /**
1506c1474
< goto out;
---
> return ret_val;
1513c1481
< goto out;
---
> return ret_val;
1627,1628c1595
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
1633c1600
< goto out;
---
> return ret_val;
1637c1604
< if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
---
> if (phy->autoneg_mask & ADVERTISE_1000_FULL)
1640,1641c1607,1645
< if (ret_val)
< goto out;
---
>
> return ret_val;
> }
>
> /**
> * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
> * @hw: pointer to the HW structure
> *
> * Performs initial bounds checking on autoneg advertisement parameter, then
> * configure to advertise the full capability. Setup the PHY to autoneg
> * and restart the negotiation process between the link partner. If
> * autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
> **/
> s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
> {
> struct e1000_phy_info *phy = &hw->phy;
> s32 ret_val;
> u16 phy_ctrl;
>
> DEBUGFUNC("e1000_copper_link_autoneg");
>
> /*
> * Perform some bounds checking on the autoneg advertisement
> * parameter.
> */
> phy->autoneg_advertised &= phy->autoneg_mask;
>
> /*
> * If autoneg_advertised is zero, we assume it was not defaulted
> * by the calling code so we set to advertise full capability.
> */
> if (!phy->autoneg_advertised)
> phy->autoneg_advertised = phy->autoneg_mask;
>
> DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
> ret_val = e1000_phy_setup_autoneg(hw);
> if (ret_val) {
> DEBUGOUT("Error Setting up Auto-Negotiation\n");
> return ret_val;
1642a1647
> DEBUGOUT("Restarting Auto-Neg\n");
1644c1649,1675
< out:
---
> /*
> * Restart auto-negotiation by setting the Auto Neg Enable bit and
> * the Auto Neg Restart bit in the PHY control register.
> */
> ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl);
> if (ret_val)
> return ret_val;
>
> phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
> ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl);
> if (ret_val)
> return ret_val;
>
> /*
> * Does the user want to wait for Auto-Neg to complete here, or
> * check at a later time (for example, callback routine).
> */
> if (phy->autoneg_wait_to_complete) {
> ret_val = hw->mac.ops.wait_autoneg(hw);
> if (ret_val) {
> DEBUGOUT("Error while waiting for autoneg to complete\n");
> return ret_val;
> }
> }
>
> hw->mac.get_link_status = TRUE;
>
1671c1702
< goto out;
---
> return ret_val;
1681c1712
< goto out;
---
> return ret_val;
1692c1723
< goto out;
---
> return ret_val;
1696c1727
< e1000_config_collision_dist_generic(hw);
---
> hw->mac.ops.config_collision_dist(hw);
1702d1732
< out:
1725c1755
< goto out;
---
> return ret_val;
1731c1761
< goto out;
---
> return ret_val;
1739c1769
< goto out;
---
> return ret_val;
1746c1776
< goto out;
---
> return ret_val;
1758c1788
< goto out;
---
> return ret_val;
1766,1767d1795
< if (ret_val)
< goto out;
1770d1797
< out:
1799c1826
< goto out;
---
> return ret_val;
1804c1831
< goto out;
---
> return ret_val;
1810c1837
< goto out;
---
> return ret_val;
1816c1843
< goto out;
---
> return ret_val;
1821c1848
< goto out;
---
> return ret_val;
1829c1856
< goto out;
---
> return ret_val;
1832,1835c1859,1874
< if (hw->phy.type != e1000_phy_m88 ||
< hw->phy.id == I347AT4_E_PHY_ID ||
< hw->phy.id == M88E1340M_E_PHY_ID ||
< hw->phy.id == M88E1112_E_PHY_ID) {
---
> bool reset_dsp = TRUE;
>
> switch (hw->phy.id) {
> case I347AT4_E_PHY_ID:
> case M88E1340M_E_PHY_ID:
> case M88E1112_E_PHY_ID:
> case I210_I_PHY_ID:
> reset_dsp = FALSE;
> break;
> default:
> if (hw->phy.type != e1000_phy_m88)
> reset_dsp = FALSE;
> break;
> }
>
> if (!reset_dsp) {
1846c1885
< goto out;
---
> return ret_val;
1849c1888
< goto out;
---
> return ret_val;
1857c1896
< goto out;
---
> return ret_val;
1860,1864c1899,1900
< if (hw->phy.type != e1000_phy_m88 ||
< hw->phy.id == I347AT4_E_PHY_ID ||
< hw->phy.id == M88E1340M_E_PHY_ID ||
< hw->phy.id == M88E1112_E_PHY_ID)
< goto out;
---
> if (hw->phy.type != e1000_phy_m88)
> return E1000_SUCCESS;
1865a1902,1907
> if (hw->phy.id == I347AT4_E_PHY_ID ||
> hw->phy.id == M88E1340M_E_PHY_ID ||
> hw->phy.id == M88E1112_E_PHY_ID)
> return E1000_SUCCESS;
> if (hw->phy.id == I210_I_PHY_ID)
> return E1000_SUCCESS;
1868c1910
< goto out;
---
> return ret_val;
1878c1920
< goto out;
---
> return ret_val;
1886c1928
< goto out;
---
> return ret_val;
1891d1932
< out:
1914c1955
< goto out;
---
> return ret_val;
1920c1961
< goto out;
---
> return ret_val;
1925c1966
< goto out;
---
> return ret_val;
1932c1973
< goto out;
---
> return ret_val;
1944c1985
< goto out;
---
> return ret_val;
1953c1994
< goto out;
---
> return ret_val;
1956,1957c1997
< out:
< return ret_val;
---
> return E1000_SUCCESS;
2017c2057
< e1000_config_collision_dist_generic(hw);
---
> hw->mac.ops.config_collision_dist(hw);
2039c2079
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
2044,2045c2084,2085
< if (!(hw->phy.ops.read_reg))
< goto out;
---
> if (!hw->phy.ops.read_reg)
> return E1000_SUCCESS;
2049c2089
< goto out;
---
> return ret_val;
2056c2096
< goto out;
---
> return ret_val;
2068c2108
< goto out;
---
> return ret_val;
2075c2115
< goto out;
---
> return ret_val;
2081c2121
< goto out;
---
> return ret_val;
2088c2128
< goto out;
---
> return ret_val;
2097c2137
< goto out;
---
> return ret_val;
2103c2143
< goto out;
---
> return ret_val;
2110d2149
< out:
2130a2170
> case e1000_phy_i210:
2147,2148c2187
< ret_val = E1000_SUCCESS;
< goto out;
---
> return E1000_SUCCESS;
2154c2193
< phy->speed_downgraded = (phy_data & mask) ? TRUE : FALSE;
---
> phy->speed_downgraded = !!(phy_data & mask);
2156d2194
< out:
2209c2247
< goto out;
---
> return ret_val;
2231d2268
< out:
2284c2321
< if (!(hw->phy.ops.read_reg))
---
> if (!hw->phy.ops.read_reg)
2324c2361
< if (!(hw->phy.ops.read_reg))
---
> if (!hw->phy.ops.read_reg)
2352c2389
< *success = (i < iterations) ? TRUE : FALSE;
---
> *success = (i < iterations);
2382c2419
< goto out;
---
> return ret_val;
2386,2389d2422
< if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) {
< ret_val = -E1000_ERR_PHY;
< goto out;
< }
2390a2424,2426
> if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1)
> return -E1000_ERR_PHY;
>
2396,2397c2432
< out:
< return ret_val;
---
> return E1000_SUCCESS;
2408a2444,2464
> case I210_I_PHY_ID:
> /* Get cable length from PHY Cable Diagnostics Control Reg */
> ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) +
> (I347AT4_PCDL + phy->addr),
> &phy_data);
> if (ret_val)
> return ret_val;
>
> /* Check if the unit of cable length is meters or cm */
> ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) +
> I347AT4_PCDC, &phy_data2);
> if (ret_val)
> return ret_val;
>
> is_cm = !(phy_data2 & I347AT4_PCDC_CABLE_LENGTH_UNIT);
>
> /* Populate the phy structure with cable length in meters */
> phy->min_cable_length = phy_data / (is_cm ? 100 : 1);
> phy->max_cable_length = phy_data / (is_cm ? 100 : 1);
> phy->cable_length = phy_data / (is_cm ? 100 : 1);
> break;
2415c2471
< goto out;
---
> return ret_val;
2419c2475
< goto out;
---
> return ret_val;
2425c2481
< goto out;
---
> return ret_val;
2430c2486
< goto out;
---
> return ret_val;
2443c2499
< goto out;
---
> return ret_val;
2444a2501
>
2450c2507
< goto out;
---
> return ret_val;
2454c2511
< goto out;
---
> return ret_val;
2459c2516
< goto out;
---
> return ret_val;
2463,2466d2519
< if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) {
< ret_val = -E1000_ERR_PHY;
< goto out;
< }
2467a2521,2523
> if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1)
> return -E1000_ERR_PHY;
>
2478c2534
< goto out;
---
> return ret_val;
2482,2483c2538
< ret_val = -E1000_ERR_PHY;
< goto out;
---
> return -E1000_ERR_PHY;
2486d2540
< out:
2504c2558
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
2521c2575
< goto out;
---
> return ret_val;
2534,2537c2588,2589
< (cur_agc_index == 0)) {
< ret_val = -E1000_ERR_PHY;
< goto out;
< }
---
> (cur_agc_index == 0))
> return -E1000_ERR_PHY;
2561,2562c2613
< out:
< return ret_val;
---
> return E1000_SUCCESS;
2586,2587c2637
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
2592c2642
< goto out;
---
> return ret_val;
2596,2597c2646
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
2602c2651
< goto out;
---
> return ret_val;
2604,2605c2653,2654
< phy->polarity_correction = (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
< ? TRUE : FALSE;
---
> phy->polarity_correction = !!(phy_data &
> M88E1000_PSCR_POLARITY_REVERSAL);
2609c2658
< goto out;
---
> return ret_val;
2613c2662
< goto out;
---
> return ret_val;
2615c2664
< phy->is_mdix = (phy_data & M88E1000_PSSR_MDIX) ? TRUE : FALSE;
---
> phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX);
2620c2669
< goto out;
---
> return ret_val;
2624c2673
< goto out;
---
> return ret_val;
2640d2688
< out:
2664c2712
< goto out;
---
> return ret_val;
2668,2669c2716
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
2676c2723
< goto out;
---
> return ret_val;
2680c2727
< goto out;
---
> return ret_val;
2682c2729
< phy->is_mdix = (data & IGP01E1000_PSSR_MDIX) ? TRUE : FALSE;
---
> phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX);
2688c2735
< goto out;
---
> return ret_val;
2692c2739
< goto out;
---
> return ret_val;
2707d2753
< out:
2728c2774
< goto out;
---
> return ret_val;
2732,2733c2778
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
2738,2740c2783,2784
< goto out;
< phy->polarity_correction = (data & IFE_PSC_AUTO_POLARITY_DISABLE)
< ? FALSE : TRUE;
---
> return ret_val;
> phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE);
2745c2789
< goto out;
---
> return ret_val;
2755c2799
< goto out;
---
> return ret_val;
2757c2801
< phy->is_mdix = (data & IFE_PMC_MDIX_STATUS) ? TRUE : FALSE;
---
> phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS);
2764,2765c2808
< out:
< return ret_val;
---
> return E1000_SUCCESS;
2777c2820
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
2782,2783c2825,2826
< if (!(hw->phy.ops.read_reg))
< goto out;
---
> if (!hw->phy.ops.read_reg)
> return E1000_SUCCESS;
2787c2830
< goto out;
---
> return ret_val;
2792c2835
< goto out;
---
> return ret_val;
2796d2838
< out:
2812c2854
< s32 ret_val = E1000_SUCCESS;
---
> s32 ret_val;
2817,2820c2859,2862
< ret_val = phy->ops.check_reset_block(hw);
< if (ret_val) {
< ret_val = E1000_SUCCESS;
< goto out;
---
> if (phy->ops.check_reset_block) {
> ret_val = phy->ops.check_reset_block(hw);
> if (ret_val)
> return E1000_SUCCESS;
2825c2867
< goto out;
---
> return ret_val;
2840,2843c2882
< ret_val = phy->ops.get_cfg_done(hw);
<
< out:
< return ret_val;
---
> return phy->ops.get_cfg_done(hw);
2996a3036,3038
> case I210_I_PHY_ID:
> phy_type = e1000_phy_i210;
> break;
3014d3055
< s32 ret_val = -E1000_ERR_PHY_TYPE;
3033,3036c3074,3076
< if (phy_type != e1000_phy_unknown) {
< ret_val = E1000_SUCCESS;
< goto out;
< }
---
> if (phy_type != e1000_phy_unknown)
> return E1000_SUCCESS;
>
3042,3043c3082
< out:
< return ret_val;
---
> return -E1000_ERR_PHY_TYPE;
3086c3125
< goto out;
---
> goto release;
3111c3150
< goto out;
---
> goto release;
3117c3156
< out:
---
> release:
3147c3186
< goto out;
---
> goto release;
3172c3211
< goto out;
---
> goto release;
3177c3216
< out:
---
> release:
3207c3246
< goto out;
---
> goto release;
3219c3258
< goto out;
---
> goto release;
3224c3263
< out:
---
> release:
3253c3292
< goto out;
---
> goto release;
3264c3303
< goto out;
---
> goto release;
3270c3309
< out:
---
> release:
3290,3293c3329,3330
< if (!phy_reg) {
< ret_val = -E1000_ERR_PARAM;
< goto out;
< }
---
> if (!phy_reg)
> return -E1000_ERR_PARAM;
3302c3339
< goto out;
---
> return ret_val;
3309c3346
< goto out;
---
> return ret_val;
3324c3361
< goto out;
---
> return ret_val;
3327,3332c3364,3368
< /* Select Host Wakeup Registers page */
< ret_val = e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT));
<
< /* caller now able to write registers on the Wakeup registers page */
< out:
< return ret_val;
---
> /*
> * Select Host Wakeup Registers page - caller now able to write
> * registers on the Wakeup registers page
> */
> return e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT));
3359c3395
< goto out;
---
> return ret_val;
3367c3403
< out:
---
>
3416c3452
< goto out;
---
> return ret_val;
3426c3462
< goto out;
---
> return ret_val;
3441c3477
< goto out;
---
> return ret_val;
3447d3482
< out:
3461a3497
> u16 power_reg = 0;
3465a3502,3506
> if (hw->phy.type == e1000_phy_i210) {
> hw->phy.ops.read_reg(hw, GS40G_COPPER_SPEC, &power_reg);
> power_reg &= ~GS40G_CS_POWER_DOWN;
> hw->phy.ops.write_reg(hw, GS40G_COPPER_SPEC, power_reg);
> }
3479a3521
> u16 power_reg = 0;
3483a3526,3531
> /* i210 Phy requires an additional bit for power up/down */
> if (hw->phy.type == e1000_phy_i210) {
> hw->phy.ops.read_reg(hw, GS40G_COPPER_SPEC, &power_reg);
> power_reg |= GS40G_CS_POWER_DOWN;
> hw->phy.ops.write_reg(hw, GS40G_COPPER_SPEC, power_reg);
> }
3649c3697
< ((MAX_PHY_REG_ADDRESS & reg) == 0) &&
---
> !(MAX_PHY_REG_ADDRESS & reg) &&
3773c3821
< goto out;
---
> return ret_val;
3782c3830
< if (ret_val) {
---
> if (ret_val)
3784,3785d3831
< goto out;
< }
3787d3832
< out:
3810c3855
< goto out;
---
> return E1000_SUCCESS;
3815c3860
< goto out;
---
> return E1000_SUCCESS;
3820c3865
< goto out;
---
> return ret_val;
3827c3872
< goto out;
---
> return E1000_SUCCESS;
3836c3881
< goto out;
---
> return ret_val;
3838,3842c3883,3884
< ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL,
< HV_MUX_DATA_CTRL_GEN_TO_MAC);
<
< out:
< return ret_val;
---
> return hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL,
> HV_MUX_DATA_CTRL_GEN_TO_MAC);
3888c3930
< goto out;
---
> return ret_val;
3894c3936
< goto out;
---
> return ret_val;
3904c3946
< goto out;
---
> return ret_val;
3912,3913d3953
< if (ret_val)
< goto out;
3916d3955
< out:
3940c3979
< goto out;
---
> return ret_val;
3944,3945c3983
< ret_val = -E1000_ERR_CONFIG;
< goto out;
---
> return -E1000_ERR_CONFIG;
3952c3990
< goto out;
---
> return ret_val;
3956c3994
< goto out;
---
> return ret_val;
3958c3996
< phy->is_mdix = (data & I82577_PHY_STATUS2_MDIX) ? TRUE : FALSE;
---
> phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX);
3964c4002
< goto out;
---
> return ret_val;
3968c4006
< goto out;
---
> return ret_val;
3983,3984c4021
< out:
< return ret_val;
---
> return E1000_SUCCESS;
4004c4041
< goto out;
---
> return ret_val;
4014c4051,4081
< out:
---
> return E1000_SUCCESS;
> }
>
> /**
> * e1000_write_phy_reg_gs40g - Write GS40G PHY register
> * @hw: pointer to the HW structure
> * @offset: register offset to write to
> * @data: data to write at register offset
> *
> * Acquires semaphore, if necessary, then writes the data to PHY register
> * at the offset. Release any acquired semaphores before exiting.
> **/
> s32 e1000_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data)
> {
> s32 ret_val;
> u16 page = offset >> GS40G_PAGE_SHIFT;
>
> DEBUGFUNC("e1000_write_phy_reg_gs40g");
>
> offset = offset & GS40G_OFFSET_MASK;
> ret_val = hw->phy.ops.acquire(hw);
> if (ret_val)
> return ret_val;
>
> ret_val = e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page);
> if (ret_val)
> goto release;
> ret_val = e1000_write_phy_reg_mdic(hw, offset, data);
>
> release:
> hw->phy.ops.release(hw);
4016a4084,4115
>
> /**
> * e1000_read_phy_reg_gs40g - Read GS40G PHY register
> * @hw: pointer to the HW structure
> * @offset: lower half is register offset to read to
> * upper half is page to use.
> * @data: data to read at register offset
> *
> * Acquires semaphore, if necessary, then reads the data in the PHY register
> * at the offset. Release any acquired semaphores before exiting.
> **/
> s32 e1000_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data)
> {
> s32 ret_val;
> u16 page = offset >> GS40G_PAGE_SHIFT;
>
> DEBUGFUNC("e1000_read_phy_reg_gs40g");
>
> offset = offset & GS40G_OFFSET_MASK;
> ret_val = hw->phy.ops.acquire(hw);
> if (ret_val)
> return ret_val;
>
> ret_val = e1000_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page);
> if (ret_val)
> goto release;
> ret_val = e1000_read_phy_reg_mdic(hw, offset, data);
>
> release:
> hw->phy.ops.release(hw);
> return ret_val;
> }