aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/phy.c')
-rw-r--r--drivers/net/phy/phy.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 47cd578052fc..b2197b506acb 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -58,6 +58,31 @@ static const char *phy_speed_to_str(int speed)
58 } 58 }
59} 59}
60 60
61#define PHY_STATE_STR(_state) \
62 case PHY_##_state: \
63 return __stringify(_state); \
64
65static const char *phy_state_to_str(enum phy_state st)
66{
67 switch (st) {
68 PHY_STATE_STR(DOWN)
69 PHY_STATE_STR(STARTING)
70 PHY_STATE_STR(READY)
71 PHY_STATE_STR(PENDING)
72 PHY_STATE_STR(UP)
73 PHY_STATE_STR(AN)
74 PHY_STATE_STR(RUNNING)
75 PHY_STATE_STR(NOLINK)
76 PHY_STATE_STR(FORCING)
77 PHY_STATE_STR(CHANGELINK)
78 PHY_STATE_STR(HALTED)
79 PHY_STATE_STR(RESUMING)
80 }
81
82 return NULL;
83}
84
85
61/** 86/**
62 * phy_print_status - Convenience function to print out the current phy status 87 * phy_print_status - Convenience function to print out the current phy status
63 * @phydev: the phy_device struct 88 * @phydev: the phy_device struct
@@ -784,10 +809,13 @@ void phy_state_machine(struct work_struct *work)
784 struct phy_device *phydev = 809 struct phy_device *phydev =
785 container_of(dwork, struct phy_device, state_queue); 810 container_of(dwork, struct phy_device, state_queue);
786 bool needs_aneg = false, do_suspend = false; 811 bool needs_aneg = false, do_suspend = false;
812 enum phy_state old_state;
787 int err = 0; 813 int err = 0;
788 814
789 mutex_lock(&phydev->lock); 815 mutex_lock(&phydev->lock);
790 816
817 old_state = phydev->state;
818
791 if (phydev->drv->link_change_notify) 819 if (phydev->drv->link_change_notify)
792 phydev->drv->link_change_notify(phydev); 820 phydev->drv->link_change_notify(phydev);
793 821
@@ -952,6 +980,9 @@ void phy_state_machine(struct work_struct *work)
952 if (err < 0) 980 if (err < 0)
953 phy_error(phydev); 981 phy_error(phydev);
954 982
983 dev_dbg(&phydev->dev, "PHY state change %s -> %s\n",
984 phy_state_to_str(old_state), phy_state_to_str(phydev->state));
985
955 queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 986 queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
956 PHY_STATE_TIME * HZ); 987 PHY_STATE_TIME * HZ);
957} 988}
@@ -1062,8 +1093,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
1062 if ((phydev->duplex == DUPLEX_FULL) && 1093 if ((phydev->duplex == DUPLEX_FULL) &&
1063 ((phydev->interface == PHY_INTERFACE_MODE_MII) || 1094 ((phydev->interface == PHY_INTERFACE_MODE_MII) ||
1064 (phydev->interface == PHY_INTERFACE_MODE_GMII) || 1095 (phydev->interface == PHY_INTERFACE_MODE_GMII) ||
1065 (phydev->interface >= PHY_INTERFACE_MODE_RGMII && 1096 phy_interface_is_rgmii(phydev) ||
1066 phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID) ||
1067 phy_is_internal(phydev))) { 1097 phy_is_internal(phydev))) {
1068 int eee_lp, eee_cap, eee_adv; 1098 int eee_lp, eee_cap, eee_adv;
1069 u32 lp, cap, adv; 1099 u32 lp, cap, adv;