From patchwork Tue Mar 23 16:46:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wong Vee Khee X-Patchwork-Id: 407392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86CC8C433DB for ; Tue, 23 Mar 2021 16:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45D07619C6 for ; Tue, 23 Mar 2021 16:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbhCWQmz (ORCPT ); Tue, 23 Mar 2021 12:42:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:14550 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbhCWQmd (ORCPT ); Tue, 23 Mar 2021 12:42:33 -0400 IronPort-SDR: yVVciRJlSFr3BpfE540ygosXLl5AIocNaJghT+KMHnXE/1psc0K1yRChIZ3mOCIdiMCW4Zbr9+ g0Sket0f0mDw== X-IronPort-AV: E=McAfee;i="6000,8403,9932"; a="187198388" X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="187198388" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2021 09:42:32 -0700 IronPort-SDR: 84xPRr46Uy/BvgfKwPID2GwAGiVxWv/NEowCLPizF12T/LzW9ngxTWO0z9oExR30c7T+MvyVJx h6NH+QauRZ+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="408403259" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 23 Mar 2021 09:42:31 -0700 Received: from glass.png.intel.com (glass.png.intel.com [10.158.65.59]) by linux.intel.com (Postfix) with ESMTP id 690D8580718; Tue, 23 Mar 2021 09:42:29 -0700 (PDT) From: Wong Vee Khee To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Voon Weifeng , Ong Boon Leong Subject: [PATCH net-next 1/2] net: phy: add genphy_c45_loopback Date: Wed, 24 Mar 2021 00:46:40 +0800 Message-Id: <20210323164641.26059-2-vee.khee.wong@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323164641.26059-1-vee.khee.wong@linux.intel.com> References: <20210323164641.26059-1-vee.khee.wong@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add generic code to enable C45 PHY loopback into the common phy-c45.c file. This will allow C45 PHY drivers aceess this by setting .set_loopback. Suggested-by: Heiner Kallweit Signed-off-by: Wong Vee Khee Reviewed-by: Heiner Kallweit Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 8 ++++++++ include/linux/phy.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 077f2929c45e..91e3acb9e397 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -560,6 +560,14 @@ int gen10g_config_aneg(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(gen10g_config_aneg); +int genphy_c45_loopback(struct phy_device *phydev, bool enable) +{ + return phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_LOOPBACK, + enable ? MDIO_PCS_CTRL1_LOOPBACK : 0); +} +EXPORT_SYMBOL_GPL(genphy_c45_loopback); + struct phy_driver genphy_c45_driver = { .phy_id = 0xffffffff, .phy_id_mask = 0xffffffff, diff --git a/include/linux/phy.h b/include/linux/phy.h index 1a12e4436b5b..8e2cf84b2318 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1532,6 +1532,7 @@ int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev); int genphy_c45_config_aneg(struct phy_device *phydev); +int genphy_c45_loopback(struct phy_device *phydev, bool enable); /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver; From patchwork Tue Mar 23 16:46:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wong Vee Khee X-Patchwork-Id: 408710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D60D4C433E2 for ; Tue, 23 Mar 2021 16:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B45AA619C0 for ; Tue, 23 Mar 2021 16:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233391AbhCWQm6 (ORCPT ); Tue, 23 Mar 2021 12:42:58 -0400 Received: from mga18.intel.com ([134.134.136.126]:31003 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233224AbhCWQmf (ORCPT ); Tue, 23 Mar 2021 12:42:35 -0400 IronPort-SDR: w3tSc0/ErQxoEhk8UQu+KQ4J/sklvlBPnYc9vkNI+9wszcQc50oU7fLDQF/fP8rQygZtkMaEVx do3oqMJ+d1Jw== X-IronPort-AV: E=McAfee;i="6000,8403,9932"; a="178081796" X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="178081796" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2021 09:42:35 -0700 IronPort-SDR: 2mACqbPw8a6SJ9PSHWd+QyBnkPlurmQQ9aedR+9Ev/lsbTjVsRy5dPD9U693riaeP5jeekb07G CV3P8kFID/dQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="415070639" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP; 23 Mar 2021 09:42:34 -0700 Received: from glass.png.intel.com (glass.png.intel.com [10.158.65.59]) by linux.intel.com (Postfix) with ESMTP id DA1F758069F; Tue, 23 Mar 2021 09:42:31 -0700 (PDT) From: Wong Vee Khee To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Voon Weifeng , Ong Boon Leong Subject: [PATCH net-next 2/2] net: phy: marvell10g: Add PHY loopback support Date: Wed, 24 Mar 2021 00:46:41 +0800 Message-Id: <20210323164641.26059-3-vee.khee.wong@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323164641.26059-1-vee.khee.wong@linux.intel.com> References: <20210323164641.26059-1-vee.khee.wong@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for PHY loopback for Marvell 88x2110 and Marvell 88x3310. This allow user to perform PHY loopback test using ethtool selftest. Signed-off-by: Wong Vee Khee --- drivers/net/phy/marvell10g.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index b1bb9b8e1e4e..74b64e52ffa2 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -781,6 +781,7 @@ static struct phy_driver mv3310_drivers[] = { .get_tunable = mv3310_get_tunable, .set_tunable = mv3310_set_tunable, .remove = mv3310_remove, + .set_loopback = genphy_c45_loopback, }, { .phy_id = MARVELL_PHY_ID_88E2110, @@ -796,6 +797,7 @@ static struct phy_driver mv3310_drivers[] = { .get_tunable = mv3310_get_tunable, .set_tunable = mv3310_set_tunable, .remove = mv3310_remove, + .set_loopback = genphy_c45_loopback, }, };