Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5870215rdb; Thu, 14 Dec 2023 01:49:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuBdp2qLAooiQW+yzqr1naeDgJxIiw6fVfha6/WM+x/iYTib4G5RFCulGidxlpdTWIXxj6 X-Received: by 2002:a05:6a00:c91:b0:6ce:eee:b337 with SMTP id a17-20020a056a000c9100b006ce0eeeb337mr5069277pfv.0.1702547372118; Thu, 14 Dec 2023 01:49:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702547372; cv=none; d=google.com; s=arc-20160816; b=XY5EvtO4a9kf6k+36Ns8oxX16gIevXWVZqGxiymbLGUyAgzYGANr4Gg2cSEq+mp/y9 MUSHG2f7pRMOkkqOEwnxvGgcl2Xg9sJEXDJAbMI40G5ZyEo9/mUiN0rWAFVoj8ExHTOe eJGgowjPgKzHIdiMEETJzraymWWq3+aie/HVdrIi3qayZxIo0yRDmtuETKIiMZFRgF/V hv32MlXtnU0eQLoIFU9XndbA+gt8MzigBlSmrXDZglYJX/2s9CW7lEEkICpBQG/cn3zz gObOozv3Kmdwu5I8qdL+IQEVcQ4h4hvxaWLO9krGXRNeIj815nc7b2QbWVVG4BmuOwmV p0+g== 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=y0D0iHXYA2UwA5V/ss5IJKv+axl//qAJpDzVbQOftAs=; fh=/GuWXIFJTb2Z3LVYajHwooJWphp6NrpriHhj5GHcik0=; b=Z1tNLJH+hjwfQEzrnF1UhPBv7oPRoKotwb/KZoHTiLcqYY+CN49pbNweI3KqCLj2Mx vQbRCQPe+5BO1N7XrP4xA8JWKRXy/GFkLVYFWZlmRHfNawZt7oP2pBrFwLmcfXuSMfjo WjfsXjn7HJxgvbBCbyGIvEMFNID4Itw0bsh8VtKzpwmBlqQUgqVaXOMMkQZkRY1eZ/8D uUg8uLxFte3R0I2kO55g7mDmDTGTxof9cTnMMq1GM172ShMgb23JhPZbfqPgoz66ihVu oGtmEomWzCgrKjvKG8QAvlMX2JPUbjRPIf95eF9vzn/Y2n+O8hwcvNuC+b8b6BIHqCfO 9NrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lKQWqLP5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p41-20020a056a000a2900b006ce5bf560e1si10902415pfh.73.2023.12.14.01.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lKQWqLP5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id C8FAD8028A4A; Thu, 14 Dec 2023 01:49:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443556AbjLNJtP (ORCPT + 99 others); Thu, 14 Dec 2023 04:49:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443564AbjLNJtK (ORCPT ); Thu, 14 Dec 2023 04:49:10 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD0D0186; Thu, 14 Dec 2023 01:49:08 -0800 (PST) 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 3BE6F5uM020469; Thu, 14 Dec 2023 09:48:55 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=y0D0iHXYA2UwA5V/ss5IJKv+axl//qAJpDzVbQOftAs=; b=lK QWqLP5DkWjGLtg7TE6eN4Eqk3w5YjE559rz+3mOhnrhVUrAk+qIdYL49KtCPNtss H+/CtO/7lB54QsClBR+SpKWriZAbhbONAVwh+fkPxo12M2biixljcoRVBk3fW7Jq w/wW5IFB63H6IXLTzIXpuK1yDEBQ/zH7u3uFdS4T74k5Mspx1uTwsACNBKa9Lj4e wz/rRlK7ySl6wajTNAYXbJW0+BJIJkfzeMN+x6vjtQGZYy7RfssDZ0gA0/DKIiYA HhQDCAcGl3V2Ekw0CsIV+t2SP1dXwaiXXuve+motCBczXl+//FigH7JtL6jNVc1V rGQfdoENvQMLSMY0mUYA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uyqgt0x6v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 09:48:55 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BE9msk8016564 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 09:48:54 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 01:48:49 -0800 From: Luo Jie To: , , , , , , , , , , , , CC: , , , Subject: [PATCH v7 06/14] net: phy: at803x: add qca8084_link_change_notify Date: Thu, 14 Dec 2023 17:48:05 +0800 Message-ID: <20231214094813.24690-7-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214094813.24690-1-quic_luoj@quicinc.com> References: <20231214094813.24690-1-quic_luoj@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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-GUID: JS8OlbMNkJnE_wXl87Cfi-nGgSakcntL X-Proofpoint-ORIG-GUID: JS8OlbMNkJnE_wXl87Cfi-nGgSakcntL 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 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312140065 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Dec 2023 01:49:30 -0800 (PST) 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 ba5d069ad351..b6b41b1a4352 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"); @@ -2114,6 +2121,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 */ @@ -2311,6 +2351,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); -- 2.42.0