Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7987531rwr; Wed, 10 May 2023 16:05:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mS0r86WwHLKSYntYJsgBc5NM/Hz3yqXlQ9vWzHh/dJWgpXOofHAO2UEIB8k5jDZXfpSmO X-Received: by 2002:a17:902:f80b:b0:1a6:d4cb:eeb3 with SMTP id ix11-20020a170902f80b00b001a6d4cbeeb3mr17185497plb.63.1683759913419; Wed, 10 May 2023 16:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683759913; cv=none; d=google.com; s=arc-20160816; b=d7NS7nEuuDvqv5UknEOmKoMuwsxGterSpTuVWluaE61IyFSietbDgg1jHvWtEThTeo SjBtW2abtASyYryCxcny0BONcuGm6ahka9yeQ2oPZP2c8UNJ+JWhvONO79ELEP5csVw7 EPQcZVjU6+hEzcrCgMhM9DXrb6uhTD6wXmobv4uSnv+v0RPH1WKzRDf+30MdjhuQQ0Mb NBdcMP+fvM3SG9xzxXFExyVYdNERMoRDZprU1hu0QCKJ/bW5W/lXAVzC/6/EdayugvzW 6xTN4wmznTPwhufczY5dsenLNuG7vFCFymT0aI2VcLNSdDRW1c5a72zSdsJTqk8HwNRi hHFw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a170902da8200b001a6a1ed899csi612830plx.644.2023.05.10.16.05.01; Wed, 10 May 2023 16:05:13 -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 S236629AbjEJXAI (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-Type: text/plain; charset=us-ascii 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 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); } -- 2.40.0