From patchwork Fri Jun 8 10:23:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvaro Gamez Machado X-Patchwork-Id: 926666 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hazent.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=hazent-com.20150623.gappssmtp.com header.i=@hazent-com.20150623.gappssmtp.com header.b="lz1Tvx4P"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 412JRC5DMLz9s0W for ; Fri, 8 Jun 2018 20:23:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbeFHKXs (ORCPT ); Fri, 8 Jun 2018 06:23:48 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52073 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbeFHKXr (ORCPT ); Fri, 8 Jun 2018 06:23:47 -0400 Received: by mail-wm0-f68.google.com with SMTP id r15-v6so2429630wmc.1 for ; Fri, 08 Jun 2018 03:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hazent-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=7D/oBIyX+xnC4eWa4AyrM3AH1zd4KRIMh82VxkskIOE=; b=lz1Tvx4PW4QKNZhK5TzMPw5/O0bIk6+2xagAX/lqRdU1ktU1I6sw2+xAD8b38XWSjA w6qHrq07KJMo8IG0Zgn0qD/Xfok9Nfss4x6yKv/gJ8kATTGnvbp1PTcLcwaiJ5roIam/ KPrH6B+kQ49fHduSQv4H3ZoZixQfpRxgjUdFdRxmcSZOSloP/jYVpf+A7qXbKkO4gO+1 T4jq6r2jpFPXnIHW/5/P3WtCzM185xa62CnqyirndlnLjtU90JBPMzLSrPnxYGhG3k3A QY1ABjjerBUdFkbJ0s2JrvM3Ufu6UDk60t+dzOEPGKPI9EvEGHxlWWRv9aDrAF7l4TJj pJ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7D/oBIyX+xnC4eWa4AyrM3AH1zd4KRIMh82VxkskIOE=; b=tnRhOFbMWMglwiHOJivwRJuTxUUfaJJUNhZBAoFRlxHYwxXydc6nAoHBBQXmuU8xtH YiHpqXiLeOIMRosNdlqw2592wJFhJYOjUOvS5njOxJuh2JNz9B9wRmLWFik4xncFM1IS 7d1QntQ/Q6Ovv57Mp8Dp1uScYPJ8LHmx6cdFX5gCUpMPvJiPzZ6m/8JL8BEyarX2Tjyb T4k1lqGtQjO6KOtYomhfZ5EgfayDYcOaR6F1+MCthbvi0mA5pwxlQYvhFScE3uZhZRA5 vfYPWoEWFedgy49BrmkmDJqKDxCgPXGkyoEok62ogfDwf3C1HUASDAycdtLR4MxTbtww hCag== X-Gm-Message-State: APt69E39aP352yD9aCA1Cub/JXjIQmo6oiVzdwM9yskTuIT33EWv4E5a hpbkJ4yV/EPBkz9gC/PjOTzx8w== X-Google-Smtp-Source: ADUXVKLdVgQ7Yh2yJdFWGbxIQaDZLz6qDCj4eMRbtq/tU6olS4MrLsfLII4ZLC1ZCr7Jc3Wp2HWttQ== X-Received: by 2002:a1c:2005:: with SMTP id g5-v6mr1053478wmg.4.1528453426387; Fri, 08 Jun 2018 03:23:46 -0700 (PDT) Received: from salem.gmr.ssr.upm.es (salem.gmr.ssr.upm.es. [138.4.36.7]) by smtp.gmail.com with ESMTPSA id m16-v6sm21799465wro.91.2018.06.08.03.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 03:23:45 -0700 (PDT) From: Alvaro Gamez Machado To: Andrew Lunn , Florian Fainelli , "David S. Miller" , netdev@vger.kernel.org Cc: Alvaro Gamez Machado Subject: [PATCH] net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620 Date: Fri, 8 Jun 2018 12:23:39 +0200 Message-Id: <20180608102339.2572-1-alvaro.gamez@hazent.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org DP83620 register set is compatible with the DP83848, but it also supports 100base-FX. When the hardware is configured such as that fiber mode is enabled, autonegotiation is not possible. The chip, however, doesn't expose this information via BMSR_ANEGCAPABLE. Instead, this bit is always set high, even if the particular hardware configuration makes it so that auto negotiation is not possible [1]. Under these circumstances, the phy subsystem keeps trying for autonegotiation to happen, without success. Hereby, we inspect BMCR_ANENABLE bit after genphy_config_init, which on reset is set to 0 when auto negotiation is disabled, and so we use this value instead of BMSR_ANEGCAPABLE. [1] https://e2e.ti.com/support/interface/ethernet/f/903/p/697165/2571170 Signed-off-by: Alvaro Gamez Machado --- drivers/net/phy/dp83848.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c index cd09c3af2117..6e8e42361fd5 100644 --- a/drivers/net/phy/dp83848.c +++ b/drivers/net/phy/dp83848.c @@ -74,6 +74,25 @@ static int dp83848_config_intr(struct phy_device *phydev) return phy_write(phydev, DP83848_MICR, control); } +static int dp83848_config_init(struct phy_device *phydev) +{ + int err; + int val; + + err = genphy_config_init(phydev); + if (err < 0) + return err; + + /* DP83620 always reports Auto Negotiation Ability on BMSR. Instead, + * we check initial value of BMCR Auto negotiation enable bit + */ + val = phy_read(phydev, MII_BMCR); + if (!(val & BMCR_ANENABLE)) + phydev->autoneg = AUTONEG_DISABLE; + + return 0; +} + static struct mdio_device_id __maybe_unused dp83848_tbl[] = { { TI_DP83848C_PHY_ID, 0xfffffff0 }, { NS_DP83848C_PHY_ID, 0xfffffff0 }, @@ -83,7 +102,7 @@ static struct mdio_device_id __maybe_unused dp83848_tbl[] = { }; MODULE_DEVICE_TABLE(mdio, dp83848_tbl); -#define DP83848_PHY_DRIVER(_id, _name) \ +#define DP83848_PHY_DRIVER(_id, _name, _config_init) \ { \ .phy_id = _id, \ .phy_id_mask = 0xfffffff0, \ @@ -92,7 +111,7 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl); .flags = PHY_HAS_INTERRUPT, \ \ .soft_reset = genphy_soft_reset, \ - .config_init = genphy_config_init, \ + .config_init = _config_init, \ .suspend = genphy_suspend, \ .resume = genphy_resume, \ \ @@ -102,10 +121,14 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl); } static struct phy_driver dp83848_driver[] = { - DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"), - DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"), - DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY"), - DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"), + DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY", + genphy_config_init), + DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY", + genphy_config_init), + DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY", + dp83848_config_init), + DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY", + genphy_config_init), }; module_phy_driver(dp83848_driver);