From patchwork Wed May 10 22:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 92324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3978271vqo; Wed, 10 May 2023 16:08:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fMvjAomTodGzdFzTTTnZcDfmjxWkL4G7LkkAkrj4rs8NY7xf6vrrcwCHgcQ+gEO9CdAEP X-Received: by 2002:a17:902:bd44:b0:1a6:9d98:e763 with SMTP id b4-20020a170902bd4400b001a69d98e763mr18323665plx.26.1683760110797; Wed, 10 May 2023 16:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683760110; cv=none; d=google.com; s=arc-20160816; b=GGmwDYEEzeyGfV/UDW+o7QNi2pEaLA8hgr3Ql2YXeRRZPzeQFwAwPMs1U4+zyHlllB VmcMnH1AXCjtAWPPDih51CYdQ1WQkJQ9fBFeJ164uVnogcnItk3fq+NiuwtxaRuMrKK7 EwkOIr8ElW4JR3FbxgM2+jELENCWg3czkp89HsmvAYxdso1AnyyQKemWGmfQYOF84Vc7 bKIdg1L2UhgDxi1EVjFY5bvT2ZSlI0tySgAMJPZlrRY5GmYN8C07k2xjqJZAJ9r+My0L NRapZFQl4QsxZ1or8KsZ9GhrVuph6WzBRxAhBWGWSbdQTjeHr+gYBj5QzBGGY/KvfaWa dSfg== 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=2l9h8ojR3yYSLsGeKUCE1lyRpBTvO/ed7Mich777Tpw=; b=dmt5NAQuTExTJlEkxlZbFzXtualYHfpRxnH15KGSHC/w9N19nqTCCpv5tzRBPdH4N9 y2iZBvxyt0yzCPvuaW5TS8ctOGyqrFzds7OBGpbbzG3YBIeW7PXW7HF4QW4GbbPwRwaL BHgJ/IOuARQPP9V+sw8sWpGNvMz8YqOB5cIHwsRJyZH7uW9gx81Sl9o2TaqouWaKpN2m +L3HS0oeR1xTCfwPHca84qb0sE6eXoicyyd+pvxs9shtBGorIeU0Hi4Io/wuGAS/uweK ATdouhD81y9kzIpXFPAAHuRpake+XT+l7ME3MsaN7pl3cXpfmoh1hdIo6lz1UTvQDBeF tDBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170902b48d00b001a52db202c7si4854027plr.382.2023.05.10.16.08.18; Wed, 10 May 2023 16:08:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235708AbjEJXAI (ORCPT + 99 others); Wed, 10 May 2023 19:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236614AbjEJXAH (ORCPT ); Wed, 10 May 2023 19:00:07 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64F9E64; Wed, 10 May 2023 16:00:05 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pwsmy-0004U1-1A; Wed, 10 May 2023 23:00:04 +0000 Date: Thu, 11 May 2023 00:58:10 +0200 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH net-next 4/8] net: phy: realtek: disable SGMII in-band AN for 2.5G PHYs Message-ID: <574c9703523af5643af0623144db3aa385635e84.1683756691.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765550441912209220?= X-GMAIL-MSGID: =?utf-8?q?1765550441912209220?= MAC drivers don't use SGMII in-band autonegotiation unless told to do so in device tree using 'managed = "in-band-status"'. When using MDIO to access a PHY, in-band-status is unneeded as we have link-status via MDIO. Switch off SGMII in-band autonegotiation using magic values. Reported-by: Chen Minqiang Reported-by: Chukun Pan Reported-by: Yevhen Kolomeiko Tested-by: Yevhen Kolomeiko Signed-off-by: Daniel Golle --- drivers/net/phy/realtek.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 0cf7846c9812..acadb6f0057b 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -666,7 +666,7 @@ static int rtl822x_get_features(struct phy_device *phydev) static int rtl822x_config_aneg(struct phy_device *phydev) { - int ret = 0; + int val, ret = 0; if (phydev->autoneg == AUTONEG_ENABLE) { u16 adv2500 = 0; @@ -681,6 +681,19 @@ static int rtl822x_config_aneg(struct phy_device *phydev) return ret; } + /* MACs using phylink assume SGMII in-band status is not used. + * Keep things as they are for MACs not using phylink such as + * RealTek PCIe chips which come with built-in PHYs + */ + if (phydev->phylink) { + /* Disable SGMII AN */ + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7588, 0x2); + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7589, 0x71d0); + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, 0x3); + phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, + val, !(val & BIT(0)), 500, 100000, false); + } + return __genphy_config_aneg(phydev, ret); }