From patchwork Fri Oct 21 15:09:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 617284 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 C039AC433FE for ; Fri, 21 Oct 2022 15:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbiJUPJu (ORCPT ); Fri, 21 Oct 2022 11:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiJUPJn (ORCPT ); Fri, 21 Oct 2022 11:09:43 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196BF357F8; Fri, 21 Oct 2022 08:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dJnfrd9PAQikF9AnaX83iDIDtvEV0H9qvFXsF0c/yNc=; b=GHp4OD5Qwe/AEjWlJ/50d28rQh F+jnP5LqHDO34lwl3PCDIcKLZV2hHrUUJPWRyeNxr0gHvTi4zl9IUUK3Y4KTrE9BBJXyg6vzYOuYu hNrfrGwn5CLYV17y850rXtq5xPD8eBg6tqAwgIIwpAVBrHxt4LY7jaGezhI3H7S+chxci+s0tREO9 5uhwvaJUXvO28yJ1OTnEU2SX38RX1N6oz6N0PR790OAJv/Ltqyu/rMpW7Ba547ZLwCZJXVu0H0q3t cXKpQ7usHQU1ZNWZdnLxLL0/+57JjXv6OypqJyR9QWNG55skUHDrfBwsMgFoLlBt3PUEN44jlQixL LV4NGeQA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52004 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olteV-0000M2-EX; Fri, 21 Oct 2022 16:09:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1olteU-00Fwwi-PT; Fri, 21 Oct 2022 16:09:38 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: "David S. Miller" , Jakub Kicinski Cc: Andrew Lunn , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Krzysztof Kozlowski , netdev@vger.kernel.org, Paolo Abeni , Rob Herring Subject: [PATCH net-next 1/7] dt-bindings: net: sff,sfp: update binding MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 21 Oct 2022 16:09:38 +0100 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a minimum and default for the maximum-power-milliwatt option; module power levels were originally up to 1W, so this is the default and the minimum power level we can have for a functional SFP cage. Signed-off-by: Russell King (Oracle) --- Documentation/devicetree/bindings/net/sff,sfp.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/sff,sfp.yaml b/Documentation/devicetree/bindings/net/sff,sfp.yaml index 06c66ab81c01..231c4d75e4b1 100644 --- a/Documentation/devicetree/bindings/net/sff,sfp.yaml +++ b/Documentation/devicetree/bindings/net/sff,sfp.yaml @@ -22,7 +22,8 @@ title: Small Form Factor (SFF) Committee Small Form-factor Pluggable (SFP) phandle of an I2C bus controller for the SFP two wire serial maximum-power-milliwatt: - maxItems: 1 + minimum: 1000 + default: 1000 description: Maximum module power consumption Specifies the maximum power consumption allowable by a module in the slot, in milli-Watts. Presently, modules can From patchwork Fri Oct 21 15:09:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 617283 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 AB6D9C433FE for ; Fri, 21 Oct 2022 15:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbiJUPKN (ORCPT ); Fri, 21 Oct 2022 11:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbiJUPJw (ORCPT ); Fri, 21 Oct 2022 11:09:52 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A9548CA2; Fri, 21 Oct 2022 08:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6rqIsGiuGIbdm1Qj9PHgbZHxsJ3BDKwgjZR6ybGW1JM=; b=b1DHpi7denXfkIoftwNCnml+8R d7lceXL58JRZOfp7r2sTm3I+y2ZSnhMwOW/5xu65wUcq5apkdWbwb0V85pszS07yVHZFyGKDfRc+b C2W3ksc7R8rdrx3WB9Ejrn2HiFo7DdmB7AqDcdSxLH5hkNBvLoCnhqACQR0qTb1nzBa5uClD2oW6q SuMoXknP9b+N/6cSG5tzcnEpDQrZ6tkuL76GxkKvXhmWGrnw80eL5C8wJUNYBrOlS4C6MonqMSCrp Jzb3arUUnafqaaqmxrgq+BrVMZuHoG8/Ko/HRnVDKtejo+cq3U5PODgcRNNqWOdjjF1/YuKs/SMTV 4Aj100Ww==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60366 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oltef-0000MU-Pl; Fri, 21 Oct 2022 16:09:49 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oltef-00Fwwz-3t; Fri, 21 Oct 2022 16:09:49 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: "David S. Miller" , Jakub Kicinski Cc: Andrew Lunn , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Krzysztof Kozlowski , netdev@vger.kernel.org, Paolo Abeni , Rob Herring Subject: [PATCH net-next 3/7] net: sfp: ignore power level 2 prior to SFF-8472 Rev 10.2 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 21 Oct 2022 16:09:49 +0100 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Power level 2 was introduced by SFF-8472 revision 10.2. Ignore the power declaration bit for modules that are not compliant with at least this revision. This should remove any spurious indication of 1.5W modules. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/sfp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index f7ad4d5d9041..a7635b02524a 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1761,7 +1761,8 @@ static int sfp_module_parse_power(struct sfp *sfp) u32 power_mW = 1000; bool supports_a2; - if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL)) + if (sfp->id.ext.sff8472_compliance >= SFP_SFF8472_COMPLIANCE_REV10_2 && + sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL)) power_mW = 1500; if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL)) power_mW = 2000; From patchwork Fri Oct 21 15:09:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 617282 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 9F5DFC433FE for ; Fri, 21 Oct 2022 15:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbiJUPKs (ORCPT ); Fri, 21 Oct 2022 11:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbiJUPKL (ORCPT ); Fri, 21 Oct 2022 11:10:11 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F271E75FF4; Fri, 21 Oct 2022 08:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7H4ttJKRH0pSFYxxGqIOxLFjjfnbU3ChjsIdXUJw408=; b=XF67eeYTOEbEAmiZa/RuSD3vWf 7CVMCUpT5UzeaendNWLnxqvFZirMd+jVkXk7WiVXVlXq/Kc8wZ5MKUffiE93GJ+KBkHr8C8QoQVWz D5w3MKRB7hSj7FGPF72AuUvGK/l9K1NECcgdXi6SAnVOv8cxMPATTmGtbP12S8IFuFYUwnWCan2cd mvXgUeBVu/+56NX5lvCbrM6Ni47KV1efK5CeySXjTUpy2J4ja41mArjjesNi5jgE8d4/eWZP89nxZ xNTblnaXExpzmhtDcELtAy1L2qQZ5rTbxHnADW91NHZ8spIy62DWDmANHsMDPECtvIVFXOM5lTZaO FKjWZ77Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36032 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olteq-0000Mu-3c; Fri, 21 Oct 2022 16:10:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oltep-00FwxB-EN; Fri, 21 Oct 2022 16:09:59 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: "David S. Miller" , Jakub Kicinski Cc: Andrew Lunn , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Krzysztof Kozlowski , netdev@vger.kernel.org, Paolo Abeni , Rob Herring Subject: [PATCH net-next 5/7] net: sfp: provide a definition for the power level select bit MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 21 Oct 2022 16:09:59 +0100 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Provide a named definition for the power level select bit in the extended status register, rather than using BIT(0) in the code. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/sfp.c | 6 +++--- include/linux/sfp.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index af676e28ba6a..16bce0ea68d9 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1837,13 +1837,13 @@ static int sfp_sm_mod_hpower(struct sfp *sfp, bool enable) * all bytes 0xff) at 0x51 but does not accept writes. In any case, * if the bit is already set, we're already in high power mode. */ - if (!!(val & BIT(0)) == enable) + if (!!(val & SFP_EXT_STATUS_PWRLVL_SELECT) == enable) return 0; if (enable) - val |= BIT(0); + val |= SFP_EXT_STATUS_PWRLVL_SELECT; else - val &= ~BIT(0); + val &= ~SFP_EXT_STATUS_PWRLVL_SELECT; err = sfp_write(sfp, true, SFP_EXT_STATUS, &val, sizeof(val)); if (err != sizeof(val)) { diff --git a/include/linux/sfp.h b/include/linux/sfp.h index d1f343853b6c..01ae9f1dd2ad 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h @@ -489,6 +489,8 @@ enum { SFP_WARN1_RXPWR_LOW = BIT(6), SFP_EXT_STATUS = 0x76, + SFP_EXT_STATUS_PWRLVL_SELECT = BIT(0), + SFP_VSL = 0x78, SFP_PAGE = 0x7f, }; From patchwork Fri Oct 21 15:10:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 617281 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 C40A4C43217 for ; Fri, 21 Oct 2022 15:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbiJUPKv (ORCPT ); Fri, 21 Oct 2022 11:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbiJUPKQ (ORCPT ); Fri, 21 Oct 2022 11:10:16 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01432A52F6; Fri, 21 Oct 2022 08:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CdzXJYSUP5pe0nNmt5zqsj5UcWBs/9HSTXlHf2H/4oI=; b=GiavR2ITDiDNg5NwEgCNHOormm Z8V5P4kgoO1G8OGNPeoQVH+DphOJwJAElTnj7e8Ho9oNFlj7JtgV+L8m9SsrVx1mviOtbLtdO6C5E wo4rjTwFACduJ1M57u4ViY01uRMOK4G+lRDg3CXrLQ3GE7Z+b8fJAf1W+M8nORlMNpYX4lsFxySSO 0ALfmi0HEy3dmj+MTvubb5db6llK57KoDW1SKK7XdL4W/X5H9JWRmmtNKbXwEnRO/7Wnj5nQ2/+Vf 2DX6zL3Q5YoUpEoBIgQemcRACt8u87/VwHpnsWc5eLwDLB2D50hfkD/W+Kn8xoe3zq1a3oA1Okesa eRwha3GQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:42514 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oltev-0000NA-8r; Fri, 21 Oct 2022 16:10:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1olteu-00FwxH-J5; Fri, 21 Oct 2022 16:10:04 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: "David S. Miller" , Jakub Kicinski Cc: Andrew Lunn , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Krzysztof Kozlowski , netdev@vger.kernel.org, Paolo Abeni , Rob Herring Subject: [PATCH net-next 6/7] net: sfp: add sfp_modify_u8() helper MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Fri, 21 Oct 2022 16:10:04 +0100 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a helper to modify bits in a single byte in memory space, and use it when updating the soft tx-disable flag in the module. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/sfp.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 16bce0ea68d9..921bbedd9b22 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -608,6 +608,22 @@ static int sfp_write(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len) return sfp->write(sfp, a2, addr, buf, len); } +static int sfp_modify_u8(struct sfp *sfp, bool a2, u8 addr, u8 mask, u8 val) +{ + int ret; + u8 old, v; + + ret = sfp_read(sfp, a2, addr, &old, sizeof(old)); + if (ret != sizeof(old)) + return ret; + + v = (old & ~mask) | (val & mask); + if (v == old) + return sizeof(v); + + return sfp_write(sfp, a2, addr, &v, sizeof(v)); +} + static unsigned int sfp_soft_get_state(struct sfp *sfp) { unsigned int state = 0; @@ -633,17 +649,14 @@ static unsigned int sfp_soft_get_state(struct sfp *sfp) static void sfp_soft_set_state(struct sfp *sfp, unsigned int state) { - u8 status; + u8 mask = SFP_STATUS_TX_DISABLE_FORCE; + u8 val = 0; - if (sfp_read(sfp, true, SFP_STATUS, &status, sizeof(status)) == - sizeof(status)) { - if (state & SFP_F_TX_DISABLE) - status |= SFP_STATUS_TX_DISABLE_FORCE; - else - status &= ~SFP_STATUS_TX_DISABLE_FORCE; + if (state & SFP_F_TX_DISABLE) + val |= SFP_STATUS_TX_DISABLE_FORCE; - sfp_write(sfp, true, SFP_STATUS, &status, sizeof(status)); - } + + sfp_modify_u8(sfp, true, SFP_STATUS, mask, val); } static void sfp_soft_start_poll(struct sfp *sfp)