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.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 76d96b9ebcdb..1d788f19135b 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -38,6 +38,26 @@
38 38
39#include <asm/irq.h> 39#include <asm/irq.h>
40 40
41static const char *phy_speed_to_str(int speed)
42{
43 switch (speed) {
44 case SPEED_10:
45 return "10Mbps";
46 case SPEED_100:
47 return "100Mbps";
48 case SPEED_1000:
49 return "1Gbps";
50 case SPEED_2500:
51 return "2.5Gbps";
52 case SPEED_10000:
53 return "10Gbps";
54 case SPEED_UNKNOWN:
55 return "Unknown";
56 default:
57 return "Unsupported (update phy.c)";
58 }
59}
60
41/** 61/**
42 * phy_print_status - Convenience function to print out the current phy status 62 * phy_print_status - Convenience function to print out the current phy status
43 * @phydev: the phy_device struct 63 * @phydev: the phy_device struct
@@ -45,12 +65,13 @@
45void phy_print_status(struct phy_device *phydev) 65void phy_print_status(struct phy_device *phydev)
46{ 66{
47 if (phydev->link) { 67 if (phydev->link) {
48 pr_info("%s - Link is Up - %d/%s\n", 68 netdev_info(phydev->attached_dev,
49 dev_name(&phydev->dev), 69 "Link is Up - %s/%s - flow control %s\n",
50 phydev->speed, 70 phy_speed_to_str(phydev->speed),
51 DUPLEX_FULL == phydev->duplex ? "Full" : "Half"); 71 DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
72 phydev->pause ? "rx/tx" : "off");
52 } else { 73 } else {
53 pr_info("%s - Link is Down\n", dev_name(&phydev->dev)); 74 netdev_info(phydev->attached_dev, "Link is Down\n");
54 } 75 }
55} 76}
56EXPORT_SYMBOL(phy_print_status); 77EXPORT_SYMBOL(phy_print_status);
@@ -62,7 +83,7 @@ EXPORT_SYMBOL(phy_print_status);
62 * If the @phydev driver has an ack_interrupt function, call it to 83 * If the @phydev driver has an ack_interrupt function, call it to
63 * ack and clear the phy device's interrupt. 84 * ack and clear the phy device's interrupt.
64 * 85 *
65 * Returns 0 on success on < 0 on error. 86 * Returns 0 on success or < 0 on error.
66 */ 87 */
67static int phy_clear_interrupt(struct phy_device *phydev) 88static int phy_clear_interrupt(struct phy_device *phydev)
68{ 89{
@@ -77,7 +98,7 @@ static int phy_clear_interrupt(struct phy_device *phydev)
77 * @phydev: the phy_device struct 98 * @phydev: the phy_device struct
78 * @interrupts: interrupt flags to configure for this @phydev 99 * @interrupts: interrupt flags to configure for this @phydev
79 * 100 *
80 * Returns 0 on success on < 0 on error. 101 * Returns 0 on success or < 0 on error.
81 */ 102 */
82static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts) 103static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
83{ 104{
@@ -93,15 +114,16 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
93 * phy_aneg_done - return auto-negotiation status 114 * phy_aneg_done - return auto-negotiation status
94 * @phydev: target phy_device struct 115 * @phydev: target phy_device struct
95 * 116 *
96 * Description: Reads the status register and returns 0 either if 117 * Description: Return the auto-negotiation status from this @phydev
97 * auto-negotiation is incomplete, or if there was an error. 118 * Returns > 0 on success or < 0 on error. 0 means that auto-negotiation
98 * Returns BMSR_ANEGCOMPLETE if auto-negotiation is done. 119 * is still pending.
99 */ 120 */
100static inline int phy_aneg_done(struct phy_device *phydev) 121static inline int phy_aneg_done(struct phy_device *phydev)
101{ 122{
102 int retval = phy_read(phydev, MII_BMSR); 123 if (phydev->drv->aneg_done)
124 return phydev->drv->aneg_done(phydev);
103 125
104 return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE); 126 return genphy_aneg_done(phydev);
105} 127}
106 128
107/* A structure for mapping a particular speed and duplex 129/* A structure for mapping a particular speed and duplex
@@ -283,7 +305,10 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
283 305
284 ethtool_cmd_speed_set(cmd, phydev->speed); 306 ethtool_cmd_speed_set(cmd, phydev->speed);
285 cmd->duplex = phydev->duplex; 307 cmd->duplex = phydev->duplex;
286 cmd->port = PORT_MII; 308 if (phydev->interface == PHY_INTERFACE_MODE_MOCA)
309 cmd->port = PORT_BNC;
310 else
311 cmd->port = PORT_MII;
287 cmd->phy_address = phydev->addr; 312 cmd->phy_address = phydev->addr;
288 cmd->transceiver = phy_is_internal(phydev) ? 313 cmd->transceiver = phy_is_internal(phydev) ?
289 XCVR_INTERNAL : XCVR_EXTERNAL; 314 XCVR_INTERNAL : XCVR_EXTERNAL;