From patchwork Thu Feb 8 11:17:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sneh Shah X-Patchwork-Id: 198317 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp92942dyd; Thu, 8 Feb 2024 03:18:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXILp/9Ej0HifvRV+p1SNM8iLBSimSwewJeoeDwRrpMZchkxsQl0nk3BWNOOJdlCebSi4o7rBCu3jOpgF9yI92Ug1G8iw== X-Google-Smtp-Source: AGHT+IF0zJ1J2kUpBnlsSOwBEswVs3Ud7PgBuG04Tgv3repBbHCtsSJ4yAz9BmqbRkPkg9sr0N7w X-Received: by 2002:ac8:5a41:0:b0:42c:33ca:637c with SMTP id o1-20020ac85a41000000b0042c33ca637cmr12066089qta.54.1707391094189; Thu, 08 Feb 2024 03:18:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707391094; cv=pass; d=google.com; s=arc-20160816; b=RUOOrA5HGzZp+a2r7qztAPD97xxM1CS3ZxusS6WIasMfZG/Wbyeta7yY/+9o79ULHX t6KsggJs6LBjW/NeV/dHdSz/hSMXxzyeOPMXWxdQjqVvggQFCRsXBkjdR2r+gmWfGvvl +DWfCSDgEp2wKsMekStog5MX2TOW5eDddv8r5AofVQr8ce8IEs/GIbSxGj9s76rC5PSN xGXHkIRA5ge3dO6vfgPuUEI2vVIS0Mzf86qj3bbaZcKDiB4pU3wCmi2VcOeF7re6GBsH kN4XmC7b67lLa3e78ZFf0BjmYhGUmFNXcc6oO2SMLxVEStumWTlUp8tbtakAgsRcG6O7 +8PA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=P7rVxZZV6fmCKYVVkz4X2Lp65M9s3qN4g2zODqDihLY=; fh=Av9Y2yDTcQrQeSkJkQQ7lXwQ4A4Nz0vLOZgEDhTc80c=; b=wL7ICWDtU1UcMSVr1o+60By3P638bURLD1KsG7I/oVZ1LsgoQUFu/GNwm3LzMhuT/k iL75N6k+iu/xnJBkget7W7m9VcBdkm2jRBgn5jHs2VnJPCn4aGl+LkACrHKBIzjT6S9V W5dPIyjyW6K6/128Lx6TXFenhga5iZ4FbMXar5PN5ODVOE/QqGvV4Fdh9xlAbc8+XjOU sc9sIzSxG+Q3usytox6Wz8OiJoFNuuFr9KZM1Jwa+cIYs5Us7SDa5ehoqFb+T0mvmqmQ Yd2/ESvEkm14It7TVLwh+kmUNGKpdJHSQ5Jz9lPeS8bEIGpwIyT2byywIq+8OFGZ/rjz vzHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gDCUxCnu; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-57957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCVi3KV8gx5OtGSMvw0NLRsBySdjOiXZbejNSjCg8o8EbmNyTfJ174jPLQ972C3jfbuJZJeGmWTFCcOLN7469Jx+XARd5g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c4-20020ac85a84000000b0042c45082b5dsi2359506qtc.424.2024.02.08.03.18.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:18:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gDCUxCnu; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-57957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DC66C1C27F99 for ; Thu, 8 Feb 2024 11:18:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51F436F098; Thu, 8 Feb 2024 11:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="gDCUxCnu" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 775D52628C; Thu, 8 Feb 2024 11:17:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391068; cv=none; b=tahpzv0Bcm89VBeAjw7czcIejSI1OopANju3jErS92c1KQIWo/6gRrU16qaJYMVk0nnTdtrurcDIpaUx+2/CP1MYi/wbI4uFW2S5CE4hAlytoIpPdfYaoHTAh9hAjaI3vpP8xfg3ZpeyQUSLNZc3HtujWgPJgeQCWanlU9ss4is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707391068; c=relaxed/simple; bh=5Dk/vO8WfkPjH3MNYNEstO4x37MmshYkmWqY5gOSRmE=; h=From:To:Cc:Subject:Date:Message-Id; b=rq66CDGZQPjlyNSW6YShgccP/bg6Bldtn/9Jq6namlrt2F/xiqpe6BLw3VDRbpGBwe4AxgrdXAov4pFlZtoBAp0rLxUprvyS2cft8e5tSQS84rGC33Nx7FOr6HaUKheZjWdnQGFFkrfgbZ6+c7xjRlu+aIoXvn3r4MNkoNDBViE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=gDCUxCnu; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4188i96d025233; Thu, 8 Feb 2024 11:17:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id; s=qcppdkim1; bh=P7rVxZZV6fmC KYVVkz4X2Lp65M9s3qN4g2zODqDihLY=; b=gDCUxCnu+AseLf6oIxUMJk6RjIZd STkPuSPd/K5NrZQFRJ/KfscByFBcUd3Ve+fpATEL+Y3O6PdBOM1t73jlaIkk7Ad0 PwzvgaS9ZHxOAuw8v0Dc4WAGL/MZY3c++EjU6mG2/7or/kciktoqGOXsQZGywYqH diqi47l8RurDAA5xEFTZj9zC8Mzv6LeNhyr9u/icZJI2GqzpJzhqHSdFjxbhiEsB W3uieLmo3pgS0JQQyY+9SbQRtRJkQ1+kZExS/xomlP1dk0Su9GB/M1QQv25LhNHq QP4Sm4SQvs1crcCEkgH9rvUqHrehrIsRWrJupACngpHt6X1Olk8PGWtHgA== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4uphrdga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 11:17:24 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 418BHKFW002481; Thu, 8 Feb 2024 11:17:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3w1ejkjk8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 08 Feb 2024 11:17:20 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418BHJOH002476; Thu, 8 Feb 2024 11:17:19 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-snehshah-hyd.qualcomm.com [10.147.246.35]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 418BHJIm002475; Thu, 08 Feb 2024 11:17:19 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2319345) id 395085001C3; Thu, 8 Feb 2024 16:47:18 +0530 (+0530) From: Sneh Shah To: Vinod Koul , Bhupesh Sharma , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sneh Shah , kernel@quicinc.com, Andrew Halaney Subject: [PATCH net-next v4] net: stmmac: dwmac-qcom-ethqos: Add support for 2.5G SGMII Date: Thu, 8 Feb 2024 16:47:14 +0530 Message-Id: <20240208111714.11456-1-quic_snehshah@quicinc.com> X-Mailer: git-send-email 2.17.1 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: EhHtJoGy1q9ewg8b0xFfVo4bkyUoG0Bq X-Proofpoint-GUID: EhHtJoGy1q9ewg8b0xFfVo4bkyUoG0Bq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_03,2024-02-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402080059 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790329323564820174 X-GMAIL-MSGID: 1790329323564820174 Serdes phy needs to operate at 2500 mode for 2.5G speed and 1000 mode for 1G/100M/10M speed. Added changes to configure serdes phy and mac based on link speed. Changing serdes phy speed involves multiple register writes for serdes block. To avoid redundant write operations only update serdes phy when new speed is different. Signed-off-by: Sneh Shah --- v4 changelog: - Made cosmetic changes v3 changelog: - updated commit message --- v2 changelog: - updated stmmac_pcs_ane to support autoneg disable - Update serdes speed to 1000 for 100M and 10M also--- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 26 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 31631e3f89d0..6bbdbb7bef44 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -106,6 +106,7 @@ struct qcom_ethqos { struct clk *link_clk; struct phy *serdes_phy; unsigned int speed; + int serdes_speed; phy_interface_t phy_mode; const struct ethqos_emac_por *por; @@ -606,19 +607,39 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) */ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) { + struct net_device *dev = platform_get_drvdata(ethqos->pdev); + struct stmmac_priv *priv = netdev_priv(dev); int val; val = readl(ethqos->mac_base + MAC_CTRL_REG); switch (ethqos->speed) { + case SPEED_2500: + val &= ~ETHQOS_MAC_CTRL_PORT_SEL; + rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, + RGMII_CONFIG2_RGMII_CLK_SEL_CFG, + RGMII_IO_MACRO_CONFIG2); + if (ethqos->serdes_speed != SPEED_2500) + phy_set_speed(ethqos->serdes_phy, SPEED_2500); + ethqos->serdes_speed = SPEED_2500; + stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 0, 0, 0); + break; case SPEED_1000: val &= ~ETHQOS_MAC_CTRL_PORT_SEL; rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, RGMII_IO_MACRO_CONFIG2); + if (ethqos->serdes_speed != SPEED_1000) + phy_set_speed(ethqos->serdes_phy, SPEED_1000); + ethqos->serdes_speed = SPEED_1000; + stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); break; case SPEED_100: val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; + if (ethqos->serdes_speed != SPEED_1000) + phy_set_speed(ethqos->serdes_phy, SPEED_1000); + ethqos->serdes_speed = SPEED_1000; + stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); break; case SPEED_10: val |= ETHQOS_MAC_CTRL_PORT_SEL; @@ -627,6 +648,10 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) FIELD_PREP(RGMII_CONFIG_SGMII_CLK_DVDR, SGMII_10M_RX_CLK_DVDR), RGMII_IO_MACRO_CONFIG); + if (ethqos->serdes_speed != SPEED_1000) + phy_set_speed(ethqos->serdes_phy, ethqos->speed); + ethqos->serdes_speed = SPEED_1000; + stmmac_pcs_ctrl_ane(priv, priv->ioaddr, 1, 0, 0); break; } @@ -799,6 +824,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) "Failed to get serdes phy\n"); ethqos->speed = SPEED_1000; + ethqos->serdes_speed = SPEED_1000; ethqos_update_link_clk(ethqos, SPEED_1000); ethqos_set_func_clk_en(ethqos); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index aefc121464b5..13a30e6df4c1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -110,6 +110,8 @@ static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, /* Enable and restart the Auto-Negotiation */ if (ane) value |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN; + else + value &= ~GMAC_AN_CTRL_ANE; /* In case of MAC-2-MAC connection, block is configured to operate * according to MAC conf register.