From: Heiner Kallweit Subject: [PATCH net-next] net: phy: add GBit master / slave error detection Date: Wed, 18 Jul 2018 08:14:09 +0200 Message-ID: <60685308-a848-e4d0-e170-f2738f046679@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "netdev@vger.kernel.org" To: Andrew Lunn , Florian Fainelli , David Miller Return-path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:41351 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbeGRGub (ORCPT ); Wed, 18 Jul 2018 02:50:31 -0400 Received: by mail-wr1-f65.google.com with SMTP id j5-v6so3347888wrr.8 for ; Tue, 17 Jul 2018 23:14:18 -0700 (PDT) Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Certain PHY's have issues when operating in GBit slave mode and can be forced to master mode. Examples are RTL8211C, also the Micrel PHY driver has a DT setting to force master mode. If two such chips are link partners the autonegotiation will fail. Standard defines a self-clearing on read, latched-high bit to indicate this error. Check this bit to inform the user. Signed-off-by: Heiner Kallweit --- drivers/net/phy/phy_device.c | 5 +++++ include/uapi/linux/mii.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index b9f5f40a..249c6f75 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1551,6 +1551,11 @@ int genphy_read_status(struct phy_device *phydev) if (lpagb < 0) return lpagb; + if (lpagb & LPA_1000MSFAIL) { + phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n"); + return -ENOLINK; + } + adv = phy_read(phydev, MII_CTRL1000); if (adv < 0) return adv; diff --git a/include/uapi/linux/mii.h b/include/uapi/linux/mii.h index b5c2fdcf..a5062165 100644 --- a/include/uapi/linux/mii.h +++ b/include/uapi/linux/mii.h @@ -136,6 +136,7 @@ #define CTL1000_ENABLE_MASTER 0x1000 /* 1000BASE-T Status register */ +#define LPA_1000MSFAIL 0x8000 /* Master/Slave resolution failure */ #define LPA_1000LOCALRXOK 0x2000 /* Link partner local receiver status */ #define LPA_1000REMRXOK 0x1000 /* Link partner remote receiver status */ #define LPA_1000FULL 0x0800 /* Link partner 1000BASE-T full duplex */ -- 2.18.0