From patchwork Wed Nov 15 14:06:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 165389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2561008vqg; Wed, 15 Nov 2023 06:09:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IH50mNWxz1H/ZiOs+W70+NX4ZE+67yv70Sc3BX+HF9WG5S5evgySGg6Wn/J3rsXUagg5Pjy X-Received: by 2002:a05:6808:998:b0:3a8:432a:ea13 with SMTP id a24-20020a056808099800b003a8432aea13mr15629896oic.46.1700057382664; Wed, 15 Nov 2023 06:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700057382; cv=none; d=google.com; s=arc-20160816; b=OG5bo9WOG7Yj+tqgDhBp87N3ilvMt5EDiMHn9/75D7mheGicz1t6Un1lziYasMPQpD 2tjrpV6QLKQfaucv2kXrqCLbtLiVaq56J6yrPYF811EhqrmpCy7n9Yz7H21PV9mLotpj SX2qTIIVuBnk26248ki6LFe7pGbJA11yilg0sOGZLy4jgrr6GohmZFKqbwLl/cTpNnst L2qGl6k1nG1dfcvrnDaNDp2IkMSiYxSRvpDEVBJrbsdo4tZEnDcu0Q3zK4tGh6kiygFI iQccg4CIT64Rcgzk3jQA1/m/LPcXB2X2HV63TAW6Juh60VQQS1CkJO7EBNNLGUcvjWwE qvhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uxMZ5i08IIj1P3XHjsuTSAB7PjcYnIlgE+t3bDDRN3U=; fh=CzJZH1Mq0+1gFor3WuKjwLRRL9rPD0zvQs0go/fRLgA=; b=kE1UNhfrL1R6QJFvBJroeHwTrCwC/tl1K4o0uH4EnJwy7wBVdKzSfDavbcNUTamcV1 seiiuXBlUoQWIcfhT2v47aBNgqJ6yxsR83FcMeGEb+fxZywMmdL+8R2nr0q1yOkZH2vE pDQ+KOYVakNXET7uxEs2w2GAE+yUzAL1BRIDEd6/hP10DVrYJr2VCDb0NUjabAzrzElA 8JW/COMS+R/N+1pY60jd0uebcsd2Bipx0VHYHAASb+oGuhAU9F9pZvj6HMYyQk6ViCn4 wsPXv29UfxeJduBtTA0OE8ZEtePpnxAOGzM0Sdk0bEkp84DAgXGEi7glMg/o52iHAJ6F d2Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VauVzqMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id az14-20020a056808164e00b003b2d711b76dsi3515231oib.176.2023.11.15.06.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 06:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VauVzqMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 66E70801CCC7; Wed, 15 Nov 2023 06:09:37 -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 S1344120AbjKOOJW (ORCPT + 28 others); Wed, 15 Nov 2023 09:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344190AbjKOOJR (ORCPT ); Wed, 15 Nov 2023 09:09:17 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35EC1A2; Wed, 15 Nov 2023 06:09:11 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFCaADf027127; Wed, 15 Nov 2023 14:09:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=uxMZ5i08IIj1P3XHjsuTSAB7PjcYnIlgE+t3bDDRN3U=; b=VauVzqMgT5v8ROQzOsyeFy2kYAf2aV2C1BMO+c2cq//ufBG1OBfA/oLzezvfq+uMwPWh tC2fv/3MtjbEtkyGvsc79/R8BaLUlSmPAuA6yMpJMteYKzhRdqfThsQqFa6/HA2v5mNw ast5K0+iJuFTXANuRsUMyY/N6ChEwOLXfPYf6X+KugbtD6FzBYXnHC2vbQPuZvu/vVM6 sHE6/JOvBoTBbCjIFAGqsoomrN7Nk7V+Dhr32NR/Xa0tf+Kyng+YjthNSPDOSzP8PoCE QKFzM84lHlK8FIMeJ5s6hF9IYQ963QMDg4SRptGwugtaOZ1cynCPllUB5Y4U+fMZjtW1 UA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uck901m9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 14:09:00 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AFE8xA3025907 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 14:08:59 GMT Received: from akronite-sh-dev02.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 15 Nov 2023 06:08:56 -0800 From: Luo Jie To: , , , , , , , , , , CC: , , , Subject: [PATCH v3 6/6] net: phy: qca8084: add qca8084_link_change_notify Date: Wed, 15 Nov 2023 22:06:30 +0800 Message-ID: <20231115140630.10858-7-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231115140630.10858-1-quic_luoj@quicinc.com> References: <20231115140630.10858-1-quic_luoj@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: N0jsMtbKAqLZ6WNTZscxJ4XS3MsUe4uF X-Proofpoint-ORIG-GUID: N0jsMtbKAqLZ6WNTZscxJ4XS3MsUe4uF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_13,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150109 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 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]); Wed, 15 Nov 2023 06:09:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782639370047484000 X-GMAIL-MSGID: 1782639370047484000 When the link is changed, qca8084 needs to do the fifo reset and adjust the IPG level for the qusgmii link speed 1000M. Signed-off-by: Luo Jie --- drivers/net/phy/at803x.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 06a068ca5539..7267ce858937 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -289,6 +289,13 @@ #define QCA8084_MSE_THRESHOLD 0x800a #define QCA8084_MSE_THRESHOLD_2P5G_VAL 0x51c6 +#define QCA8084_FIFO_CONTROL 0x19 +#define QCA8084_FIFO_MAC_2_PHY BIT(1) +#define QCA8084_FIFO_PHY_2_MAC BIT(0) + +#define QCA8084_MMD7_IPG_OP 0x901d +#define QCA8084_IPG_10_TO_11_EN BIT(0) + MODULE_DESCRIPTION("Qualcomm Atheros AR803x and QCA808X PHY driver"); MODULE_AUTHOR("Matus Ujhelyi"); MODULE_LICENSE("GPL"); @@ -2109,6 +2116,35 @@ static int qca8084_config_init(struct phy_device *phydev) QCA8084_MSE_THRESHOLD, QCA8084_MSE_THRESHOLD_2P5G_VAL); } +static void qca8084_link_change_notify(struct phy_device *phydev) +{ + int ret; + + ret = phy_modify(phydev, QCA8084_FIFO_CONTROL, + QCA8084_FIFO_MAC_2_PHY | QCA8084_FIFO_PHY_2_MAC, + 0); + if (ret) + return; + + /* If the PHY works on PHY_INTERFACE_MODE_10G_QXGMII mode, the fifo needs to + * be kept as reset state in link down status. + */ + if (phydev->interface != PHY_INTERFACE_MODE_10G_QXGMII || phydev->link) { + msleep(50); + ret = phy_modify(phydev, QCA8084_FIFO_CONTROL, + QCA8084_FIFO_MAC_2_PHY | QCA8084_FIFO_PHY_2_MAC, + QCA8084_FIFO_MAC_2_PHY | QCA8084_FIFO_PHY_2_MAC); + if (ret) + return; + } + + /* Enable IPG 10 to 11 tuning on link speed 1000M of QUSGMII mode. */ + if (phydev->interface == PHY_INTERFACE_MODE_10G_QXGMII) + phy_modify_mmd(phydev, MDIO_MMD_AN, QCA8084_MMD7_IPG_OP, + QCA8084_IPG_10_TO_11_EN, + phydev->speed == SPEED_1000 ? QCA8084_IPG_10_TO_11_EN : 0); +} + static struct phy_driver at803x_driver[] = { { /* Qualcomm Atheros AR8035 */ @@ -2307,6 +2343,7 @@ static struct phy_driver at803x_driver[] = { .cable_test_start = qca808x_cable_test_start, .cable_test_get_status = qca808x_cable_test_get_status, .config_init = qca8084_config_init, + .link_change_notify = qca8084_link_change_notify, }, }; module_phy_driver(at803x_driver);