From patchwork Thu Nov 9 21:51:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 163613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp727674vqs; Thu, 9 Nov 2023 13:52:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH7MEBtUfZa+wSV6Hwwo4IwFjZB+IWXeYf2ptx+rQEGXof2a40Zho6RsdRjKXjs2XUBuQq X-Received: by 2002:a17:90a:ba0f:b0:27d:375d:c16e with SMTP id s15-20020a17090aba0f00b0027d375dc16emr2863732pjr.42.1699566735297; Thu, 09 Nov 2023 13:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699566735; cv=none; d=google.com; s=arc-20160816; b=mpCI0xhkaHdiIuANgh4dct9TygOjysuvDKFxXt4ouuLSjN1xwnfBRReM5iAYSiWTzj ka8vSu+EkyaLOYOcZLtavtX8jAyRqkF+8OAt5J3EyyF/xjUKOpzGZ/iqxsm+9z/fVQeu KsT439au9gePZxgoBkcw2/hCsc1PHJw3ms7mIU42Y4VPDY0lwLVw7FSFWzZDBH7CC+rc 0PPExdLn+smlUTr0dj9/H0jKl93q68viNGLQvvcgFZTVQhvIwioIAZCldCErsUq8MtVK 8zy/O5jvkD5SSEyp2KcijXYt/3jUWi+/mn/lMkgcTHSz38EtIY5E/Koq4ufZuDxopahR 2UCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=d3quOEc+H0+05qOxGg6i/OWIccEb1Kdj6xy+Hw/3G1M=; fh=9GVzMIks0k0Waq6W0HUSHcdxejYnykUnl93AUDny5kk=; b=m7+XXsdLQlz64xowXnDfWXDgeRUVw3Iwd3PHHLwOXp5bwywPdrluzo8CeXY4bSH3Mz Eorn0N8oDEQNxymOEo0ZiC1qgGGRNzVHweeyk/OD2ClCIlmme42ib/907JOGASwB5VF4 cItzZUmjwUKi8fu4jTyxjvr5CZEWU70n0gY8hTR0du5YYttF2EE5rTvY9a2zPoIuNYq0 vOF2LcUkGCJsq3lnFMve7UqRJdkY3OnWJ2BpSCW7O2AZSUutjsxptI7AfHNP2ngLsaHq EL8Oopsl0XNi+OtZ6VXLQJDM8o2VbI0RQfY/RyOGod02sRZiEENLbBo5sJT1H04ePL6I PYnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id pc17-20020a17090b3b9100b00278eb61c0ebsi2716874pjb.118.2023.11.09.13.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 13:52:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6B7A383038A2; Thu, 9 Nov 2023 13:52:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234657AbjKIVvs (ORCPT + 30 others); Thu, 9 Nov 2023 16:51:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345281AbjKIVvj (ORCPT ); Thu, 9 Nov 2023 16:51:39 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56AE8420F; Thu, 9 Nov 2023 13:51:37 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1r1Cvu-0003Vy-0e; Thu, 09 Nov 2023 21:51:26 +0000 Date: Thu, 9 Nov 2023 21:51:22 +0000 From: Daniel Golle To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Andrew Lunn , Heiner Kallweit , Russell King , Alexander Couzens , Daniel Golle , Philipp Zabel , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org Subject: [RFC PATCH 3/8] net: pcs: pcs-mtk-lynxi: use 2500Base-X without AN Message-ID: <091e466912f1333bb76d23e95dc6019c9b71645f.1699565880.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 09 Nov 2023 13:52:11 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782124888822619234 X-GMAIL-MSGID: 1782124888822619234 Using 2500Base-T SFP modules e.g. on the BananaPi R3 requires manually disabling auto-negotiation, e.g. using ethtool. While a proper fix using SFP quirks is being discussed upstream, bring a work-around to restore user experience to what it was before the switch to the dedicated SGMII PCS driver. Signed-off-by: Daniel Golle --- drivers/net/pcs/pcs-mtk-lynxi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/pcs/pcs-mtk-lynxi.c b/drivers/net/pcs/pcs-mtk-lynxi.c index 8501dd365279b..6204448d8eac6 100644 --- a/drivers/net/pcs/pcs-mtk-lynxi.c +++ b/drivers/net/pcs/pcs-mtk-lynxi.c @@ -92,14 +92,23 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); - unsigned int bm, adv; + unsigned int bm, bmsr, adv; /* Read the BMSR and LPA */ regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm); - regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv); + bmsr = FIELD_GET(SGMII_BMSR, bm); + + if (state->interface == PHY_INTERFACE_MODE_2500BASEX) { + state->link = !!(bmsr & BMSR_LSTATUS); + state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); + state->speed = SPEED_2500; + state->duplex = DUPLEX_FULL; + + return; + } - phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm), - FIELD_GET(SGMII_LPA, adv)); + regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv); + phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv)); } static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, @@ -129,7 +138,8 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, if (neg_mode & PHYLINK_PCS_NEG_INBAND) sgm_mode |= SGMII_REMOTE_FAULT_DIS; - if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED && + interface != PHY_INTERFACE_MODE_2500BASEX) { if (interface == PHY_INTERFACE_MODE_SGMII) sgm_mode |= SGMII_SPEED_DUPLEX_AN; bmcr = BMCR_ANENABLE;