Message ID | 20231103123538.15735-1-quic_luoj@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp995689vqu; Fri, 3 Nov 2023 05:36:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsH//WBLw4DExzabX1Sldsp34vJs3SSzv/32B8WhQ5NeocX2aVYcIqYTNdlQg1dsKngj8Y X-Received: by 2002:a17:903:1104:b0:1c9:ea6e:5a63 with SMTP id n4-20020a170903110400b001c9ea6e5a63mr22233324plh.32.1699015007037; Fri, 03 Nov 2023 05:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699015007; cv=none; d=google.com; s=arc-20160816; b=Wv7A4FdUknzDNdN9Rtj68uhPBdpoU5F8IuDqdjt2sD3IG6ROlaxPbiznXt4p9bHE0P c5TKC2RIbNpXsqWCt1+Lu6H/5re1MDaZv3sywi/xZCdixo6roeKbhL4JxAX7cJuBRUq+ BDq9ZM669fPKKv5giT/6IU29PGMQk0UJasqF0g/hU6zuv43AFvKAvdf7aaJhPEfOkDfO dsic18YeouDb3PodOR6fXOiP/oayx40/IByffebNw6JjHMg+VKb73P/rMoZjHlPB4N16 iUUiN1sQqo4QaXkHSRFTj5LYLsawwO+xVhefF3WqGh1Wc+kt29p3Ax9R07o02H3P+sS5 nD6A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xXusRQbm4m28+UlBOW+vODwkm5i55zyiI+PcrVbxQZg=; fh=SRY8/p+PzzHTptcO7IUDl/XG/bg89PEmkgToMpWxWh0=; b=xAMchwEwfFURYTjCrjt0D+XkQ/MTf9O7Dh3Oi3JZRAiF+xuM6TR20ir85OcoibhU7F J7YSJIqxx7bus0j5ivjy6DlBJqt3MV59DCZdYr2OfYkZveiQ9YwEdx/6W1VG4ZTCdIq/ tn1TlkZcy2ggDvmvEA2dl4I6vVi/JYS6j+rWwpgiIKAAiD5qdTjPhsP+b2+tktsDbeyE GbZeArVgYr8d+VoqhahiGu5lf2G81+ZrEWiQWoLDi8epOit5/rr9qCJMQSsqGvh9CYg9 pXaUgrmzMmnM8XWjX776a1vV9DpOL5awltV9z3dtu0bbbP5tLi1LtqyJ9namIoGerNHo QJDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GHGUFl7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j15-20020a170902da8f00b001c88e81a54asi1468238plx.325.2023.11.03.05.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:36:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GHGUFl7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id CF28F81E5E56; Fri, 3 Nov 2023 05:36:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376706AbjKCMgW (ORCPT <rfc822;lhua1029@gmail.com> + 36 others); Fri, 3 Nov 2023 08:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376554AbjKCMgU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Nov 2023 08:36:20 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AE94D4F; Fri, 3 Nov 2023 05:36:14 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A3BP841009823; Fri, 3 Nov 2023 12:35:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=xXusRQbm4m28+UlBOW+vODwkm5i55zyiI+PcrVbxQZg=; b=GHGUFl7zHJMigAUKnF1oAjFDpFMWG4dfm3BG5G/3E/aKgbjzy+YOMbW0HHhFSJ6QWr4U vYIuOIJFOc7NqRPCZj45+2FreV/ALnKLrWeR4u1TGARGjwF+EemDBP6xw99UvrUz3NLc JC8xEx9t/n8MKejJ4nPWl18tRhQcrojzyI1jbmRFFHuTCy+OdqTw/Vyi/2Iz9yihmvPZ kRJJw87KmmOuf+d3ewyjD5wcsBxHfrh2T2wq8rK2wrMpPYppL4x2czt2VZaZ3VFve3ZM 0GeRdsq/9os0v5oV5j/nMNhILwh15lZc8IrgdbPAyA2MSQWitqfvPYcaKtPE957/yiro LA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u4cw9tejh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Nov 2023 12:35:54 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3A3CZr3K015831 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 3 Nov 2023 12:35:53 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; Fri, 3 Nov 2023 05:35:51 -0700 From: Luo Jie <quic_luoj@quicinc.com> To: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] net: phy: at803x: add QCA8084 ethernet phy support Date: Fri, 3 Nov 2023 20:35:37 +0800 Message-ID: <20231103123538.15735-1-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: ibQeycliF0kq73Jw_3m6JwQoSF2A8b9z X-Proofpoint-ORIG-GUID: ibQeycliF0kq73Jw_3m6JwQoSF2A8b9z 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-03_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311030106 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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 05:36:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781546360200394767 X-GMAIL-MSGID: 1781546360200394767 |
Series |
net: phy: at803x: add QCA8084 ethernet phy support
|
|
Commit Message
Jie Luo
Nov. 3, 2023, 12:35 p.m. UTC
Add qca8084 PHY support, which is four-port PHY with maximum
link capability 2.5G, the features of each port is almost same
as QCA8081 and slave seed config is not needed.
There are some initialization configurations needed.
1. Configuring qca8084 related initializations including
MSE detect threshold and ADC clock edge invert.
2. Add the additional configurations for the CDT feature.
Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
---
drivers/net/phy/at803x.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
Comments
> #define QCA8081_PHY_ID 0x004dd101 > +#define QCA8081_PHY_MASK 0xffffff00 That is an unusual mask. Please check it is correct. All you should need its PHY_ID_MATCH_EXACT, PHY_ID_MATCH_MODEL, PHY_ID_MATCH_VENDOR. > @@ -1767,6 +1781,20 @@ static int qca808x_config_init(struct phy_device *phydev) > { > int ret; > > + if (phydev->phy_id == QCA8084_PHY_ID) { > + /* Invert ADC clock edge */ > + ret = at803x_debug_reg_mask(phydev, QCA8084_ADC_CLK_SEL, > + QCA8084_ADC_CLK_SEL_ACLK, > + FIELD_PREP(QCA8084_ADC_CLK_SEL_ACLK, > + QCA8084_ADC_CLK_SEL_ACLK_FALL)); > + if (ret < 0) > + return ret; > + > + /* Adjust MSE threshold value to avoid link issue with some link partner */ > + return phy_write_mmd(phydev, MDIO_MMD_PMAPMD, > + QCA8084_MSE_THRESHOLD, QCA8084_MSE_THRESHOLD_2P5G_VAL); > + } > + Please add a qca8084_config_init() and use that from the phy_driver structure. > /* Active adc&vga on 802.3az for the link 1000M and 100M */ > ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, > QCA808X_8023AZ_AFE_CTRL_MASK, QCA808X_8023AZ_AFE_EN); > @@ -1958,6 +1986,11 @@ static int qca808x_cable_test_start(struct phy_device *phydev) > phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); > phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); > > + if (phydev->phy_id == QCA8084_PHY_ID) { > + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8075, 0xa060); > + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807f, 0x1eb0); > + } > + Please add a comment what this is doing. > }, { > /* Qualcomm QCA8081 */ > - PHY_ID_MATCH_EXACT(QCA8081_PHY_ID), > - .name = "Qualcomm QCA8081", > + .phy_id = QCA8081_PHY_ID, > + .phy_id_mask = QCA8081_PHY_MASK, > + .name = "Qualcomm QCA808X", Please add a new entry for the 8084. Andrew
On 11/3/2023 9:01 PM, Andrew Lunn wrote: >> #define QCA8081_PHY_ID 0x004dd101 >> +#define QCA8081_PHY_MASK 0xffffff00 > > That is an unusual mask. Please check it is correct. All you should > need its PHY_ID_MATCH_EXACT, PHY_ID_MATCH_MODEL, PHY_ID_MATCH_VENDOR. Thanks Andrew for the review. The PHY ID of qca8084 is correct, i will update to use PHY_ID_MATCH_EXACT in the new added entry for qca8084. > >> @@ -1767,6 +1781,20 @@ static int qca808x_config_init(struct phy_device *phydev) >> { >> int ret; >> >> + if (phydev->phy_id == QCA8084_PHY_ID) { >> + /* Invert ADC clock edge */ >> + ret = at803x_debug_reg_mask(phydev, QCA8084_ADC_CLK_SEL, >> + QCA8084_ADC_CLK_SEL_ACLK, >> + FIELD_PREP(QCA8084_ADC_CLK_SEL_ACLK, >> + QCA8084_ADC_CLK_SEL_ACLK_FALL)); >> + if (ret < 0) >> + return ret; >> + >> + /* Adjust MSE threshold value to avoid link issue with some link partner */ >> + return phy_write_mmd(phydev, MDIO_MMD_PMAPMD, >> + QCA8084_MSE_THRESHOLD, QCA8084_MSE_THRESHOLD_2P5G_VAL); >> + } >> + > > Please add a qca8084_config_init() and use that from the phy_driver > structure. OK. > >> /* Active adc&vga on 802.3az for the link 1000M and 100M */ >> ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, >> QCA808X_8023AZ_AFE_CTRL_MASK, QCA808X_8023AZ_AFE_EN); >> @@ -1958,6 +1986,11 @@ static int qca808x_cable_test_start(struct phy_device *phydev) >> phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); >> phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); >> >> + if (phydev->phy_id == QCA8084_PHY_ID) { >> + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8075, 0xa060); >> + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807f, 0x1eb0); >> + } >> + > > Please add a comment what this is doing. Ok, will add comments in the next patch. > >> }, { >> /* Qualcomm QCA8081 */ >> - PHY_ID_MATCH_EXACT(QCA8081_PHY_ID), >> - .name = "Qualcomm QCA8081", >> + .phy_id = QCA8081_PHY_ID, >> + .phy_id_mask = QCA8081_PHY_MASK, >> + .name = "Qualcomm QCA808X", > > Please add a new entry for the 8084. > > Andrew Will add it in the next patch, thanks.
On Sat, Nov 04, 2023 at 02:25:25PM +0800, Jie Luo wrote: > > > On 11/3/2023 9:01 PM, Andrew Lunn wrote: > > > #define QCA8081_PHY_ID 0x004dd101 > > > +#define QCA8081_PHY_MASK 0xffffff00 > > > > That is an unusual mask. Please check it is correct. All you should > > need its PHY_ID_MATCH_EXACT, PHY_ID_MATCH_MODEL, PHY_ID_MATCH_VENDOR. > > Thanks Andrew for the review. > The PHY ID of qca8084 is correct, i will update to use PHY_ID_MATCH_EXACT in > the new added entry for qca8084. Note, i asked about the mask, not the ID. Is PHY_ID_MATCH_EXACT maybe too exact? Is there the option for different revisions of the PHY? Can one entry in the table be used for multiple revisions? Andrew --- pw-bot: cr
On Fri, Nov 03, 2023 at 08:35:37PM +0800, Luo Jie wrote: > Add qca8084 PHY support, which is four-port PHY with maximum > link capability 2.5G, the features of each port is almost same > as QCA8081 and slave seed config is not needed. > > There are some initialization configurations needed. > 1. Configuring qca8084 related initializations including > MSE detect threshold and ADC clock edge invert. > 2. Add the additional configurations for the CDT feature. > > Signed-off-by: Luo Jie <quic_luoj@quicinc.com> > --- > drivers/net/phy/at803x.c | 40 +++++++++++++++++++++++++++++++++++++--- > 1 file changed, 37 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > index 37fb033e1c29..4124eb76d835 100644 > --- a/drivers/net/phy/at803x.c > +++ b/drivers/net/phy/at803x.c > @@ -176,6 +176,8 @@ > #define AT8030_PHY_ID_MASK 0xffffffef > > #define QCA8081_PHY_ID 0x004dd101 > +#define QCA8081_PHY_MASK 0xffffff00 > +#define QCA8084_PHY_ID 0x004dd180 ... > @@ -2207,8 +2240,9 @@ static struct phy_driver at803x_driver[] = { > .resume = qca83xx_resume, > }, { > /* Qualcomm QCA8081 */ > - PHY_ID_MATCH_EXACT(QCA8081_PHY_ID), > - .name = "Qualcomm QCA8081", > + .phy_id = QCA8081_PHY_ID, > + .phy_id_mask = QCA8081_PHY_MASK, > + .name = "Qualcomm QCA808X", ... > @@ -2241,7 +2275,7 @@ static struct mdio_device_id __maybe_unused atheros_tbl[] = { > { PHY_ID_MATCH_EXACT(QCA8327_A_PHY_ID) }, > { PHY_ID_MATCH_EXACT(QCA8327_B_PHY_ID) }, > { PHY_ID_MATCH_EXACT(QCA9561_PHY_ID) }, > - { PHY_ID_MATCH_EXACT(QCA8081_PHY_ID) }, > + { QCA8081_PHY_ID, QCA8081_PHY_MASK}, So, in summary from the above, what you're doing is using the pair of QCA8081_PHY_ID, QCA8081_PHY_MASK to match not only QCA8081 but also QCA8084. This is confusing. Are there any other parts that QCA808X would correspond with which would not be compatible with the above? E.g. QCA8082, QCA8083, QCA8088 etc. If there are, then the correct approach would be to list them separately in atheros_tbl, and also have separate driver entries in at803x_driver so it's unambiguous. If we keep this approach, then I would suggest: #define QCA808X_PHY_ID 0x004dd100 #define QCA808X_PHY_MASK GENMASK(31, 8) to make it explicit that this phy ID/mask pair is matching several devices, rather than re-using the QCA8081_PHY_ID definition. The next point - what about the revision field which occupies bits 3:0 in these: > static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) > { > + if (phydev->phy_id == QCA8084_PHY_ID) > + return false; > + ... > @@ -1767,6 +1781,20 @@ static int qca808x_config_init(struct phy_device *phydev) > { > int ret; > > + if (phydev->phy_id == QCA8084_PHY_ID) { > + /* Invert ADC clock edge */ ... > @@ -1958,6 +1986,11 @@ static int qca808x_cable_test_start(struct phy_device *phydev) > phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); > phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); > > + if (phydev->phy_id == QCA8084_PHY_ID) { Do these need to be exact matches, or should the revision field be ignored? If so, consider using phy_id_compare(), or if you end up with separate driver entries, consider using phydev_id_compare(). Thanks.
On 11/4/2023 10:19 PM, Andrew Lunn wrote: > On Sat, Nov 04, 2023 at 02:25:25PM +0800, Jie Luo wrote: >> >> >> On 11/3/2023 9:01 PM, Andrew Lunn wrote: >>>> #define QCA8081_PHY_ID 0x004dd101 >>>> +#define QCA8081_PHY_MASK 0xffffff00 >>> >>> That is an unusual mask. Please check it is correct. All you should >>> need its PHY_ID_MATCH_EXACT, PHY_ID_MATCH_MODEL, PHY_ID_MATCH_VENDOR. >> >> Thanks Andrew for the review. >> The PHY ID of qca8084 is correct, i will update to use PHY_ID_MATCH_EXACT in >> the new added entry for qca8084. > > Note, i asked about the mask, not the ID. Is PHY_ID_MATCH_EXACT maybe > too exact? Is there the option for different revisions of the PHY? Can > one entry in the table be used for multiple revisions? > > > Andrew > > --- > pw-bot: cr Sure, Andrew, qca8084 is the different model chip from qca8081, and there is only one PHY ID used currently for the qca8084(4-port) and qca8082(2-port), but we can use PHY_ID_MATCH_MODEL for new added entry of qca8084 and qca8082.
On 11/5/2023 3:35 AM, Russell King (Oracle) wrote: > On Fri, Nov 03, 2023 at 08:35:37PM +0800, Luo Jie wrote: >> Add qca8084 PHY support, which is four-port PHY with maximum >> link capability 2.5G, the features of each port is almost same >> as QCA8081 and slave seed config is not needed. >> >> There are some initialization configurations needed. >> 1. Configuring qca8084 related initializations including >> MSE detect threshold and ADC clock edge invert. >> 2. Add the additional configurations for the CDT feature. >> >> Signed-off-by: Luo Jie <quic_luoj@quicinc.com> >> --- >> drivers/net/phy/at803x.c | 40 +++++++++++++++++++++++++++++++++++++--- >> 1 file changed, 37 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c >> index 37fb033e1c29..4124eb76d835 100644 >> --- a/drivers/net/phy/at803x.c >> +++ b/drivers/net/phy/at803x.c >> @@ -176,6 +176,8 @@ >> #define AT8030_PHY_ID_MASK 0xffffffef >> >> #define QCA8081_PHY_ID 0x004dd101 >> +#define QCA8081_PHY_MASK 0xffffff00 >> +#define QCA8084_PHY_ID 0x004dd180 > ... >> @@ -2207,8 +2240,9 @@ static struct phy_driver at803x_driver[] = { >> .resume = qca83xx_resume, >> }, { >> /* Qualcomm QCA8081 */ >> - PHY_ID_MATCH_EXACT(QCA8081_PHY_ID), >> - .name = "Qualcomm QCA8081", >> + .phy_id = QCA8081_PHY_ID, >> + .phy_id_mask = QCA8081_PHY_MASK, >> + .name = "Qualcomm QCA808X", > ... >> @@ -2241,7 +2275,7 @@ static struct mdio_device_id __maybe_unused atheros_tbl[] = { >> { PHY_ID_MATCH_EXACT(QCA8327_A_PHY_ID) }, >> { PHY_ID_MATCH_EXACT(QCA8327_B_PHY_ID) }, >> { PHY_ID_MATCH_EXACT(QCA9561_PHY_ID) }, >> - { PHY_ID_MATCH_EXACT(QCA8081_PHY_ID) }, >> + { QCA8081_PHY_ID, QCA8081_PHY_MASK}, > > So, in summary from the above, what you're doing is using the pair of > QCA8081_PHY_ID, QCA8081_PHY_MASK to match not only QCA8081 but also > QCA8084. This is confusing. Yes, Russell. qca8084 is the different PHY model compared with the existed qca8081, qca8084 needs the extra PCS configuration and clock configuration, which will be pushed to the PCS driver. I will update to use PHY_ID_MATCH_MODEL for the new added entry of qca8084 to distinguish qca8081. > > Are there any other parts that QCA808X would correspond with which > would not be compatible with the above? E.g. QCA8082, QCA8083, QCA8088 > etc. The new added PHY chip qca8082, qca8084 and qca8085 use the same PHY ID, so the PHY_ID_MATCH_MODEL should be able to cover the new added entry. > > If there are, then the correct approach would be to list them > separately in atheros_tbl, and also have separate driver entries in > at803x_driver so it's unambiguous. > > If we keep this approach, then I would suggest: > > #define QCA808X_PHY_ID 0x004dd100 > #define QCA808X_PHY_MASK GENMASK(31, 8) > > to make it explicit that this phy ID/mask pair is matching several > devices, rather than re-using the QCA8081_PHY_ID definition. Thanks for the suggestion. the PHY_ID_MATCH_MODEL should match the new added PHY devices. > > > The next point - what about the revision field which occupies bits 3:0 > in these: bits[3:0] is for the revision number, currently there is only one PHY ID (revision number is 0)used for the new added series PHY chip. > >> static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) >> { >> + if (phydev->phy_id == QCA8084_PHY_ID) >> + return false; >> + > ... >> @@ -1767,6 +1781,20 @@ static int qca808x_config_init(struct phy_device *phydev) >> { >> int ret; >> >> + if (phydev->phy_id == QCA8084_PHY_ID) { >> + /* Invert ADC clock edge */ > ... >> @@ -1958,6 +1986,11 @@ static int qca808x_cable_test_start(struct phy_device *phydev) >> phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); >> phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); >> >> + if (phydev->phy_id == QCA8084_PHY_ID) { > > Do these need to be exact matches, or should the revision field be > ignored? If so, consider using phy_id_compare(), or if you end up with > separate driver entries, consider using phydev_id_compare(). > > Thanks. > Ok, i will double check this configuration to consider to use the suggested API in the next updated patch. Thanks Russell for the review.
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 37fb033e1c29..4124eb76d835 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -176,6 +176,8 @@ #define AT8030_PHY_ID_MASK 0xffffffef #define QCA8081_PHY_ID 0x004dd101 +#define QCA8081_PHY_MASK 0xffffff00 +#define QCA8084_PHY_ID 0x004dd180 #define QCA8327_A_PHY_ID 0x004dd033 #define QCA8327_B_PHY_ID 0x004dd034 @@ -279,6 +281,15 @@ #define QCA8081_PHY_SERDES_MMD1_FIFO_CTRL 0x9072 #define QCA8081_PHY_FIFO_RSTN BIT(11) +/* QCA8084 ADC clock edge */ +#define QCA8084_ADC_CLK_SEL 0x8b80 +#define QCA8084_ADC_CLK_SEL_ACLK GENMASK(7, 4) +#define QCA8084_ADC_CLK_SEL_ACLK_FALL 0xf +#define QCA8084_ADC_CLK_SEL_ACLK_RISE 0x0 + +#define QCA8084_MSE_THRESHOLD 0x800a +#define QCA8084_MSE_THRESHOLD_2P5G_VAL 0x51c6 + MODULE_DESCRIPTION("Qualcomm Atheros AR803x and QCA808X PHY driver"); MODULE_AUTHOR("Matus Ujhelyi"); MODULE_LICENSE("GPL"); @@ -1760,6 +1771,9 @@ static bool qca808x_is_prefer_master(struct phy_device *phydev) static bool qca808x_has_fast_retrain_or_slave_seed(struct phy_device *phydev) { + if (phydev->phy_id == QCA8084_PHY_ID) + return false; + return linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported); } @@ -1767,6 +1781,20 @@ static int qca808x_config_init(struct phy_device *phydev) { int ret; + if (phydev->phy_id == QCA8084_PHY_ID) { + /* Invert ADC clock edge */ + ret = at803x_debug_reg_mask(phydev, QCA8084_ADC_CLK_SEL, + QCA8084_ADC_CLK_SEL_ACLK, + FIELD_PREP(QCA8084_ADC_CLK_SEL_ACLK, + QCA8084_ADC_CLK_SEL_ACLK_FALL)); + if (ret < 0) + return ret; + + /* Adjust MSE threshold value to avoid link issue with some link partner */ + return phy_write_mmd(phydev, MDIO_MMD_PMAPMD, + QCA8084_MSE_THRESHOLD, QCA8084_MSE_THRESHOLD_2P5G_VAL); + } + /* Active adc&vga on 802.3az for the link 1000M and 100M */ ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7, QCA808X_8023AZ_AFE_CTRL_MASK, QCA808X_8023AZ_AFE_EN); @@ -1958,6 +1986,11 @@ static int qca808x_cable_test_start(struct phy_device *phydev) phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807a, 0xc060); phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807e, 0xb060); + if (phydev->phy_id == QCA8084_PHY_ID) { + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8075, 0xa060); + phy_write_mmd(phydev, MDIO_MMD_PCS, 0x807f, 0x1eb0); + } + return 0; } @@ -2207,8 +2240,9 @@ static struct phy_driver at803x_driver[] = { .resume = qca83xx_resume, }, { /* Qualcomm QCA8081 */ - PHY_ID_MATCH_EXACT(QCA8081_PHY_ID), - .name = "Qualcomm QCA8081", + .phy_id = QCA8081_PHY_ID, + .phy_id_mask = QCA8081_PHY_MASK, + .name = "Qualcomm QCA808X", .flags = PHY_POLL_CABLE_TEST, .probe = at803x_probe, .config_intr = at803x_config_intr, @@ -2241,7 +2275,7 @@ static struct mdio_device_id __maybe_unused atheros_tbl[] = { { PHY_ID_MATCH_EXACT(QCA8327_A_PHY_ID) }, { PHY_ID_MATCH_EXACT(QCA8327_B_PHY_ID) }, { PHY_ID_MATCH_EXACT(QCA9561_PHY_ID) }, - { PHY_ID_MATCH_EXACT(QCA8081_PHY_ID) }, + { QCA8081_PHY_ID, QCA8081_PHY_MASK}, { } };