From patchwork Tue Jul 12 13:15:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12914985 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58D58C43334 for ; Tue, 12 Jul 2022 13:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232894AbiGLNQQ (ORCPT ); Tue, 12 Jul 2022 09:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232343AbiGLNQJ (ORCPT ); Tue, 12 Jul 2022 09:16:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D333C7AB1B; Tue, 12 Jul 2022 06:16:03 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 4C10A22248; Tue, 12 Jul 2022 15:16:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657631761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YKhzt3cpITEJyGyy9hsxcRxMJ7yw3/fJk2ysgW6U4JY=; b=ii+xTKVa3ZeGjM4nMcroApaA2P6iByzeL5OlSdUmoC5nO2Ip5U7BOZhUgJa71EER8ToyVo w6w0AguvD1gDza0OVUIttcLFhc5R5pPAaWqfYiB4SEfDkzk99FrXWZHiLTUKfRWgpTvzJ9 Hh0akFYIBT8WuxSPnYdgLMogMhTmAEU= From: Michael Walle To: Xu Liang , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 1/4] net: phy: mxl-gpy: fix version reporting Date: Tue, 12 Jul 2022 15:15:51 +0200 Message-Id: <20220712131554.2737792-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220712131554.2737792-1-michael@walle.cc> References: <20220712131554.2737792-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The commit 09ce6b20103b ("net: phy: mxl-gpy: add temperature sensor") will overwrite the return value and the reported version will be wrong. Fix it. Fixes: 09ce6b20103b ("net: phy: mxl-gpy: add temperature sensor") Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn --- drivers/net/phy/mxl-gpy.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index 5b99acf44337..9728ef93fc0b 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -198,6 +198,7 @@ static int gpy_config_init(struct phy_device *phydev) static int gpy_probe(struct phy_device *phydev) { + int fw_version; int ret; if (!phydev->is_c45) { @@ -207,16 +208,16 @@ static int gpy_probe(struct phy_device *phydev) } /* Show GPY PHY FW version in dmesg */ - ret = phy_read(phydev, PHY_FWV); - if (ret < 0) - return ret; + fw_version = phy_read(phydev, PHY_FWV); + if (fw_version < 0) + return fw_version; ret = gpy_hwmon_register(phydev); if (ret) return ret; - phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n", ret, - (ret & PHY_FWV_REL_MASK) ? "release" : "test"); + phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n", fw_version, + (fw_version & PHY_FWV_REL_MASK) ? "release" : "test"); return 0; } From patchwork Tue Jul 12 13:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12914984 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 889E8C433EF for ; Tue, 12 Jul 2022 13:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbiGLNQP (ORCPT ); Tue, 12 Jul 2022 09:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbiGLNQJ (ORCPT ); Tue, 12 Jul 2022 09:16:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F4474DF4; Tue, 12 Jul 2022 06:16:03 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id D7A9422249; Tue, 12 Jul 2022 15:16:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657631762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w1eHMRpW+oTXNDNSJlNq7iOEgDl3HFbuG1KOFvnVIGo=; b=nSb7c/hAb4Jei3tlILPG9XmJS7GHJpQWz15BuzoCXh2xU32SClrq/W/pixBZYI7Ik7bNvc Q+IA86j0CdV/ilBmcJH13Wj73ebvN+Zd0EmY/NXIjtAtO1QbblP/JrPV9tRd33So7lroLt sZfzxp5KyDiAfVThgyBP0hrVOyuMMtw= From: Michael Walle To: Xu Liang , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 2/4] net: phy: mxl-gpy: cache PHY firmware version Date: Tue, 12 Jul 2022 15:15:52 +0200 Message-Id: <20220712131554.2737792-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220712131554.2737792-1-michael@walle.cc> References: <20220712131554.2737792-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Cache the firmware version during probe. There is no need to read the firmware version on every autonegotiation. Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn --- drivers/net/phy/mxl-gpy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index 9728ef93fc0b..b6303089d425 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -77,6 +77,11 @@ #define VPSPEC2_WOL_AD45 0x0E0A #define WOL_EN BIT(0) +struct gpy_priv { + u8 fw_type; + u8 fw_minor; +}; + static const struct { int type; int minor; @@ -198,6 +203,8 @@ static int gpy_config_init(struct phy_device *phydev) static int gpy_probe(struct phy_device *phydev) { + struct device *dev = &phydev->mdio.dev; + struct gpy_priv *priv; int fw_version; int ret; @@ -207,15 +214,22 @@ static int gpy_probe(struct phy_device *phydev) return ret; } - /* Show GPY PHY FW version in dmesg */ + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + phydev->priv = priv; + fw_version = phy_read(phydev, PHY_FWV); if (fw_version < 0) return fw_version; + priv->fw_type = FIELD_GET(PHY_FWV_TYPE_MASK, fw_version); + priv->fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, fw_version); ret = gpy_hwmon_register(phydev); if (ret) return ret; + /* Show GPY PHY FW version in dmesg */ phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n", fw_version, (fw_version & PHY_FWV_REL_MASK) ? "release" : "test"); @@ -224,20 +238,13 @@ static int gpy_probe(struct phy_device *phydev) static bool gpy_sgmii_need_reaneg(struct phy_device *phydev) { - int fw_ver, fw_type, fw_minor; + struct gpy_priv *priv = phydev->priv; size_t i; - fw_ver = phy_read(phydev, PHY_FWV); - if (fw_ver < 0) - return true; - - fw_type = FIELD_GET(PHY_FWV_TYPE_MASK, fw_ver); - fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, fw_ver); - for (i = 0; i < ARRAY_SIZE(ver_need_sgmii_reaneg); i++) { - if (fw_type != ver_need_sgmii_reaneg[i].type) + if (priv->fw_type != ver_need_sgmii_reaneg[i].type) continue; - if (fw_minor < ver_need_sgmii_reaneg[i].minor) + if (priv->fw_minor < ver_need_sgmii_reaneg[i].minor) return true; break; } @@ -605,18 +612,12 @@ static int gpy_loopback(struct phy_device *phydev, bool enable) static int gpy115_loopback(struct phy_device *phydev, bool enable) { - int ret; - int fw_minor; + struct gpy_priv *priv = phydev->priv; if (enable) return gpy_loopback(phydev, enable); - ret = phy_read(phydev, PHY_FWV); - if (ret < 0) - return ret; - - fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret); - if (fw_minor > 0x0076) + if (priv->fw_minor > 0x76) return gpy_loopback(phydev, 0); return genphy_soft_reset(phydev); From patchwork Tue Jul 12 13:15:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12914983 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32DCACCA47C for ; Tue, 12 Jul 2022 13:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232158AbiGLNQM (ORCPT ); Tue, 12 Jul 2022 09:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbiGLNQJ (ORCPT ); Tue, 12 Jul 2022 09:16:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1280D80519; Tue, 12 Jul 2022 06:16:04 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 2B6752224D; Tue, 12 Jul 2022 15:16:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657631762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0q0S8Q96ZyO6ESUfNLtf32EjwK3M5wnz6DlAPCArk/0=; b=dU7Gvw0FO1+t3dAqq98T4F8dnbwt9NbD0skFCreGpEDLwG4u5lzNI06s5R5zJyrFlaHWBF JY992rfDAlsjQoTHAeaQxREI/oNAgtvfrK+6Vg171MXazQudN39heignRQY3g/aHV4FFIn ofYVrsKyrbBm73UH+HOAgQOsdM72PPU= From: Michael Walle To: Xu Liang , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 3/4] net: phy: mxl-gpy: rename the FW type field name Date: Tue, 12 Jul 2022 15:15:53 +0200 Message-Id: <20220712131554.2737792-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220712131554.2737792-1-michael@walle.cc> References: <20220712131554.2737792-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Align the firmware field name with the reference manual where it is called "major". Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn --- drivers/net/phy/mxl-gpy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index b6303089d425..ac62b01c61ed 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -56,7 +56,7 @@ PHY_IMASK_ANC) #define PHY_FWV_REL_MASK BIT(15) -#define PHY_FWV_TYPE_MASK GENMASK(11, 8) +#define PHY_FWV_MAJOR_MASK GENMASK(11, 8) #define PHY_FWV_MINOR_MASK GENMASK(7, 0) /* SGMII */ @@ -78,12 +78,12 @@ #define WOL_EN BIT(0) struct gpy_priv { - u8 fw_type; + u8 fw_major; u8 fw_minor; }; static const struct { - int type; + int major; int minor; } ver_need_sgmii_reaneg[] = { {7, 0x6D}, @@ -222,7 +222,7 @@ static int gpy_probe(struct phy_device *phydev) fw_version = phy_read(phydev, PHY_FWV); if (fw_version < 0) return fw_version; - priv->fw_type = FIELD_GET(PHY_FWV_TYPE_MASK, fw_version); + priv->fw_major = FIELD_GET(PHY_FWV_MAJOR_MASK, fw_version); priv->fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, fw_version); ret = gpy_hwmon_register(phydev); @@ -242,7 +242,7 @@ static bool gpy_sgmii_need_reaneg(struct phy_device *phydev) size_t i; for (i = 0; i < ARRAY_SIZE(ver_need_sgmii_reaneg); i++) { - if (priv->fw_type != ver_need_sgmii_reaneg[i].type) + if (priv->fw_major != ver_need_sgmii_reaneg[i].major) continue; if (priv->fw_minor < ver_need_sgmii_reaneg[i].minor) return true; From patchwork Tue Jul 12 13:15:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12914982 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F101DC433EF for ; Tue, 12 Jul 2022 13:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232641AbiGLNQL (ORCPT ); Tue, 12 Jul 2022 09:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbiGLNQJ (ORCPT ); Tue, 12 Jul 2022 09:16:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543C5820F5; Tue, 12 Jul 2022 06:16:04 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 7B03E2224E; Tue, 12 Jul 2022 15:16:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657631762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ttA7hy2efh7uguHjjZhwytdsronnsa+uPbqeqsgPMs=; b=Tf0NSwVJFA9kgNler/v6L6I6kKX6RiOhRx5fjARTAbhtUzVgqkpz6meDwoqWgBl/u8kWar hhjaMABl7wRs2i4eqfI2PYRLkHSK5in/tlGkoFVOZE9Gg7ZPNgYfezukBlZUPLCycFjHOS qGRnp5PCvn/n3p2rDBJpTWhIYi/WfmM= From: Michael Walle To: Xu Liang , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 4/4] net: phy: mxl-gpy: print firmware in human readable form Date: Tue, 12 Jul 2022 15:15:54 +0200 Message-Id: <20220712131554.2737792-5-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220712131554.2737792-1-michael@walle.cc> References: <20220712131554.2737792-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now having a major and a minor number, also print the firmware in human readable form "major.minor". Still keep the 4-digit hexadecimal representation because that form is used in the firmware changelog documents. Also, drop the "release" string assuming that most common case, but make it clearer that the user is running a test version. Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn --- drivers/net/phy/mxl-gpy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index ac62b01c61ed..24bae27eedef 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -230,8 +230,9 @@ static int gpy_probe(struct phy_device *phydev) return ret; /* Show GPY PHY FW version in dmesg */ - phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n", fw_version, - (fw_version & PHY_FWV_REL_MASK) ? "release" : "test"); + phydev_info(phydev, "Firmware Version: %d.%d (0x%04X%s)\n", + priv->fw_major, priv->fw_minor, fw_version, + fw_version & PHY_FWV_REL_MASK ? "" : " test version"); return 0; }