From patchwork Mon Oct 22 10:32:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 987567 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=pass (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="ABr5Dnp9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42dtC74ZDTz9sD4 for ; Mon, 22 Oct 2018 21:33:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728524AbeJVSvE (ORCPT ); Mon, 22 Oct 2018 14:51:04 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:39896 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbeJVSvD (ORCPT ); Mon, 22 Oct 2018 14:51:03 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0E1D224E1599; Mon, 22 Oct 2018 03:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540204385; bh=ImWlQLmluFlurCYbLX1IPm1kdG9l0QmEPDExqyjqKJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=ABr5Dnp96T+aayTdCPQsuBcZSV3poczG34CifjZP3E0+ukFuwKsmh0ovKZOnritSg gOfq6GJCOE7h1d8Pnt6SE4i12d+/Jz85awRzbPYV8xggJkeXE2KEIBQbjlvLOUXtIt rIAn0nrTEjfYCJmK5Wv6oZCLn0/9hzL3AY+swNlKVCra4qiflBO7QqOqqcsZuNJ6pa 4GjGdGset5jmk4hjoa1NqBoMbRSW8w+rvMb1FGsnX4EqWmPLiUIVWKGOXcgh6UuvTp 9y/yQcLaZVv+hN6VSTM/4SK0rMz+U5nY/d2WAEI/7VXYEZIrQmQ5oNX0xSu4HzeV46 Zt5WTV3g4eJ7A== Received: from joabreu-VirtualBox.internal.synopsys.com (joabreu-e7440.internal.synopsys.com [10.107.19.15]) by mailhost.synopsys.com (Postfix) with ESMTP id 9BA955074; Mon, 22 Oct 2018 03:33:03 -0700 (PDT) From: Jose Abreu To: netdev@vger.kernel.org Cc: Jose Abreu , Andrew Lunn , Florian Fainelli , "David S. Miller" , Joao Pinto Subject: [PATCH net-next 1/4] net: phy: Use C45 Helpers when forcing PHY Date: Mon, 22 Oct 2018 11:32:46 +0100 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If PHY is in force state and we have a C45 phy we need to use the standard C45 helpers and not the C22 ones. Signed-off-by: Jose Abreu Cc: Andrew Lunn Cc: Florian Fainelli Cc: "David S. Miller" Cc: Joao Pinto --- drivers/net/phy/phy.c | 2 +- include/linux/phy.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1d73ac3309ce..0ff4946e208e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -995,7 +995,7 @@ void phy_state_machine(struct work_struct *work) } break; case PHY_FORCING: - err = genphy_update_link(phydev); + err = phy_update_link(phydev); if (err) break; diff --git a/include/linux/phy.h b/include/linux/phy.h index 3ea87f774a76..02c2ee8bc05b 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1044,6 +1044,14 @@ static inline int phy_read_status(struct phy_device *phydev) return genphy_read_status(phydev); } +static inline int phy_update_link(struct phy_device *phydev) +{ + if (phydev->is_c45) + return gen10g_read_status(phydev); + else + return genphy_update_link(phydev); +} + void phy_driver_unregister(struct phy_driver *drv); void phy_drivers_unregister(struct phy_driver *drv, int n); int phy_driver_register(struct phy_driver *new_driver, struct module *owner); From patchwork Mon Oct 22 10:32:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 987568 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=pass (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="OHW0pyLm"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42dtC85014z9sD3 for ; Mon, 22 Oct 2018 21:33:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728558AbeJVSvF (ORCPT ); Mon, 22 Oct 2018 14:51:05 -0400 Received: from smtprelay.synopsys.com ([198.182.47.9]:39904 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbeJVSvF (ORCPT ); Mon, 22 Oct 2018 14:51:05 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2E97424E168E; Mon, 22 Oct 2018 03:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540204387; bh=ElNwv7PhOosBDsX+3NXtK3K22pefyXwbhxQ9FKR5+NA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=OHW0pyLm6T0s4/Yq0BZmfqLICQkTdfprVif7m3DwktZ44gb+zD2rXoMw9viG3TbIX aJW7Jx7RVJubofIn9JySwILAgNnjGvD3n5nfVopBHTplqtorPjzQlxWpKDtt+mRSoh ZvF/DKIn5+eeeves8lFve8WNwmm7A7fNdEI4VG9/VmJ2+GvVfFaY9tD/HMtG14Kyn2 314Uf32FN0vYziJstAVicLb2pa+bpe4dm1S76cpTFpb8SlQuP3YN5ssAvtYwMtk44c +oIvpRr9wWAqAVFLkHIxTa10lw/Cg7rIYAxVAnpR4amfdWfNaUsdhAoKnz4mzdeQAE 3iY3zuAonXfsA== Received: from joabreu-VirtualBox.internal.synopsys.com (joabreu-e7440.internal.synopsys.com [10.107.19.15]) by mailhost.synopsys.com (Postfix) with ESMTP id AA517507B; Mon, 22 Oct 2018 03:33:05 -0700 (PDT) From: Jose Abreu To: netdev@vger.kernel.org Cc: Jose Abreu , Andrew Lunn , Florian Fainelli , "David S. Miller" , Joao Pinto Subject: [PATCH net-next 2/4] net: phy-c45: Populate autoneg_done callback Date: Mon, 22 Oct 2018 11:32:47 +0100 Message-Id: <65a0791a760dc488f62445343e041baf4a2db17e.1540204183.git.joabreu@synopsys.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We already have this callback implemented. Use it in driver structure. Signed-off-by: Jose Abreu Cc: Andrew Lunn Cc: Florian Fainelli Cc: "David S. Miller" Cc: Joao Pinto --- drivers/net/phy/phy-c45.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index e1225545362d..c0135217b81f 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -330,6 +330,7 @@ struct phy_driver genphy_10g_driver = { .soft_reset = gen10g_no_soft_reset, .config_init = gen10g_config_init, .features = 0, + .aneg_done = genphy_c45_aneg_done, .config_aneg = gen10g_config_aneg, .read_status = gen10g_read_status, .suspend = gen10g_suspend, From patchwork Mon Oct 22 10:32:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 987569 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=pass (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="ltu1hG0E"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42dtCB5xqcz9sD3 for ; Mon, 22 Oct 2018 21:33:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728589AbeJVSvH (ORCPT ); Mon, 22 Oct 2018 14:51:07 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:44604 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbeJVSvH (ORCPT ); Mon, 22 Oct 2018 14:51:07 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 459F410C15A0; Mon, 22 Oct 2018 03:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540204389; bh=b7LQoew3KShJBAhcTaw+IFSBAob0idK2cLGuH2ARCJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=ltu1hG0E3Ku6CtZ665ots1Mm3XKlLrHMRB2gu6ZhESzpBYOzKtx7g0tvbDQcUtvQs bVCDPuNmgfZSTwrLJqug+iz5pssBm7q9AEkaW3DK4K2/yUeHqjQ2d4WrlHDv/nacDP Ecm2irXxdnoVJeYxQPP9nPmpvdjCKipHqAnk18+KbWAIr6KIXMcZtYkbDIAmpk1nLL M4yCpgHFmxLLqAvz834swGhhZjb4ShP1Ar+qzPskqzoJhmdpYKdSNtuhQs9XUc+c11 Ay0jcB1tHYVHutgz5h/oHZ9UcsNMm2sIGC82nrVrO324nHrBlBFrK3fGYpoxycZt/6 JvERUKRTN4Qug== Received: from joabreu-VirtualBox.internal.synopsys.com (joabreu-e7440.internal.synopsys.com [10.107.19.15]) by mailhost.synopsys.com (Postfix) with ESMTP id A18B35083; Mon, 22 Oct 2018 03:33:07 -0700 (PDT) From: Jose Abreu To: netdev@vger.kernel.org Cc: Jose Abreu , Andrew Lunn , Florian Fainelli , "David S. Miller" , Joao Pinto Subject: [PATCH net-next 3/4] net: phy-c45: Implement reset/suspend/resume callbacks Date: Mon, 22 Oct 2018 11:32:48 +0100 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Implement the missing callbacks for Generic 10G PHY. Tested using XGMAC with a C45 PHY working at 10G Link. Signed-off-by: Jose Abreu Cc: Andrew Lunn Cc: Florian Fainelli Cc: "David S. Miller" Cc: Joao Pinto --- drivers/net/phy/phy-c45.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index c0135217b81f..7e62bd7795a3 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -1,6 +1,7 @@ /* * Clause 45 PHY support */ +#include #include #include #include @@ -294,6 +295,35 @@ int gen10g_read_status(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(gen10g_read_status); +static int gen10g_poll_reset(struct phy_device *phydev) +{ + /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */ + unsigned int retries = 12; + int ret; + + do { + msleep(50); + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1); + if (ret < 0) + return ret; + } while (ret & MDIO_CTRL1_RESET && --retries); + if (ret & MDIO_CTRL1_RESET) + return -ETIMEDOUT; + + return 0; +} + +static int gen10g_soft_reset(struct phy_device *phydev) +{ + int val; + + val = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, MDIO_CTRL1_RESET); + if (val < 0) + return val; + + return gen10g_poll_reset(phydev); +} + int gen10g_no_soft_reset(struct phy_device *phydev) { /* Do nothing for now */ @@ -313,12 +343,36 @@ EXPORT_SYMBOL_GPL(gen10g_config_init); int gen10g_suspend(struct phy_device *phydev) { + int val; + + val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1); + if (val < 0) + return val; + + val |= MDIO_CTRL1_LPOWER; + + val = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, val); + if (val < 0) + return val; + return 0; } EXPORT_SYMBOL_GPL(gen10g_suspend); int gen10g_resume(struct phy_device *phydev) { + int val; + + val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1); + if (val < 0) + return val; + + val &= ~MDIO_CTRL1_LPOWER; + + val = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, val); + if (val < 0) + return val; + return 0; } EXPORT_SYMBOL_GPL(gen10g_resume); @@ -327,7 +381,7 @@ struct phy_driver genphy_10g_driver = { .phy_id = 0xffffffff, .phy_id_mask = 0xffffffff, .name = "Generic 10G PHY", - .soft_reset = gen10g_no_soft_reset, + .soft_reset = gen10g_soft_reset, .config_init = gen10g_config_init, .features = 0, .aneg_done = genphy_c45_aneg_done, From patchwork Mon Oct 22 10:32:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 987570 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=pass (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="LsP8rW8y"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42dtCD5S9Xz9sD3 for ; Mon, 22 Oct 2018 21:33:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728732AbeJVSvJ (ORCPT ); Mon, 22 Oct 2018 14:51:09 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:44612 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728726AbeJVSvJ (ORCPT ); Mon, 22 Oct 2018 14:51:09 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0EECC10C1720; Mon, 22 Oct 2018 03:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540204391; bh=WUTruGVPMXzLxPxGgLM+f+qmTctnRRIot2HutyKWwEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=LsP8rW8ytPovoWGcaAchyxCXFt7e913Kae+Z9mIm8y2r/xyNBwvBlMH1xU6SqrMdh LXmGR1Iymd6h0GXlSLP2JCWFnsHpPRaS3oxBWYwmTF4Q+5JqgKmYbbOV9DxW+gxcpS pivQDwETrwXhnrA5RyluO/yfP0HybnR2zwwcKqPLqHGUdD935SRYmvguhrWQWUQBlk Rl1w8xlJMzmhUMoTBit4/BPPTtA/9pN9Tt2lGrtKMJ4NafXDAJE4zbY20ZKTTx73D6 cbj6HwQrzrpr9EncDJ1Cdu5vLkRxVo3D3d/fmUYF3mj7W8jVmWsTR6wXDqUtA5oHah 7NvbOJi/XAzlg== Received: from joabreu-VirtualBox.internal.synopsys.com (joabreu-e7440.internal.synopsys.com [10.107.19.15]) by mailhost.synopsys.com (Postfix) with ESMTP id 8D1875096; Mon, 22 Oct 2018 03:33:09 -0700 (PDT) From: Jose Abreu To: netdev@vger.kernel.org Cc: Jose Abreu , Andrew Lunn , Florian Fainelli , "David S. Miller" , Joao Pinto Subject: [PATCH net-next 4/4] net: phy-c45: Populate missing features Date: Mon, 22 Oct 2018 11:32:49 +0100 Message-Id: <42cf41718e693f4e7dfd956bac73bdaff4ee22bf.1540204183.git.joabreu@synopsys.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Populate the missing features field of Generic 10G PHY Driver. This will be overwritten in .config_init callback so we can just set basic 10G funcionalities in the field. Signed-off-by: Jose Abreu Cc: Andrew Lunn Cc: Florian Fainelli Cc: "David S. Miller" Cc: Joao Pinto --- drivers/net/phy/phy-c45.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 7e62bd7795a3..99c66b452af9 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -383,7 +383,7 @@ struct phy_driver genphy_10g_driver = { .name = "Generic 10G PHY", .soft_reset = gen10g_soft_reset, .config_init = gen10g_config_init, - .features = 0, + .features = PHY_10GBIT_FEATURES, .aneg_done = genphy_c45_aneg_done, .config_aneg = gen10g_config_aneg, .read_status = gen10g_read_status,