From patchwork Fri Dec 15 07:39:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 179068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9105252dys; Thu, 14 Dec 2023 23:45:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqyHgieN3AQSxxcj09cmRS/YI5Ks1YAkcXY3tDFyUZ076tKOxMjyPzoBdXrnVs9AlQ99em X-Received: by 2002:a05:620a:5599:b0:77e:fe60:ed30 with SMTP id vq25-20020a05620a559900b0077efe60ed30mr12652042qkn.125.1702626313505; Thu, 14 Dec 2023 23:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702626313; cv=none; d=google.com; s=arc-20160816; b=hWmZWkf1Y88togXxCe7ptkLy51RdC5EDMolepHuWIm/fvXkMe4BiSE7qA9S7DUeo16 kqB5z6mohfPz91GaPacnL13/RFcpm9mn6iJsI+G6ShGm+0aEUpjCY/jWGunrcK1e9oVR frtVtmDr2IJGxC783OJtn6LnH/Jbnqwf6z5GZIHo8Ea9kJ+FUibwtdj4KgUQho6iulNk w25sIhZiNf3aDeu7NhnNCobV4VanvTU6cRn+4LPLMMsMNZNdCwGPvm66SODWNCh1Lmar Iu/zf4xRwM94yblI8kubQ+yJOKqKhHEAmEdfZCurFS3Wl3iR3MGlNrJzktuHl/mCTP9D LNig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7+uJJsu7r1bUFsYmXKjWyci5NkWtJ9QfDE/bEKYNGi4=; fh=/GuWXIFJTb2Z3LVYajHwooJWphp6NrpriHhj5GHcik0=; b=FuH94LyyZhsn82NfAFIfsHaKioYQaG49I5CqtWnnoJjgIG/aNfi3pQaS3JS+5HFHca K4mLqKRNNUNa6L9vc+DVxXk8VOhA8yLHVwd3MeT5Y7kX+uFvlOs5IMWdO4fmDlkECkIV HPaAHT6j7brv8mmAhsr6bi2Ubp+TDWqMws7d1qjnHzo69hy8cw4IyupZrAW20VowaPwz tKC+1ybfTWGQmhe28n+aTkegdhDgXKy9WA1XCOvD/v6YA5aq7McFc2laKIWPZDqboCH5 5aK5153jXZSMSS1bkpiWe9VJ8wvOtpu7nAMUr1OgJ8i0fAu2k1HO5PuuWx59Ly1cj3oa Hkyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kOfX8EMg; spf=pass (google.com: domain of linux-kernel+bounces-549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r7-20020a05620a298700b0077f11e354efsi17707188qkp.415.2023.12.14.23.45.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 23:45:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kOfX8EMg; spf=pass (google.com: domain of linux-kernel+bounces-549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-549-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 DA08E1C21569 for ; Fri, 15 Dec 2023 07:45:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70EE52511F; Fri, 15 Dec 2023 07:41:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="kOfX8EMg" X-Original-To: linux-kernel@vger.kernel.org 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 848831BDDC; Fri, 15 Dec 2023 07:41:16 +0000 (UTC) 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=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BF4FYsi012570; Fri, 15 Dec 2023 07:40:53 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=7+uJJsu7r1bUFsYmXKjWyci5NkWtJ9QfDE/bEKYNGi4=; b=kO fX8EMggrnJZSdnX85aXLbmklAI1Ab2vT1OF1TKG4EkJN6/COQm9dIVUBFyACQNFt 0gelLMstqeggovyxJ0ThQPZP3JnNGUijBlObgumGMJIa9yJMYczZhhdyOwJeMeZJ WwDiopGtjzl3sR3dVUC+FGVQqyJ7cSe7WtOBCL2N4F8+XDGDKcLfV50MyucqSp13 fSRmeNt493ZUCEOi9aYeiF9cLRP2Z2qANo9yicLCZNnd+uvXsLvc/aTI8l5vrUmS bzRXYcrVLdS2k5sJ1hroFr91cnkLElqWfFRHKgnjG9Nx7bmi5HRBN8GroSwSCocW KqC1m/MZFo1AUaWH+69g== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v05jqhhcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 07:40:53 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BF7erYh002820 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 07:40:53 GMT Received: from akronite-sh-dev02.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 14 Dec 2023 23:40:48 -0800 From: Luo Jie To: , , , , , , , , , , , , CC: , , , Subject: [PATCH v8 06/14] net: phy: at803x: add qca8084_link_change_notify Date: Fri, 15 Dec 2023 15:39:56 +0800 Message-ID: <20231215074005.26976-7-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231215074005.26976-1-quic_luoj@quicinc.com> References: <20231215074005.26976-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: gqoNSi-LJIoA_ez-vGOEIq0HPfvfEzZ9 X-Proofpoint-GUID: gqoNSi-LJIoA_ez-vGOEIq0HPfvfEzZ9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312150047 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785333089060012698 X-GMAIL-MSGID: 1785333089060012698 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 | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 252fae4329cc..bb382089ab77 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"); @@ -2192,6 +2199,39 @@ static int qca8084_config_init(struct phy_device *phydev) 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 */ @@ -2388,6 +2428,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);