Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1000003rdb; Wed, 24 Jan 2024 01:26:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn6TEAPnHw3Htaqw80e5WMzgjb96IaFpf/hb502ss5r7htdkVFHfiq8zJaxAPKTV4ZEzNE X-Received: by 2002:a05:6a00:21c6:b0:6db:d186:2f48 with SMTP id t6-20020a056a0021c600b006dbd1862f48mr4296914pfj.51.1706088408746; Wed, 24 Jan 2024 01:26:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706088408; cv=pass; d=google.com; s=arc-20160816; b=o1CvIMAvkhy6waR3TmH6stVbY3YWPicV0L7dG/Px+uzjQkZCXMc6GFERNfx52AcvOF Bph0ofzdSRAOuP9KVQ5j8zU2ZAUgM+9iWP7ftNymMNnuRgqPnOO2WOjvmxDUXb5cq3+x QGgTKtV6PvO/lBKoguUi+DZTzRofekm6OXTGfNESnS5wXbtbgp7pMDp93GkNJ0DM/nex 2fwmNVtrO6JmjNAey+jC/8TgEfA+3Tt2SjUY2da5wKe3puFrR/xv9vhPyX/ftbNvezQ3 k/ArcXZd6u4005pW25FXXgLarxZFytP8zp0HqSTQuMfnwtY1Y72tplsTfhJyV1dNc1hh 1cWg== 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=rugATKa4IkJP2vKvemVbUve3N/NxJypJVtd+Rko963k=; fh=1Jy5qpJ7e4FuBmQkVP0GCA4F+wDSel+w4r34NwoYij8=; b=QtBQ6oaDar4p8JLmSiS9NQCYbzQgImv7K/FrVJ7P7LjRKWqtNgkwPlCrJiJFj06QZO taRhz18mcIlJFvc5GRz0m/rRJJWGeO3lpNqUgrngo4fuzDiKjYHpqEqBHCihB3ekuzPX XEmikCXB/iyG4wspujG7M5wXBdS42nURpfBCrz8zppMUHcrIf44nzJqlFAy1M/ynkCV5 MecV6N2Lt3H4r6hrXRxxZ6lx5dDIACRqtYX0MrSov5rM5asSNCWZULckV2QmlII8jCGl DoVrSgbuXLnQP6+2wSkghZqFpoflVbNQZWMR3Ug2e+CT+CAe0063aeCE+hcret80vMCB dLgg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lfoSjgeS; 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-36712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x4-20020a636304000000b005cee87f85b8si1588512pgb.348.2024.01.24.01.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 01:26:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lfoSjgeS; 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-36712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36712-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9CA902910BE for ; Wed, 24 Jan 2024 09:26:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C4BE182CC; Wed, 24 Jan 2024 09:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lfoSjgeS" 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 9BA3C175AB; Wed, 24 Jan 2024 09:23:31 +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=1706088213; cv=none; b=ddZkHsQUyV7xmlHCxPgF+T7XkP/1ZrVFugSJpMGy2NkGkFxUs8Mj7FvmcjVQE/RIM+sBeCZrOtSkPMcu8VOlqjMJsXEh+Ny8eFrV0vfs/D5mKJdTn9O8K52meSPojbV3imHIVTDMvWeuB6t4RgBvbiYLbQxUh3KvSR3HIIb6cp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706088213; c=relaxed/simple; bh=iXibbrJy5H4kvdEN+3nZQDx0y73tV/y+CG9r37k61+c=; h=From:To:Cc:Subject:Date:Message-Id; b=uDnDXHoFtxUqjCr90pRrgmfo0hI46Y7NoP49Edickb+xZRDgiBBgphZ0hPBqQfiYBdocEyyaPYkJznQ83qG0S7llFN06A1KiREJa561jFlp7AkybSZLTFr7tjLuUMPSrBpjy+lPVj7IdG0nRJjusLiM7I9l6XtCSwwBk3Dy5g6s= 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=lfoSjgeS; 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40O6Pg23018306; Wed, 24 Jan 2024 09:22:33 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=rugATKa4IkJP 2vKvemVbUve3N/NxJypJVtd+Rko963k=; b=lfoSjgeSZYpmNSjR5osO7cR+4p8D hx5/WSJQAwYXX6aH+eRacL8HsgqKtNPT7t6LMDDzYVlETJF6RIXjLiNNE9vjmQxM s2iQ+WSUS7c60U9Pfj7yw5bRTwX0NGw+hEJr3rPlAhk+x7SIFyRKAJralIEaHtMQ 97PgJzSvmgdOkHXYg1NBMrFR7MrxXIJhUBib1hhjYneCYoXzndS4fHDKUCVPog48 uFxaOgFe/JuWtiYYTBbyuJil/Muf7hsFx+2XZ453l3qjOQK1mvWffUyZvTq2RsoN gnFodG555VdTqRboPAdE9ZCp80fpjQYkEduAdxxvi3INj/m4mLVEG34sGw== 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 3vtmgwhc7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Jan 2024 09:22:33 +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 40O9MSeN008245; Wed, 24 Jan 2024 09:22:28 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 3vr78kqtbh-1; Wed, 24 Jan 2024 09:22:28 +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 40O9MSwS008239; Wed, 24 Jan 2024 09:22:28 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 40O9MSg6008228; Wed, 24 Jan 2024 09:22:28 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2319345) id 98C9D5013A3; Wed, 24 Jan 2024 14:52:27 +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 v3] net: stmmac: dwmac-qcom-ethqos: Add support for 2.5G SGMII Date: Wed, 24 Jan 2024 14:52:15 +0530 Message-Id: <20240124092215.14678-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-GUID: QMmXVuFyVlQNjXVjzbLe2p__f21Lpv1D X-Proofpoint-ORIG-GUID: QMmXVuFyVlQNjXVjzbLe2p__f21Lpv1D 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-01-24_04,2024-01-23_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 mlxlogscore=999 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401240066 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 opertions only update serdes phy when new speed is different. Signed-off-by: Sneh Shah --- 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 | 27 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index d3bf42d0fceb..c236c939fbe9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -103,6 +103,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; @@ -602,21 +603,46 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) { int val; + struct platform_device *pdev = ethqos->pdev; + struct net_device *dev = platform_get_drvdata(pdev); + struct stmmac_priv *priv = netdev_priv(dev); 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; val &= ~ETHQOS_MAC_CTRL_SPEED_MODE; + 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; } @@ -789,6 +815,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. -- 2.17.1