net: phy: Add support for polling cable test
authorAndrew Lunn <andrew@lunn.ch>
Sun, 10 May 2020 19:12:32 +0000 (21:12 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sun, 10 May 2020 19:28:41 +0000 (12:28 -0700)
Some PHYs are not capable of generating interrupts when a cable test
finished. They do however support interrupts for normal operations,
like link up/down. As such, the PHY state machine would normally not
poll the PHY.

Add support for indicating the PHY state machine must poll the PHY
when performing a cable test.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phy.c
include/linux/phy.h

index 0f4b272..9fa6101 100644 (file)
@@ -523,6 +523,8 @@ int phy_start_cable_test(struct phy_device *phydev,
 
        phydev->state = PHY_CABLETEST;
 
+       if (phy_polling_mode(phydev))
+               phy_trigger_machine(phydev);
 out:
        mutex_unlock(&phydev->lock);
 
index 632403f..f58eee7 100644 (file)
@@ -79,6 +79,7 @@ extern const int phy_10gbit_features_array[1];
 
 #define PHY_IS_INTERNAL                0x00000001
 #define PHY_RST_AFTER_CLK_EN   0x00000002
+#define PHY_POLL_CABLE_TEST    0x00000004
 #define MDIO_DEVICE_IS_PHY     0x80000000
 
 /* Interface Mode definitions */
@@ -1061,6 +1062,10 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
  */
 static inline bool phy_polling_mode(struct phy_device *phydev)
 {
+       if (phydev->state == PHY_CABLETEST)
+               if (phydev->drv->flags & PHY_POLL_CABLE_TEST)
+                       return true;
+
        return phydev->irq == PHY_POLL;
 }