aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2009-10-05 02:35:03 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-06 17:59:23 -0400
commit81fadd81a5bc897c8d0424d1cd90cb999d8e12b0 (patch)
treef0b71e08c7818f1c5a6e711ea5c2b2e5c71379eb
parent285b4167458ec7cc49008b2e61cbe0362deed335 (diff)
igb: move the generic copper link setup code into e1000_phy.c
This patch moves the generic portion of the copper link setup into a seperate function in e1000_phy.c. This helps to reduce the size of copper_link_setup_82575 and make it a bit more readable. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/igb/e1000_82575.c40
-rw-r--r--drivers/net/igb/e1000_phy.c61
-rw-r--r--drivers/net/igb/e1000_phy.h2
3 files changed, 62 insertions, 41 deletions
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 45063c25155a..5d345e3036a4 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -907,7 +907,6 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
907{ 907{
908 u32 ctrl; 908 u32 ctrl;
909 s32 ret_val; 909 s32 ret_val;
910 bool link;
911 910
912 ctrl = rd32(E1000_CTRL); 911 ctrl = rd32(E1000_CTRL);
913 ctrl |= E1000_CTRL_SLU; 912 ctrl |= E1000_CTRL_SLU;
@@ -940,44 +939,7 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
940 if (ret_val) 939 if (ret_val)
941 goto out; 940 goto out;
942 941
943 if (hw->mac.autoneg) { 942 ret_val = igb_setup_copper_link(hw);
944 /*
945 * Setup autoneg and flow control advertisement
946 * and perform autonegotiation.
947 */
948 ret_val = igb_copper_link_autoneg(hw);
949 if (ret_val)
950 goto out;
951 } else {
952 /*
953 * PHY will be set to 10H, 10F, 100H or 100F
954 * depending on user settings.
955 */
956 hw_dbg("Forcing Speed and Duplex\n");
957 ret_val = hw->phy.ops.force_speed_duplex(hw);
958 if (ret_val) {
959 hw_dbg("Error Forcing Speed and Duplex\n");
960 goto out;
961 }
962 }
963
964 /*
965 * Check link status. Wait up to 100 microseconds for link to become
966 * valid.
967 */
968 ret_val = igb_phy_has_link(hw, COPPER_LINK_UP_LIMIT, 10, &link);
969 if (ret_val)
970 goto out;
971
972 if (link) {
973 hw_dbg("Valid link established!!!\n");
974 /* Config the MAC and PHY after link is up */
975 igb_config_collision_dist(hw);
976 ret_val = igb_config_fc_after_link_up(hw);
977 } else {
978 hw_dbg("Unable to establish link!!!\n");
979 }
980
981out: 943out:
982 return ret_val; 944 return ret_val;
983} 945}
diff --git a/drivers/net/igb/e1000_phy.c b/drivers/net/igb/e1000_phy.c
index d4c928ccb294..b27275d7ff6d 100644
--- a/drivers/net/igb/e1000_phy.c
+++ b/drivers/net/igb/e1000_phy.c
@@ -669,7 +669,7 @@ out:
669 * and restart the negotiation process between the link partner. If 669 * and restart the negotiation process between the link partner. If
670 * autoneg_wait_to_complete, then wait for autoneg to complete before exiting. 670 * autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
671 **/ 671 **/
672s32 igb_copper_link_autoneg(struct e1000_hw *hw) 672static s32 igb_copper_link_autoneg(struct e1000_hw *hw)
673{ 673{
674 struct e1000_phy_info *phy = &hw->phy; 674 struct e1000_phy_info *phy = &hw->phy;
675 s32 ret_val; 675 s32 ret_val;
@@ -893,6 +893,65 @@ out:
893} 893}
894 894
895/** 895/**
896 * igb_setup_copper_link - Configure copper link settings
897 * @hw: pointer to the HW structure
898 *
899 * Calls the appropriate function to configure the link for auto-neg or forced
900 * speed and duplex. Then we check for link, once link is established calls
901 * to configure collision distance and flow control are called. If link is
902 * not established, we return -E1000_ERR_PHY (-2).
903 **/
904s32 igb_setup_copper_link(struct e1000_hw *hw)
905{
906 s32 ret_val;
907 bool link;
908
909
910 if (hw->mac.autoneg) {
911 /*
912 * Setup autoneg and flow control advertisement and perform
913 * autonegotiation.
914 */
915 ret_val = igb_copper_link_autoneg(hw);
916 if (ret_val)
917 goto out;
918 } else {
919 /*
920 * PHY will be set to 10H, 10F, 100H or 100F
921 * depending on user settings.
922 */
923 hw_dbg("Forcing Speed and Duplex\n");
924 ret_val = hw->phy.ops.force_speed_duplex(hw);
925 if (ret_val) {
926 hw_dbg("Error Forcing Speed and Duplex\n");
927 goto out;
928 }
929 }
930
931 /*
932 * Check link status. Wait up to 100 microseconds for link to become
933 * valid.
934 */
935 ret_val = igb_phy_has_link(hw,
936 COPPER_LINK_UP_LIMIT,
937 10,
938 &link);
939 if (ret_val)
940 goto out;
941
942 if (link) {
943 hw_dbg("Valid link established!!!\n");
944 igb_config_collision_dist(hw);
945 ret_val = igb_config_fc_after_link_up(hw);
946 } else {
947 hw_dbg("Unable to establish link!!!\n");
948 }
949
950out:
951 return ret_val;
952}
953
954/**
896 * igb_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY 955 * igb_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
897 * @hw: pointer to the HW structure 956 * @hw: pointer to the HW structure
898 * 957 *
diff --git a/drivers/net/igb/e1000_phy.h b/drivers/net/igb/e1000_phy.h
index 4c49803eeed9..adb9436b7336 100644
--- a/drivers/net/igb/e1000_phy.h
+++ b/drivers/net/igb/e1000_phy.h
@@ -43,7 +43,6 @@ enum e1000_smart_speed {
43 43
44s32 igb_check_downshift(struct e1000_hw *hw); 44s32 igb_check_downshift(struct e1000_hw *hw);
45s32 igb_check_reset_block(struct e1000_hw *hw); 45s32 igb_check_reset_block(struct e1000_hw *hw);
46s32 igb_copper_link_autoneg(struct e1000_hw *hw);
47s32 igb_copper_link_setup_igp(struct e1000_hw *hw); 46s32 igb_copper_link_setup_igp(struct e1000_hw *hw);
48s32 igb_copper_link_setup_m88(struct e1000_hw *hw); 47s32 igb_copper_link_setup_m88(struct e1000_hw *hw);
49s32 igb_phy_force_speed_duplex_igp(struct e1000_hw *hw); 48s32 igb_phy_force_speed_duplex_igp(struct e1000_hw *hw);
@@ -57,6 +56,7 @@ s32 igb_phy_sw_reset(struct e1000_hw *hw);
57s32 igb_phy_hw_reset(struct e1000_hw *hw); 56s32 igb_phy_hw_reset(struct e1000_hw *hw);
58s32 igb_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); 57s32 igb_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data);
59s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active); 58s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active);
59s32 igb_setup_copper_link(struct e1000_hw *hw);
60s32 igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); 60s32 igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
61s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations, 61s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
62 u32 usec_interval, bool *success); 62 u32 usec_interval, bool *success);