From patchwork Tue Jun 27 07:18:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294119 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 BD434BE5C for ; Tue, 27 Jun 2023 07:21:42 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D222120; Tue, 27 Jun 2023 00:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jNcywkGKTbNeArAxHyV1lrNJYKBbZdWDZ39Neax8JfSWg9El2/lNfulO4e3yZNg/4dFXCSzW/a6FF4dYgNdvauYQoSFCYMatmM/0YPKb0wQDrxSBo0Gc6P5JRcTtfRk8C9f3oPlpb3raro6wR0+xkT8NbH7Wd3ybh+Y+yJJewd0mVOwiCzb0482E2VjgkCBg2pczWmbCfPPUdfXWy3seDw934ELIVdosI1vFtROGou/EVhjVHHjzE3CAa47dNoYlEOgac0rhScHqGHJ+VazvhXPsY4/T68+HIYM5wbGbZU2DDPaCizBHrFSGrhwfprjiqBbV69BsPxCq3hNKhJwidw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LxMfKSZjw9iJJALUQPrHA+AaTIEfFkPKjuaWkV4v0zk=; b=ZYEEfzxyhn65XPwHx4KkW4w5wS222v8dC5rQ/LevWDPiJKA1yxsxHj1xKz9KUbyHd0fRjWrWcWl2J0WgKO8ti+WFiZgOwoQOwP3mnZwZfyg4JVw0m3kRwmHFIpZkTX6t3RZYsMj4bE6SVYqsKrmOL+zNIs7fR9pjLXwqqV4hXwKW0WJhCur5BmOzBjhJO9eXmaehGDQrTYbDqolGZehuLSFWanKHwOIBA0m3fGcQhSPEVUHzxXRLOJRkEZ01FFl/VMgK9MhpsdEQiAUkPUKWCOOmKSGPPXqrhNLTZG/YPaTmsylZS7nGqowndH++bcov3/WGHcdbtQ1MDPEkIL3FvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LxMfKSZjw9iJJALUQPrHA+AaTIEfFkPKjuaWkV4v0zk=; b=fOg9sS4pTEH55w41yfeUbqnhhFPCfh6s14Aaddt7nu7218zHgN4AN5vYdZdyXlUmbCWqpkyxlbz6wMMj7fiRS9+W6bnmIjRgO8huejFCvnit0OYnW7R5nParTLg1rPhacbSCpH0H9m+jA6gptkJfDiypOVYiKizs7uZxXnOpKIY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:53 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:53 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 01/12] net: phy: nxp-c45-tja11xx: use phylib master/slave implementation Date: Tue, 27 Jun 2023 10:18:42 +0300 Message-Id: <20230627071853.106215-2-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 2dcbf550-fa7e-43e4-9b56-08db76dee70c X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FqH4rdNBX4Y+szMXbipApF0VMRjekSniY8aMy2BqEJgUkJ2Dhoyb4GqdFVhnW+pwfYpj+TaLvRpLaV0S4UHvJAhIquqJmFsxrluXVBh6on+scoDlpzl04JCqWM2lbou4SXJW4EehlMkmdFPmO2w+WtbWFSBW4txcMC8Pu5rwxbwFAFkyncSRol3B/nbJgJrnSgPUJz0A7c3HtnFO+1k1f74MhHapRFMdf2SPE3gH+XzAaBx5J9vE34MQLVHioiSsPZQ4Rj1viNUeKkZPiST/mpxE9gp8UqQ5ceubstegA9Q4RubuD3yQvJ5c/qXf4Ax7x5svSdbcQluHzmH/MrrBYeynwnuYHGPX+5mF7p2cR8+Jx6/1p+BDcfI/PEBv1rlJ+dAoE8ZCAmR3gn5CJIUWAT/FonVG2S+xge/YXwAhVIoa5W9EcF/scHPtKT8DitQjca49VuaHCKDpDBBue+rfCtIxqaMVvDkpSQvf5CycCuFgiLWHzLvNSa1DoGd9SERcI3AGOyXi89W6CryqqWvpzEkc+Xp4+i9MaEKxLJmGcrObEldeQrcVafPIS7QW8UIiNr1XAFuQcrpTdkKdSm1lG4Pl/WNr5uZJqpMdkyeba+ttUiHcQ1W2yJMFTBdOTL01 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ap41qdAwv7Krqw3OfdnlH7OQm8UNROxfDhImildkL6pV+eBAZg+o0WKj9Ozm1LH/eYj4OEM+tDbMvyYtEjfjhEUzxyPmZDbSL3nnAGJkyXBIGIP2wBv+KiBbdc9WCvX+u1twPvg9e7epJjC0C0kV+7sJyJ+oxhtNllE7KkH4DqpwxlVB71KChjdBnJNF5C3MiMqtKkO4NMLGf5rrfVlYtyEW8y6r+M22BdqexZR2dTcHskgfCtSXXRde11fssWe5Kwi7/j16CL34DbpZ9Yqr1/U9MEsjKVDEQCUTmAi2AibhumhXLar5vXx5pvzwU9PxArNP6TFzHosXAEeprteQwnryebmC/EgUFe3wKJpoZyWXBJ27DZAhSbeWr5E6C3LOZ3mK6B65mZcAxw2FwWK+9H5X/fby5C2kcZc0WX43Mkn8YBrToEujyBFL1GD+qdhsQSt5aAcBuERSCjrrsiuNS71qZdpQlS50ow/T7XGyBSM2LUHpFKgXdxhXcquARcapfOmU3LeQWY0vFNLep/N6blnO2tUN2F+3lgtUvXu/1bbSlWbYcPqbPgeITs2LAri1JtzfoBnbIMKArPTB0BddrnGe8Vm2gOi1ja/aWRfquMRctL24gyGtbB2TNWZDfLgciTDJICoqCBngbLIhYpGTGRVDhwPh9nNMzPHh4Mfry/7cgCunesJxxg1TFJBDa10qzWJ0sn5Hh+Jx5SdEcc3kOn0DJCAFq26aX7CjuIqbwzlOSRJoJxzAasBixYk7XuD7QHr8n9nQ3yRw/qR14ku63nL5jv2wPWX54g1gjDXca4INtUpEufGTPOOIq4ZpW+G6kyHcUHNB3K2x6EMBsktflKV3iJAM++Qcj1301mbvK5+0b+xVaOgHRH+DEgcVXnQ1525dKUUKv+xsPq82q0hmV6eCOasQruftobqWHO4szC1K0Z97OsX3Xrx9zc4rLg/TgfZVjuuITtrRxtlOSSuC0LKPmRjUE0NwPe+C+Me8wpdZiv4knZuEcPU3cfGTIt9R4uyKjuvB/HurrxYyr6bnZ5C+5oQV0eu2u0xIhZuGN2aeEEALhdeRJc/QXZaPiXW4Bmcm1OLDzsvvBj/IK8GhFpCwkQ+B+pi+OEbFZnmLBCO7zDPsfJOPHJuTO74VgAiPBd8lEf8nE4Y5SdHl27wfKsUhhq0HPgmYDoYMQnkWn7k4vl/WfHAmATY/ir5QS0Vj29zAEApJfgyc8D1UMygq19uLipbji4S90f8oZm2bVYJuQzc3yXyZMo5JpS+tmlZuGom9/2KkFsGwf6y98mdO6aAJJq8V0JV4x10cqNGOMCfHI5K2hC6qx2UDnWVtKW4DcsQ5fWmHN2CbnRrnCgRphAI0LIUJN8W6By2Lg40evs1V1bSh1Ud0n67XgPlbauBuqjArzzb46GqwPqono3TdSqVeDW8OZ2RHpLQFI5u48iB1awZoy+uMLSArZvbPmbPBeDexZTrUmJ+tXAoJ+NiDXUFxXvydS+8Aew9j4YnFUWiSkWwO47JUgD62j/SzoJ6NDZWHyZzWAUB1POtH2u6/cAmeQN41F2nHnSXSUDv01n0X6AFdBVvSIhn3Hdz06kkq8T3xUkSeQruKE+sNjbqMPw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dcbf550-fa7e-43e4-9b56-08db76dee70c X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:53.5744 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Nh9qZcJ5j4uOYNuLLxT2xNEIQPRFkhKRVcFl5GtekiXI/sU4MPyJ2sSOhoRuVZGVSB5qMeZuTZclzvXXxf4hLhDQksiP5HkLT4jeYYnmMfg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 X-Patchwork-Delegate: kuba@kernel.org Remove the custom implementation of master/save setup and read status and use genphy_c45_config_aneg and genphy_c45_read_status since phylib has support for master/slave setup and master/slave status. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 77 +------------------------------ 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 029875a59ff8..41b8af0547e4 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -19,13 +19,6 @@ #define PHY_ID_TJA_1103 0x001BB010 -#define PMAPMD_B100T1_PMAPMD_CTL 0x0834 -#define B100T1_PMAPMD_CONFIG_EN BIT(15) -#define B100T1_PMAPMD_MASTER BIT(14) -#define MASTER_MODE (B100T1_PMAPMD_CONFIG_EN | \ - B100T1_PMAPMD_MASTER) -#define SLAVE_MODE (B100T1_PMAPMD_CONFIG_EN) - #define VEND1_DEVICE_CONTROL 0x0040 #define DEVICE_CONTROL_RESET BIT(15) #define DEVICE_CONTROL_CONFIG_GLOBAL_EN BIT(14) @@ -988,72 +981,6 @@ static int nxp_c45_cable_test_get_status(struct phy_device *phydev, return nxp_c45_start_op(phydev); } -static int nxp_c45_setup_master_slave(struct phy_device *phydev) -{ - switch (phydev->master_slave_set) { - case MASTER_SLAVE_CFG_MASTER_FORCE: - case MASTER_SLAVE_CFG_MASTER_PREFERRED: - phy_write_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_B100T1_PMAPMD_CTL, - MASTER_MODE); - break; - case MASTER_SLAVE_CFG_SLAVE_PREFERRED: - case MASTER_SLAVE_CFG_SLAVE_FORCE: - phy_write_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_B100T1_PMAPMD_CTL, - SLAVE_MODE); - break; - case MASTER_SLAVE_CFG_UNKNOWN: - case MASTER_SLAVE_CFG_UNSUPPORTED: - return 0; - default: - phydev_warn(phydev, "Unsupported Master/Slave mode\n"); - return -EOPNOTSUPP; - } - - return 0; -} - -static int nxp_c45_read_master_slave(struct phy_device *phydev) -{ - int reg; - - phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; - phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; - - reg = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_B100T1_PMAPMD_CTL); - if (reg < 0) - return reg; - - if (reg & B100T1_PMAPMD_MASTER) { - phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; - phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; - } else { - phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; - phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; - } - - return 0; -} - -static int nxp_c45_config_aneg(struct phy_device *phydev) -{ - return nxp_c45_setup_master_slave(phydev); -} - -static int nxp_c45_read_status(struct phy_device *phydev) -{ - int ret; - - ret = genphy_c45_read_status(phydev); - if (ret) - return ret; - - ret = nxp_c45_read_master_slave(phydev); - if (ret) - return ret; - - return 0; -} - static int nxp_c45_get_sqi(struct phy_device *phydev) { int reg; @@ -1355,11 +1282,11 @@ static struct phy_driver nxp_c45_driver[] = { .features = PHY_BASIC_T1_FEATURES, .probe = nxp_c45_probe, .soft_reset = nxp_c45_soft_reset, - .config_aneg = nxp_c45_config_aneg, + .config_aneg = genphy_c45_config_aneg, .config_init = nxp_c45_config_init, .config_intr = nxp_c45_config_intr, .handle_interrupt = nxp_c45_handle_interrupt, - .read_status = nxp_c45_read_status, + .read_status = genphy_c45_read_status, .suspend = genphy_c45_pma_suspend, .resume = genphy_c45_pma_resume, .get_sset_count = nxp_c45_get_sset_count, From patchwork Tue Jun 27 07:18:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294115 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 4D3C59445 for ; Tue, 27 Jun 2023 07:21:01 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6591FCA; Tue, 27 Jun 2023 00:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFEWlO+kIJa3a64pen21/gfqaiJ3j9tcuODpuLXPJCF8edzJBGIBExpyUc+up9L1sIg+HFiRv4XZ7A4RdUw2ihngVBJd77/fOBLQrBU6z4QCeikMHu6zisJOBt24/J4JP7KnivWCSmeRtpEPt1LEulK+MgxfeUwn6kSF2Q7RYYhYS1IucN1Tff629X+WqhIJPDBlSEXekjtYf16Up+JdzodGrHM3tkD/HlS2nVgK9suYCH/I6i0OPIhXNsI7mSBtX6emCTGHTp+Bs9pSNzevyUzTq92pyki8zND75hDKLhBCZa94r7m6RF1jgWoIfMTmPFpkaHpPTXA4gS9v1Zyu/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y2nOYKhmPkPTNbx2/4hfbCT/8vW8K+MCzBmhWG+ZCgc=; b=A/auajKMMqgFNwVziG0IcS6S6t0IFE18Ng1HOCf/fjkieVFCB5pAhyxpsv0OCjfAyWXRDL85/3wCc38hnOHgx4WgbmXIpsntJc4y/VhEZvrKEEtGF+4Y1vx3KsIdX2dgCni5DK85ciVDoclLzNDD85Ea3/I1ozGr58TD2yFo95/uAkYPv4GU00EHAD3zVD4KwKwVf7H61Iu7EsEFybeH90gBB+LtyNTHoLVhhBl4RWe2jzShdY2bk+1N26oELC+I5yrhQgpVIX3EB9WANxIsAhPLFRMiFyp0J+F+mt+SdXshiHdGBD6bfbFFBNMqP3IxQmT6H7XtBit39x2k/sfhcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y2nOYKhmPkPTNbx2/4hfbCT/8vW8K+MCzBmhWG+ZCgc=; b=bEBYmoqY9zzDQGYhyh17pQ/qdiaxd4hlSIVN0sZGjQ0Ic7VOxA1IhhQSRIXehTlOn0D7VCvAdrzrinsarfXtRkF0ZIhEgqQjZFA6kgCU3cVGMXuEfcO14eVpPhKXiey0sO1Vs9G95bLzxJiFIChuG1epYaHAIxtCIIurAk8RCFA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:55 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:55 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 02/12] net: phy: nxp-c45-tja11xx: remove RX BIST frame counters Date: Tue, 27 Jun 2023 10:18:43 +0300 Message-Id: <20230627071853.106215-3-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 137049e2-7494-4b74-c29b-08db76dee7e0 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: trvdfTYvac66ML3+BRZWIWU1y0Np4654u4T5fJ55u/AtmM2shqCHjlHHbDRQHR3GyvFMuuSzzwgUTR0L6enyat4yE1lBt1ahVcZR8kn8VvfEfdt45autHayVcdbWmZjQMCp1Rb60MbrI4LEAMoA9jkS7zdaIePz1tM70xCaG+Ao7z6h5utAIJ3PE9j/3WNzFSJxsxNhn1SdMlbbsyruXqkG3WwlNdh990vOsZVvt7102tUdqM/RFX9FnU6E7EMmXpDM20gyk8j9Mm2j+u/3fCWUwSUYE6yG3Bo4EVlPO2Ihc1QiWaqI7jHm+3IZVHxQjJyRoN2OCFkNsNCEy5VsAM1u0Oiq+asHsMWAQ0R+TYwCUq4PATmgiaCz6VKZrFplPG3kLOmmdBHmFkEBqU7B4MiwDpCUPe/LZxlIqmaj0ydRwUeoJZX4H9hGvJB1jiuf65NK7ihwnsjRnXD2oTiu6QxPQf8vLTpuL73YUT3u+B/dip7jskBlj/dv4IWCwKwdxrqKdEVn7dO3qsl009g1sE+mHe3AiycQZ/QHJru3fMhuMun/ufvgY7y3i/Ql0EndFfYsTcBL5OOTZbtQIBroaTy43xlZ9z9j83bduNgHHSoMcxQeIvBB3INip4g13sh9S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X6y1a4UMR3HFkke5n4/KBjW3DqmjdU9Zc9x44DH56o06lxxWh2XOg/Ng22dN5gyoybNY7oYyZo9P7qnY8eisHkdohlunAZWu2bnY6YkxZs0P0bZWpIfQpLlUASKPQRUaSYL8MeqORICLkQYFHJzzLf88gepYkACEs8AnbuoT1HWaltu74DMwoYGuP9RJl1Y3P4VQ5NfFy9mubITD7bZmXIFD2bq+AeYZ+wu95CQPEA9dVvEX8RXr8K+vqfhxp301fMK7Kt/b53EdHjR+IalZsmWWb6/h45ebWwEL3oPt9TWLoOZeroQszL1RyKblOW7IFv3Y7FGTwTFi5Cl1KTSZYrFs1tpyTrCMnbHCa+o/22KMJxWvLbWRexmwVa8n0RS0N3uriIm9wn1IBwz3IsFjjPzKlGCggf8JFHleygG0TDnbJs5edJ8cRbA+baQF+0jDGvbO4j0NZcKS+l4jrcay8hO2F+pNdjryJM/bXMBAyADfAdW3KKhZyJJVNhK9YGuUnuyd0OcwC7J0G5Bz3LfW/M6Y5I2k/3AcAqWgFLzjPRTC5/S5P6PJaHXDLSI+oqkXh+RMHrw1h8eVfbXeMCSFmlRwtw4HF7hujFfMC8oMsNrJKV+AmWAVQna87U5nM6mWfLVF94R524JR2lpOtFJ6P14pNQ+273FjRvFR/O4fJzeCwtWon38sU/+lVyObVNb4pH4mZZXW9Fz3QNXwSTf4wbFvS6uzrSe5mZJh3uOfWyf5qk0rpEjXmyLRaBHYOTIoJYXAU95frZwhSdN2Ojkymk7rK9MlM4JjVPw+RyeyoUud/rsBfGkZ7zlbGchY9ojQjntWf5siLDWxabPOQJBF7cjyDW3DFJW7vQyvY4MghaibbDcKWECMZ1bQYl24hlU19o8Y1/fW491dfsg+qlvfko3T4sgIf9Phf9kr1l7m71/DTxxWlPgeOIfldJ/4qROeNaOM29TYmuo0KM1SySZ5R6IUT3J8irTGJlmORUZcNHIxCrDTiJyG/Bw9L3/6VCTvCZOAPM/wNt46jKph4Z3IWhz+tOKqyDh9Ev47GYwAegMMzKI8jY8h4XrubDC/hYSLznUkay3o+mkLdfQjpO5LmgtK6nuKCrvEHTTYHX0JnEKcRnKb8S5zm36L6chSZ2fYNX/uu0/VMA/kXu6B2w4DPtVlittKKh9JsvdrQDYQckd1Ao6VYpJW4tapzOiCcXqqvWu40Y6Pt4smLJHVMz9Fbm0KfS2lhWR59jQMKwzrE1SVvprPUAO9bahvRr1rbrxPmbOOG9dcF74JJrGhMWZLtHeUgQ/E8UppSJR6Hy0ts7udb06YPDMSFN/cadw3VMEwIGLw+D7tq6TlweY+Ko8Js6/Hp+waQUNj3mBWqKRd0Z/WFNH2fykYkvq8hcvWlsJJd5TFdzfGIlBx3HSNecenl3fgEtT2I4ov7XlhxgXKbNQdH6igTjdjTsjOLkM//iyStkFH7Ay51V7sVOyJX8/GqF9Rhr7V4dizZD+xGT8TN3Fc89YLvGi5RxPIw7TgDXNG3vYJhx6ioWgl/MlcHlq9wfYLHvbzFvG5oXh9P7X4koJNihrZGIVq2IoNz3VZapP43OzAqFsjZZZcQct72yRsHQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 137049e2-7494-4b74-c29b-08db76dee7e0 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:54.9688 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IgwuR1E1TnfG7L5MaUcVPyBFsaBRuZPLaEtW3r1slLkOg4tQwQILVLuIZohCAuH/PJSscWMZ2y/Gf78GfZ6+EQrMII51ZxP6LAEoYt9Tils= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Remove RX BIST frame counters from the PHY statistics. In production mode, these counters are always read as 0. Signed-off-by: Radu Pirea (NXP OSS) --- drivers/net/phy/nxp-c45-tja11xx.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 41b8af0547e4..f1f15a1b6cfc 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -81,9 +81,6 @@ #define VEND1_SYMBOL_ERROR_COUNTER 0x8350 #define VEND1_LINK_DROP_COUNTER 0x8352 #define VEND1_LINK_LOSSES_AND_FAILURES 0x8353 -#define VEND1_R_GOOD_FRAME_CNT 0xA950 -#define VEND1_R_BAD_FRAME_CNT 0xA952 -#define VEND1_R_RXER_FRAME_CNT 0xA954 #define VEND1_RX_PREAMBLE_COUNT 0xAFCE #define VEND1_TX_PREAMBLE_COUNT 0xAFCF #define VEND1_RX_IPG_LENGTH 0xAFD0 @@ -809,12 +806,6 @@ static const struct nxp_c45_phy_stats nxp_c45_hw_stats[] = { VEND1_LINK_LOSSES_AND_FAILURES, 10, GENMASK(15, 10) }, { "phy_link_failure_cnt", MDIO_MMD_VEND1, VEND1_LINK_LOSSES_AND_FAILURES, 0, GENMASK(9, 0) }, - { "r_good_frame_cnt", MDIO_MMD_VEND1, - VEND1_R_GOOD_FRAME_CNT, 0, GENMASK(15, 0) }, - { "r_bad_frame_cnt", MDIO_MMD_VEND1, - VEND1_R_BAD_FRAME_CNT, 0, GENMASK(15, 0) }, - { "r_rxer_frame_cnt", MDIO_MMD_VEND1, - VEND1_R_RXER_FRAME_CNT, 0, GENMASK(15, 0) }, { "rx_preamble_count", MDIO_MMD_VEND1, VEND1_RX_PREAMBLE_COUNT, 0, GENMASK(5, 0) }, { "tx_preamble_count", MDIO_MMD_VEND1, From patchwork Tue Jun 27 07:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294118 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 6B7EFBA48 for ; Tue, 27 Jun 2023 07:21:37 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E712D68; Tue, 27 Jun 2023 00:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlRmUT6WppfN2YgDf8q5qTWXAT5r6tBNeZ2nPCEi4cZHksZoyf9pLlFxpg80JbhPxfA5+seZmaaKvr7Hh91dj7LrhJtQME/6hVFoijOOf2dLHyauY63kYc34Mr4r3lF98XrEcXHXshrod6bG8rluRMOXe9J8rAGqniJumXLTFdwKtV0wM1UHBGtdpXHw68FDES9R/ZtcK6FQyqnxHjufyy6Uugwmx1ZZBZOv/KJQU7kj8geKn7ecHCyDMcNks+XtsXgF79Pi8QP3kXEtu1Z1zGHNk9WpmV+FkMedd7mZ2RT6xCm0SeKx979erhQ40AJwEr7DUm8cg86NneUeqasAHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G1lPWSoUj+4n93p9hQ5/F/hpSG8PekLDoa5JhYpOPEk=; b=kP/2EIiHQNQe57BcLBcMhDJRpDl+Irzj53boshPtQhkYyzlGrzeClj19fKnSpx9HEgnQLh0pvvgWy6X4VcYH+fzxpTRjtR2aTOtpIx4egxonT7etnXVm76mC5KLiceptllx62+6Fj/4SGarj/8/vwNf9HfAXAkrjezJr/3F7A4LsAZkLsCGRSXGqCPEIR7zfJtjvvmEp+yFL+QEQorK3WaXoiXBxZ1Asw+DgpOnrWILMTDOkirlAPZ5FDTJFjDG/2Lceu3Yh6EaneF9fD9n9Bxx/pGTL4Nyf/hkRwfKNphSmVw7706p0NZKLyBWz78MzDuCTrTHYo02BZCWDQs4Xvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G1lPWSoUj+4n93p9hQ5/F/hpSG8PekLDoa5JhYpOPEk=; b=BUNqF7z9CTn4HGB0bGUoEMxpDrIQs4+pHOR/9fZ05AfShatGEIOwVFcFGjnn6e/bWOIX25lbeRaFLa7keHMEj3F3ykoz4pDieavd6owXnn6HY0ZwjytUPchEnw3UjAXHlQrmRg7u4pNavuKjyXaFlyIfSsp9rc9/6eruFL6RdBM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:56 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:56 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 03/12] net: phy: nxp-c45-tja11xx: prepare the ground for TJA1120 Date: Tue, 27 Jun 2023 10:18:44 +0300 Message-Id: <20230627071853.106215-4-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: a81d93db-4da1-4a53-efb1-08db76dee876 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eIlaKAfrgqz73dV0MxFbJYLxiXkBvky8dwiq9xIJR8dkn86l3/cm1s/atul3Bkh4Wg4hILA+GB1kdvn7Nlz6L7/tisuxrTkRV+J5xdQhIc8nG1mik21UtyYpRBYLriDG+NpJ1DUE057x92zY/DSAG7s95LhPkfNGwdFkuk2G6CgJQMkbn09u1V8UoVCP9L4p6EoobH5kTA01Vm6y93yI+5OxLwuLSMSH0VWK1vBsVq0JshMqhBUjTW0o9Fj16zC2i+9ZIRAMpOih2L5PG7a3ks9QCFD4B7CQTewiisp6AEfz8UIuToNPK3obnsu8g0o2B+uQef07cA+W74WzLCkTcx90paOSZ/gs2G6ZyRzEoTUPNsKZxMy/7HyOsR2IaLTBZDTtQBR/eZODO8uRD5ltxFytNXs6cmfTTxJiizAcaMjfQXnHKWbUKxk7ELE5lQTJJA1pdoGuGF24OK372/buvt4Au8SKYxi6zJweH6zSdQiJ0FyHUc2GWV+3qbUTFH/3NRB5goMOlReA94hchpFsO06WdZ15YYcJxbwK7jU9UiarFMHqwEay5dpM8IsibQ4V6GC027okoW6StYIxbmKirwUIJLOejjqjj/jFt7Eczz/CZJZV8xxfeuTHSeliASm5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(30864003)(38100700002)(8676002)(66574015)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JIJm0zuTOnLP7lX7Ibl7BMe9CHeDldDnKTIlI8kTQW83WCHek3Qp7QoeUrKiSh2hfUTC7QXeu6hh9x5IB5vk6G4fdGRCME6kcD8IOx341MumRPkBfJM4pLJ1nz8gQnW7I5pSMipmwPQDUEPYqmg2/abcGbdAbobDqo4nOHzoHNQR7n7XXVD3PgZLDFkyXE5Q4OsCJhKI+c+VuNFy22FAbtmOGlPVqhkQEJkkIdnEUx/DjFXQRoBF3y4OIB/uFny3VViZZyn719mng38FKZFc2Dvfmte1P0xkPDFSuqP/IxnzFF7CbuWADCWoKOBn6KMZQ21TN10yjZERhAbxJEpKJu1dxw7P4Y+8KUSUGMVW1djwXNw33PkMHq2XQaXp9GCW7q9Tzo4vq5H0tPKMvVRWQY6UTpCOprq+0lAkWrKNW7xIVWPnn2XghbDhKhFMphx3ws/QTkEJ193Glg7+yF/SjGlZJJb/h/c38P/feSSRqmh8swvb2CRqxqgEhJMkC6z+tzz4nspnt+BVtLk8L7vijSWfa4p9y430NaaWh6P9IR2EGXa+K6b0DmAhEQCwKqqbRfsPTxBXH1hzoQ8NAYkJz1ZSoJDnIFVH7CK6VaWd+4fXbrlU/44I19Pvv4FMhG3NZzA8WDNNj9r3iS36ix2+u8Jl6zb130a+/UaYljPp2Ak7do+icHUbEbbr21M4Lx9v9DOD7pAlhOzD/zpM/CtlRPq/5Wocut3UCkLFnKPlXCJLdx1PcuPjjv/OMT/IzmBKs9CLoGInmyuAmcq7Q12MbZTVkYLMjyLtF79K4uurUOuhueUdkzmFQd3KvAVklTP4wKuTSgk7JA5mR0P1hlT5itzmfYt70kpXCygoawhHxJD2Vbn0/+QVuRX/U13s2gSuzdh/WLHzDrW1gF6hqBDIvWxR+CNRw09kJpkocp2Dw3OAEbeflWcyT4h0QRuyNsDvC7gJseh7CJLSlw6xpa0vF1MZI7pxrZJ6uRNyjqGNG5VtqicVTlRRzsHSyKZqImIbHue1Xst/DyRDAWTTTExAiLYn5CuGnsssv25i6RugTFv9+NLzf4FwJzA2pm1e2HsqzRLyZtRej74vPnuV+86xX35/Sgsx/uTtKIbPLoTr6/ZTcuh7y5O8zVH1sKxPv5hNQTuGp+/3uyW0ezfJyVUPtPmq+T7IbTmg8svf99qS+hVuNnaPk7oz4lTcK5sd3gv0f2s4R59YRpWqdPpnT89loWMw+s3aOXL34zp/WL6qWOpyGFvNnM6urUGpz1UPoGxpK/kT1ogeZ0Ug8Uj+peyHtbsLVC5cBnU5FBpCp7ahTl2qbeirt0im8/qaOKLMXJZBcLAFmvxDCWkl5u3ipJ1NVPva37bggO5+OiPvpxhdxfwRqMGNjWdntGs+uAbHN2V2M/FKNdvoHxBDLej+mrnes4QnuSkHj3dpflVwoADiKw+8HK1VBuVWYhtbk6D/o8sH0HSb9nXmXvpr9rBibJMdv4YJhu88SNXXF3q4KVbRLXVQiLJZgJwyyuSr1p9tOwHPfV8cXZ6J7ag0ibPjWyjGbFZl44Hsq8DTrzAokhfX6x/00YI8/32FOejMX0JlFfw0P2bnoLCZmMZg12A3JsOCyA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a81d93db-4da1-4a53-efb1-08db76dee876 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:55.9840 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qwznK6/JJLCLIwFuWBwcARQO1T+JQG5rLxah92UEBXrX+vKt9yMg+QqW7YwtKTRsPsZawEfhR7He5nG2qOipvPugyU7E5zAtCpsQJ2MRXKo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Between TJA1120 and TJA1103 the hardware was improved, but some register addresses were changed and some bit fields were moved from one register to another. Introduce the nxp_c45_reg_field structure and its associated functions to abstract the differences between the PHYs. Remove the defined bits and register addresses that are not common between TJA1103 and TJA1120 and replace them with reg_fields and register addresses from phydev->drv->driver_data. Signed-off-by: Radu Pirea (NXP OSS) --- drivers/net/phy/nxp-c45-tja11xx.c | 572 +++++++++++++++++++++--------- 1 file changed, 405 insertions(+), 167 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index f1f15a1b6cfc..162886cce08b 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -41,10 +41,8 @@ #define SQI_MASK GENMASK(2, 0) #define MAX_SQI SQI_MASK -#define VEND1_CABLE_TEST 0x8330 #define CABLE_TEST_ENABLE BIT(15) #define CABLE_TEST_START BIT(14) -#define CABLE_TEST_VALID BIT(13) #define CABLE_TEST_OK 0x00 #define CABLE_TEST_SHORTED 0x01 #define CABLE_TEST_OPEN 0x02 @@ -89,59 +87,18 @@ #define VEND1_PTP_CONFIG 0x1102 #define EXT_TRG_EDGE BIT(1) -#define PPS_OUT_POL BIT(2) -#define PPS_OUT_EN BIT(3) -#define VEND1_LTC_LOAD_CTRL 0x1105 -#define READ_LTC BIT(2) -#define LOAD_LTC BIT(0) - -#define VEND1_LTC_WR_NSEC_0 0x1106 -#define VEND1_LTC_WR_NSEC_1 0x1107 -#define VEND1_LTC_WR_SEC_0 0x1108 -#define VEND1_LTC_WR_SEC_1 0x1109 - -#define VEND1_LTC_RD_NSEC_0 0x110A -#define VEND1_LTC_RD_NSEC_1 0x110B -#define VEND1_LTC_RD_SEC_0 0x110C -#define VEND1_LTC_RD_SEC_1 0x110D - -#define VEND1_RATE_ADJ_SUBNS_0 0x110F -#define VEND1_RATE_ADJ_SUBNS_1 0x1110 #define CLK_RATE_ADJ_LD BIT(15) #define CLK_RATE_ADJ_DIR BIT(14) -#define VEND1_HW_LTC_LOCK_CTRL 0x1115 -#define HW_LTC_LOCK_EN BIT(0) - -#define VEND1_PTP_IRQ_EN 0x1131 -#define VEND1_PTP_IRQ_STATUS 0x1132 -#define PTP_IRQ_EGR_TS BIT(0) - #define VEND1_RX_TS_INSRT_CTRL 0x114D -#define RX_TS_INSRT_MODE2 0x02 +#define TJA1103_RX_TS_INSRT_MODE2 0x02 #define VEND1_EGR_RING_DATA_0 0x114E -#define VEND1_EGR_RING_DATA_1_SEQ_ID 0x114F -#define VEND1_EGR_RING_DATA_2_NSEC_15_0 0x1150 -#define VEND1_EGR_RING_DATA_3 0x1151 #define VEND1_EGR_RING_CTRL 0x1154 -#define VEND1_EXT_TRG_TS_DATA_0 0x1121 -#define VEND1_EXT_TRG_TS_DATA_1 0x1122 -#define VEND1_EXT_TRG_TS_DATA_2 0x1123 -#define VEND1_EXT_TRG_TS_DATA_3 0x1124 -#define VEND1_EXT_TRG_TS_DATA_4 0x1125 -#define VEND1_EXT_TRG_TS_CTRL 0x1126 - -#define RING_DATA_0_DOMAIN_NUMBER GENMASK(7, 0) -#define RING_DATA_0_MSG_TYPE GENMASK(11, 8) -#define RING_DATA_0_SEC_4_2 GENMASK(14, 2) #define RING_DATA_0_TS_VALID BIT(15) -#define RING_DATA_3_NSEC_29_16 GENMASK(13, 0) -#define RING_DATA_3_SEC_1_0 GENMASK(15, 14) -#define RING_DATA_5_SEC_16_5 GENMASK(15, 4) #define RING_DONE BIT(0) #define TS_SEC_MASK GENMASK(1, 0) @@ -152,18 +109,11 @@ #define VEND1_PORT_PTP_CONTROL 0x9000 #define PORT_PTP_CONTROL_BYPASS BIT(11) -#define VEND1_PTP_CLK_PERIOD 0x1104 #define PTP_CLK_PERIOD_100BT1 15ULL -#define VEND1_EVENT_MSG_FILT 0x1148 #define EVENT_MSG_FILT_ALL 0x0F #define EVENT_MSG_FILT_NONE 0x00 -#define VEND1_TX_PIPE_DLY_NS 0x1149 -#define VEND1_TX_PIPEDLY_SUBNS 0x114A -#define VEND1_RX_PIPE_DLY_NS 0x114B -#define VEND1_RX_PIPEDLY_SUBNS 0x114C - #define VEND1_GPIO_FUNC_CONFIG_BASE 0x2C40 #define GPIO_FUNC_EN BIT(15) #define GPIO_FUNC_PTP BIT(6) @@ -181,8 +131,8 @@ #define MAX_ID_PS 2260U #define DEFAULT_ID_PS 2000U -#define PPM_TO_SUBNS_INC(ppb) div_u64(GENMASK_ULL(31, 0) * (ppb) * \ - PTP_CLK_PERIOD_100BT1, NSEC_PER_SEC) +#define PPM_TO_SUBNS_INC(ppb, ptp_clk_period) div_u64(GENMASK_ULL(31, 0) * \ + (ppb) * (ptp_clk_period), NSEC_PER_SEC) #define NXP_C45_SKB_CB(skb) ((struct nxp_c45_skb_cb *)(skb)->cb) @@ -191,6 +141,21 @@ struct nxp_c45_skb_cb { unsigned int type; }; +#define NXP_C45_REG_FIELD(_reg, _devad, _offset, _size) \ + ((struct nxp_c45_reg_field) { \ + .reg = _reg, \ + .devad = _devad, \ + .offset = _offset, \ + .size = _size, \ + }) + +struct nxp_c45_reg_field { + u16 reg; + u8 devad; + u8 offset; + u8 size; +}; + struct nxp_c45_hwts { u32 nsec; u32 sec; @@ -199,7 +164,69 @@ struct nxp_c45_hwts { u8 msg_type; }; +struct nxp_c45_regmap { + /* PTP config regs. */ + u16 vend1_ptp_clk_period; + u16 vend1_event_msg_filt; + + /* LTC bits and regs. */ + struct nxp_c45_reg_field ltc_read; + struct nxp_c45_reg_field ltc_write; + struct nxp_c45_reg_field ltc_lock_ctrl; + u16 vend1_ltc_wr_nsec_0; + u16 vend1_ltc_wr_nsec_1; + u16 vend1_ltc_wr_sec_0; + u16 vend1_ltc_wr_sec_1; + u16 vend1_ltc_rd_nsec_0; + u16 vend1_ltc_rd_nsec_1; + u16 vend1_ltc_rd_sec_0; + u16 vend1_ltc_rd_sec_1; + u16 vend1_rate_adj_subns_0; + u16 vend1_rate_adj_subns_1; + + /* External trigger reg fields. */ + struct nxp_c45_reg_field irq_egr_ts_en; + struct nxp_c45_reg_field irq_egr_ts_status; + struct nxp_c45_reg_field domain_number; + struct nxp_c45_reg_field msg_type; + struct nxp_c45_reg_field sequence_id; + struct nxp_c45_reg_field sec_1_0; + struct nxp_c45_reg_field sec_4_2; + struct nxp_c45_reg_field nsec_15_0; + struct nxp_c45_reg_field nsec_29_16; + + /* PPS and EXT Trigger bits and regs. */ + struct nxp_c45_reg_field pps_enable; + struct nxp_c45_reg_field pps_polarity; + u16 vend1_ext_trg_data_0; + u16 vend1_ext_trg_data_1; + u16 vend1_ext_trg_data_2; + u16 vend1_ext_trg_data_3; + u16 vend1_ext_trg_ctrl; + + /* Cable test reg fields. */ + u16 cable_test; + struct nxp_c45_reg_field cable_test_valid; + struct nxp_c45_reg_field cable_test_result; +}; + +struct nxp_c45_phy_stats { + const char *name; + const struct nxp_c45_reg_field counter; +}; + +struct nxp_c45_phy_data { + const struct nxp_c45_regmap *regmap; + const struct nxp_c45_phy_stats *stats; + int n_stats; + u8 ptp_clk_period; + void (*counters_enable)(struct phy_device *phydev); + void (*ptp_init)(struct phy_device *phydev); + void (*ptp_enable)(struct phy_device *phydev, bool enable); +}; + struct nxp_c45_phy { + const struct nxp_c45_phy_data *phy_data; struct phy_device *phydev; struct mii_timestamper mii_ts; struct ptp_clock *ptp_clock; @@ -217,13 +244,86 @@ struct nxp_c45_phy { bool extts; }; -struct nxp_c45_phy_stats { - const char *name; - u8 mmd; - u16 reg; - u8 off; - u16 mask; -}; +static const +struct nxp_c45_phy_data *nxp_c45_get_data(struct phy_device *phydev) +{ + return phydev->drv->driver_data; +} + +static const +struct nxp_c45_regmap *nxp_c45_get_regmap(struct phy_device *phydev) +{ + const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev); + + return phy_data->regmap; +} + +static int nxp_c45_read_reg_field(struct phy_device *phydev, + const struct nxp_c45_reg_field *reg_field) +{ + u16 mask; + int ret; + + if (reg_field->size == 0) { + phydev_err(phydev, "Trying to read a reg field of size 0.\n"); + return -EINVAL; + } + + ret = phy_read_mmd(phydev, reg_field->devad, reg_field->reg); + if (ret < 0) + return ret; + + mask = reg_field->size == 1 ? BIT(reg_field->offset) : + GENMASK(reg_field->offset + reg_field->size - 1, + reg_field->offset); + ret &= mask; + ret >>= reg_field->offset; + + return ret; +} + +static int nxp_c45_write_reg_field(struct phy_device *phydev, + const struct nxp_c45_reg_field *reg_field, + u16 val) +{ + u16 mask; + u16 set; + + if (reg_field->size == 0) { + phydev_err(phydev, "Trying to write a reg field of size 0.\n"); + return -EINVAL; + } + + mask = reg_field->size == 1 ? BIT(reg_field->offset) : + GENMASK(reg_field->offset + reg_field->size - 1, + reg_field->offset); + set = val << reg_field->offset; + + return phy_modify_mmd_changed(phydev, reg_field->devad, + reg_field->reg, mask, set); +} + +static int nxp_c45_set_reg_field(struct phy_device *phydev, + const struct nxp_c45_reg_field *reg_field) +{ + if (reg_field->size != 1) { + phydev_err(phydev, "Trying to set a reg field of size different than 1.\n"); + return -EINVAL; + } + + return nxp_c45_write_reg_field(phydev, reg_field, 1); +} + +static int nxp_c45_clear_reg_field(struct phy_device *phydev, + const struct nxp_c45_reg_field *reg_field) +{ + if (reg_field->size != 1) { + phydev_err(phydev, "Trying to set a reg field of size different than 1.\n"); + return -EINVAL; + } + + return nxp_c45_write_reg_field(phydev, reg_field, 0); +} static bool nxp_c45_poll_txts(struct phy_device *phydev) { @@ -235,17 +335,17 @@ static int _nxp_c45_ptp_gettimex64(struct ptp_clock_info *ptp, struct ptp_system_timestamp *sts) { struct nxp_c45_phy *priv = container_of(ptp, struct nxp_c45_phy, caps); + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_LOAD_CTRL, - READ_LTC); + nxp_c45_set_reg_field(priv->phydev, ®map->ltc_read); ts->tv_nsec = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_LTC_RD_NSEC_0); + regmap->vend1_ltc_rd_nsec_0); ts->tv_nsec |= phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_LTC_RD_NSEC_1) << 16; + regmap->vend1_ltc_rd_nsec_1) << 16; ts->tv_sec = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_LTC_RD_SEC_0); + regmap->vend1_ltc_rd_sec_0); ts->tv_sec |= phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_LTC_RD_SEC_1) << 16; + regmap->vend1_ltc_rd_sec_1) << 16; return 0; } @@ -267,17 +367,17 @@ static int _nxp_c45_ptp_settime64(struct ptp_clock_info *ptp, const struct timespec64 *ts) { struct nxp_c45_phy *priv = container_of(ptp, struct nxp_c45_phy, caps); + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_WR_NSEC_0, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, regmap->vend1_ltc_wr_nsec_0, ts->tv_nsec); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_WR_NSEC_1, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, regmap->vend1_ltc_wr_nsec_1, ts->tv_nsec >> 16); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_WR_SEC_0, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, regmap->vend1_ltc_wr_sec_0, ts->tv_sec); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_WR_SEC_1, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, regmap->vend1_ltc_wr_sec_1, ts->tv_sec >> 16); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_LTC_LOAD_CTRL, - LOAD_LTC); + nxp_c45_set_reg_field(priv->phydev, ®map->ltc_write); return 0; } @@ -297,6 +397,8 @@ static int nxp_c45_ptp_settime64(struct ptp_clock_info *ptp, static int nxp_c45_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) { struct nxp_c45_phy *priv = container_of(ptp, struct nxp_c45_phy, caps); + const struct nxp_c45_phy_data *data = nxp_c45_get_data(priv->phydev); + const struct nxp_c45_regmap *regmap = data->regmap; s32 ppb = scaled_ppm_to_ppb(scaled_ppm); u64 subns_inc_val; bool inc; @@ -305,16 +407,18 @@ static int nxp_c45_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) inc = ppb >= 0; ppb = abs(ppb); - subns_inc_val = PPM_TO_SUBNS_INC(ppb); + subns_inc_val = PPM_TO_SUBNS_INC(ppb, data->ptp_clk_period); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_RATE_ADJ_SUBNS_0, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, + regmap->vend1_rate_adj_subns_0, subns_inc_val); subns_inc_val >>= 16; subns_inc_val |= CLK_RATE_ADJ_LD; if (inc) subns_inc_val |= CLK_RATE_ADJ_DIR; - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_RATE_ADJ_SUBNS_1, + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, + regmap->vend1_rate_adj_subns_1, subns_inc_val); mutex_unlock(&priv->ptp_lock); @@ -358,21 +462,25 @@ static bool nxp_c45_match_ts(struct ptp_header *header, static void nxp_c45_get_extts(struct nxp_c45_phy *priv, struct timespec64 *extts) { + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); + extts->tv_nsec = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EXT_TRG_TS_DATA_0); + regmap->vend1_ext_trg_data_0); extts->tv_nsec |= phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EXT_TRG_TS_DATA_1) << 16; + regmap->vend1_ext_trg_data_1) << 16; extts->tv_sec = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EXT_TRG_TS_DATA_2); + regmap->vend1_ext_trg_data_2); extts->tv_sec |= phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EXT_TRG_TS_DATA_3) << 16; - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EXT_TRG_TS_CTRL, - RING_DONE); + regmap->vend1_ext_trg_data_3) << 16; + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, + regmap->vend1_ext_trg_ctrl, RING_DONE); } static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv, struct nxp_c45_hwts *hwts) { + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); + struct phy_device *phydev = priv->phydev; bool valid; u16 reg; @@ -384,16 +492,18 @@ static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv, if (!valid) goto nxp_c45_get_hwtxts_out; - hwts->domain_number = reg; - hwts->msg_type = (reg & RING_DATA_0_MSG_TYPE) >> 8; - hwts->sec = (reg & RING_DATA_0_SEC_4_2) >> 10; - hwts->sequence_id = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EGR_RING_DATA_1_SEQ_ID); - hwts->nsec = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_EGR_RING_DATA_2_NSEC_15_0); - reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_DATA_3); - hwts->nsec |= (reg & RING_DATA_3_NSEC_29_16) << 16; - hwts->sec |= (reg & RING_DATA_3_SEC_1_0) >> 14; + hwts->domain_number = + nxp_c45_read_reg_field(phydev, ®map->domain_number); + hwts->msg_type = + nxp_c45_read_reg_field(phydev, ®map->msg_type); + hwts->sequence_id = + nxp_c45_read_reg_field(phydev, ®map->sequence_id); + hwts->nsec = + nxp_c45_read_reg_field(phydev, ®map->nsec_15_0); + hwts->nsec |= + nxp_c45_read_reg_field(phydev, ®map->nsec_29_16) << 16; + hwts->sec = nxp_c45_read_reg_field(phydev, ®map->sec_1_0); + hwts->sec |= nxp_c45_read_reg_field(phydev, ®map->sec_4_2) << 2; nxp_c45_get_hwtxts_out: mutex_unlock(&priv->ptp_lock); @@ -498,6 +608,7 @@ static void nxp_c45_gpio_config(struct nxp_c45_phy *priv, static int nxp_c45_perout_enable(struct nxp_c45_phy *priv, struct ptp_perout_request *perout, int on) { + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); struct phy_device *phydev = priv->phydev; int pin; @@ -509,10 +620,10 @@ static int nxp_c45_perout_enable(struct nxp_c45_phy *priv, return pin; if (!on) { - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_CONFIG, - PPS_OUT_EN); - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_CONFIG, - PPS_OUT_POL); + nxp_c45_clear_reg_field(priv->phydev, + ®map->pps_enable); + nxp_c45_clear_reg_field(priv->phydev, + ®map->pps_polarity); nxp_c45_gpio_config(priv, pin, GPIO_DISABLE); @@ -541,16 +652,16 @@ static int nxp_c45_perout_enable(struct nxp_c45_phy *priv, } if (perout->phase.nsec == 0) - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PTP_CONFIG, PPS_OUT_POL); + nxp_c45_clear_reg_field(priv->phydev, + ®map->pps_polarity); else - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PTP_CONFIG, PPS_OUT_POL); + nxp_c45_set_reg_field(priv->phydev, + ®map->pps_polarity); } nxp_c45_gpio_config(priv, pin, GPIO_PPS_OUT_CFG); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_CONFIG, PPS_OUT_EN); + nxp_c45_set_reg_field(priv->phydev, ®map->pps_enable); return 0; } @@ -725,6 +836,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, struct nxp_c45_phy *priv = container_of(mii_ts, struct nxp_c45_phy, mii_ts); struct phy_device *phydev = priv->phydev; + const struct nxp_c45_phy_data *data; struct hwtstamp_config cfg; if (copy_from_user(&cfg, ifreq->ifr_data, sizeof(cfg))) @@ -733,6 +845,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, if (cfg.tx_type < 0 || cfg.tx_type > HWTSTAMP_TX_ON) return -ERANGE; + data = nxp_c45_get_data(phydev); priv->hwts_tx = cfg.tx_type; switch (cfg.rx_filter) { @@ -750,27 +863,24 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts, } if (priv->hwts_rx || priv->hwts_tx) { - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_EVENT_MSG_FILT, + phy_write_mmd(phydev, MDIO_MMD_VEND1, + data->regmap->vend1_event_msg_filt, EVENT_MSG_FILT_ALL); - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PORT_PTP_CONTROL, - PORT_PTP_CONTROL_BYPASS); + data->ptp_enable(phydev, true); } else { - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_EVENT_MSG_FILT, + phy_write_mmd(phydev, MDIO_MMD_VEND1, + data->regmap->vend1_event_msg_filt, EVENT_MSG_FILT_NONE); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_PTP_CONTROL, - PORT_PTP_CONTROL_BYPASS); + data->ptp_enable(phydev, false); } if (nxp_c45_poll_txts(priv->phydev)) goto nxp_c45_no_ptp_irq; if (priv->hwts_tx) - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PTP_IRQ_EN, PTP_IRQ_EGR_TS); + nxp_c45_set_reg_field(phydev, &data->regmap->irq_egr_ts_en); else - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, - VEND1_PTP_IRQ_EN, PTP_IRQ_EGR_TS); + nxp_c45_clear_reg_field(phydev, &data->regmap->irq_egr_ts_en); nxp_c45_no_ptp_irq: return copy_to_user(ifreq->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; @@ -795,57 +905,79 @@ static int nxp_c45_ts_info(struct mii_timestamper *mii_ts, return 0; } -static const struct nxp_c45_phy_stats nxp_c45_hw_stats[] = { - { "phy_symbol_error_cnt", MDIO_MMD_VEND1, - VEND1_SYMBOL_ERROR_COUNTER, 0, GENMASK(15, 0) }, - { "phy_link_status_drop_cnt", MDIO_MMD_VEND1, - VEND1_LINK_DROP_COUNTER, 8, GENMASK(13, 8) }, - { "phy_link_availability_drop_cnt", MDIO_MMD_VEND1, - VEND1_LINK_DROP_COUNTER, 0, GENMASK(5, 0) }, - { "phy_link_loss_cnt", MDIO_MMD_VEND1, - VEND1_LINK_LOSSES_AND_FAILURES, 10, GENMASK(15, 10) }, - { "phy_link_failure_cnt", MDIO_MMD_VEND1, - VEND1_LINK_LOSSES_AND_FAILURES, 0, GENMASK(9, 0) }, - { "rx_preamble_count", MDIO_MMD_VEND1, - VEND1_RX_PREAMBLE_COUNT, 0, GENMASK(5, 0) }, - { "tx_preamble_count", MDIO_MMD_VEND1, - VEND1_TX_PREAMBLE_COUNT, 0, GENMASK(5, 0) }, - { "rx_ipg_length", MDIO_MMD_VEND1, - VEND1_RX_IPG_LENGTH, 0, GENMASK(8, 0) }, - { "tx_ipg_length", MDIO_MMD_VEND1, - VEND1_TX_IPG_LENGTH, 0, GENMASK(8, 0) }, +static const struct nxp_c45_phy_stats common_hw_stats[] = { + { "phy_link_status_drop_cnt", + NXP_C45_REG_FIELD(0x8352, MDIO_MMD_VEND1, 8, 6), }, + { "phy_link_availability_drop_cnt", + NXP_C45_REG_FIELD(0x8352, MDIO_MMD_VEND1, 0, 6), }, + { "phy_link_loss_cnt", + NXP_C45_REG_FIELD(0x8353, MDIO_MMD_VEND1, 10, 6), }, + { "phy_link_failure_cnt", + NXP_C45_REG_FIELD(0x8353, MDIO_MMD_VEND1, 0, 10), }, + { "phy_symbol_error_cnt", + NXP_C45_REG_FIELD(0x8350, MDIO_MMD_VEND1, 0, 16) }, +}; + +static const struct nxp_c45_phy_stats tja1103_hw_stats[] = { + { "rx_preamble_count", + NXP_C45_REG_FIELD(0xAFCE, MDIO_MMD_VEND1, 0, 6), }, + { "tx_preamble_count", + NXP_C45_REG_FIELD(0xAFCF, MDIO_MMD_VEND1, 0, 6), }, + { "rx_ipg_length", + NXP_C45_REG_FIELD(0xAFD0, MDIO_MMD_VEND1, 0, 9), }, + { "tx_ipg_length", + NXP_C45_REG_FIELD(0xAFD1, MDIO_MMD_VEND1, 0, 9), }, }; static int nxp_c45_get_sset_count(struct phy_device *phydev) { - return ARRAY_SIZE(nxp_c45_hw_stats); + const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev); + + return ARRAY_SIZE(common_hw_stats) + (phy_data ? phy_data->n_stats : 0); } static void nxp_c45_get_strings(struct phy_device *phydev, u8 *data) { + const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev); + size_t count = nxp_c45_get_sset_count(phydev); + size_t idx; size_t i; - for (i = 0; i < ARRAY_SIZE(nxp_c45_hw_stats); i++) { + for (i = 0; i < count; i++) { + if (i < ARRAY_SIZE(common_hw_stats)) { + strncpy(data + i * ETH_GSTRING_LEN, + common_hw_stats[i].name, ETH_GSTRING_LEN); + continue; + } + idx = i - ARRAY_SIZE(common_hw_stats); strncpy(data + i * ETH_GSTRING_LEN, - nxp_c45_hw_stats[i].name, ETH_GSTRING_LEN); + phy_data->stats[idx].name, ETH_GSTRING_LEN); } } static void nxp_c45_get_stats(struct phy_device *phydev, struct ethtool_stats *stats, u64 *data) { + const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev); + size_t count = nxp_c45_get_sset_count(phydev); + const struct nxp_c45_reg_field *reg_field; + size_t idx; size_t i; int ret; - for (i = 0; i < ARRAY_SIZE(nxp_c45_hw_stats); i++) { - ret = phy_read_mmd(phydev, nxp_c45_hw_stats[i].mmd, - nxp_c45_hw_stats[i].reg); - if (ret < 0) { - data[i] = U64_MAX; + for (i = 0; i < count; i++) { + if (i < ARRAY_SIZE(common_hw_stats)) { + reg_field = &common_hw_stats[i].counter; } else { - data[i] = ret & nxp_c45_hw_stats[i].mask; - data[i] >>= nxp_c45_hw_stats[i].off; + idx = i - ARRAY_SIZE(common_hw_stats); + reg_field = &phy_data->stats[idx].counter; } + + ret = nxp_c45_read_reg_field(phydev, reg_field); + if (ret < 0) + data[i] = U64_MAX; + else + data[i] = ret; } } @@ -884,6 +1016,7 @@ static int nxp_c45_config_intr(struct phy_device *phydev) static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) { + const struct nxp_c45_phy_data *data = nxp_c45_get_data(phydev); struct nxp_c45_phy *priv = phydev->priv; irqreturn_t ret = IRQ_NONE; struct nxp_c45_hwts hwts; @@ -901,8 +1034,8 @@ static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) * The irq signal will be asserted until the EGR TS FIFO will be * emptied. */ - irq = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_IRQ_STATUS); - if (irq & PTP_IRQ_EGR_TS) { + irq = nxp_c45_read_reg_field(phydev, &data->regmap->irq_egr_ts_status); + if (irq) { while (nxp_c45_get_hwtxts(priv, &hwts)) nxp_c45_process_txts(priv, &hwts); @@ -929,24 +1062,28 @@ static int nxp_c45_soft_reset(struct phy_device *phydev) static int nxp_c45_cable_test_start(struct phy_device *phydev) { - return phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_CABLE_TEST, - CABLE_TEST_ENABLE | CABLE_TEST_START); + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(phydev); + + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, regmap->cable_test, + CABLE_TEST_ENABLE | CABLE_TEST_START); } static int nxp_c45_cable_test_get_status(struct phy_device *phydev, bool *finished) { + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(phydev); int ret; u8 cable_test_result; - ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_CABLE_TEST); - if (!(ret & CABLE_TEST_VALID)) { + ret = nxp_c45_read_reg_field(phydev, ®map->cable_test_valid); + if (!ret) { *finished = false; return 0; } *finished = true; - cable_test_result = ret & GENMASK(2, 0); + cable_test_result = nxp_c45_read_reg_field(phydev, + ®map->cable_test_result); switch (cable_test_result) { case CABLE_TEST_OK: @@ -966,7 +1103,7 @@ static int nxp_c45_cable_test_get_status(struct phy_device *phydev, ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC); } - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_CABLE_TEST, + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, regmap->cable_test, CABLE_TEST_ENABLE); return nxp_c45_start_op(phydev); @@ -1005,6 +1142,28 @@ static int nxp_c45_check_delay(struct phy_device *phydev, u32 delay) return 0; } +static void nxp_c45_counters_enable(struct phy_device *phydev) +{ + const struct nxp_c45_phy_data *data = nxp_c45_get_data(phydev); + + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_LINK_DROP_COUNTER, + COUNTER_EN); + + data->counters_enable(phydev); +} + +static void nxp_c45_ptp_init(struct phy_device *phydev) +{ + const struct nxp_c45_phy_data *data = nxp_c45_get_data(phydev); + + phy_write_mmd(phydev, MDIO_MMD_VEND1, + data->regmap->vend1_ptp_clk_period, + data->ptp_clk_period); + nxp_c45_clear_reg_field(phydev, &data->regmap->ltc_lock_ctrl); + + data->ptp_init(phydev); +} + static u64 nxp_c45_get_phase_shift(u64 phase_offset_raw) { /* The delay in degree phase is 73.8 + phase_offset_raw * 0.9. @@ -1182,31 +1341,14 @@ static int nxp_c45_config_init(struct phy_device *phydev) phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_CONFIG, PHY_CONFIG_AUTO); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_LINK_DROP_COUNTER, - COUNTER_EN); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_PREAMBLE_COUNT, - COUNTER_EN); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_TX_PREAMBLE_COUNT, - COUNTER_EN); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_IPG_LENGTH, - COUNTER_EN); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_TX_IPG_LENGTH, - COUNTER_EN); - ret = nxp_c45_set_phy_mode(phydev); if (ret) return ret; phydev->autoneg = AUTONEG_DISABLE; - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_CLK_PERIOD, - PTP_CLK_PERIOD_100BT1); - phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_HW_LTC_LOCK_CTRL, - HW_LTC_LOCK_EN); - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_TS_INSRT_CTRL, - RX_TS_INSRT_MODE2); - phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_FUNC_ENABLES, - PTP_ENABLE); + nxp_c45_counters_enable(phydev); + nxp_c45_ptp_init(phydev); return nxp_c45_start_op(phydev); } @@ -1266,11 +1408,107 @@ static void nxp_c45_remove(struct phy_device *phydev) skb_queue_purge(&priv->rx_queue); } +static void tja1103_counters_enable(struct phy_device *phydev) +{ + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_PREAMBLE_COUNT, + COUNTER_EN); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_TX_PREAMBLE_COUNT, + COUNTER_EN); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_IPG_LENGTH, + COUNTER_EN); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_TX_IPG_LENGTH, + COUNTER_EN); +} + +static void tja1103_ptp_init(struct phy_device *phydev) +{ + phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_RX_TS_INSRT_CTRL, + TJA1103_RX_TS_INSRT_MODE2); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_FUNC_ENABLES, + PTP_ENABLE); +} + +static void tja1103_ptp_enable(struct phy_device *phydev, bool enable) +{ + if (enable) + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_PTP_CONTROL, + PORT_PTP_CONTROL_BYPASS); + else + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_PTP_CONTROL, + PORT_PTP_CONTROL_BYPASS); +} + +static const struct nxp_c45_regmap tja1103_regmap = { + .vend1_ptp_clk_period = 0x1104, + .vend1_event_msg_filt = 0x1148, + .pps_enable = + NXP_C45_REG_FIELD(0x1102, MDIO_MMD_VEND1, 3, 1), + .pps_polarity = + NXP_C45_REG_FIELD(0x1102, MDIO_MMD_VEND1, 2, 1), + .ltc_lock_ctrl = + NXP_C45_REG_FIELD(0x1115, MDIO_MMD_VEND1, 0, 1), + .ltc_read = + NXP_C45_REG_FIELD(0x1105, MDIO_MMD_VEND1, 2, 1), + .ltc_write = + NXP_C45_REG_FIELD(0x1105, MDIO_MMD_VEND1, 0, 1), + .vend1_ltc_wr_nsec_0 = 0x1106, + .vend1_ltc_wr_nsec_1 = 0x1107, + .vend1_ltc_wr_sec_0 = 0x1108, + .vend1_ltc_wr_sec_1 = 0x1109, + .vend1_ltc_rd_nsec_0 = 0x110A, + .vend1_ltc_rd_nsec_1 = 0x110B, + .vend1_ltc_rd_sec_0 = 0x110C, + .vend1_ltc_rd_sec_1 = 0x110D, + .vend1_rate_adj_subns_0 = 0x110F, + .vend1_rate_adj_subns_1 = 0x1110, + .irq_egr_ts_en = + NXP_C45_REG_FIELD(0x1131, MDIO_MMD_VEND1, 0, 1), + .irq_egr_ts_status = + NXP_C45_REG_FIELD(0x1132, MDIO_MMD_VEND1, 0, 1), + .domain_number = + NXP_C45_REG_FIELD(0x114E, MDIO_MMD_VEND1, 0, 8), + .msg_type = + NXP_C45_REG_FIELD(0x114E, MDIO_MMD_VEND1, 8, 4), + .sequence_id = + NXP_C45_REG_FIELD(0x114F, MDIO_MMD_VEND1, 0, 16), + .sec_1_0 = + NXP_C45_REG_FIELD(0x1151, MDIO_MMD_VEND1, 14, 2), + .sec_4_2 = + NXP_C45_REG_FIELD(0x114E, MDIO_MMD_VEND1, 12, 3), + .nsec_15_0 = + NXP_C45_REG_FIELD(0x1150, MDIO_MMD_VEND1, 0, 16), + .nsec_29_16 = + NXP_C45_REG_FIELD(0x1151, MDIO_MMD_VEND1, 0, 14), + .vend1_ext_trg_data_0 = 0x1121, + .vend1_ext_trg_data_1 = 0x1122, + .vend1_ext_trg_data_2 = 0x1123, + .vend1_ext_trg_data_3 = 0x1124, + .vend1_ext_trg_ctrl = 0x1126, + .cable_test = 0x8330, + .cable_test_valid = + NXP_C45_REG_FIELD(0x8330, MDIO_MMD_VEND1, 13, 1), + .cable_test_result = + NXP_C45_REG_FIELD(0x8330, MDIO_MMD_VEND1, 0, 3), +}; + +static const struct nxp_c45_phy_data tja1103_phy_data = { + .regmap = &tja1103_regmap, + .stats = tja1103_hw_stats, + .n_stats = ARRAY_SIZE(tja1103_hw_stats), + .ptp_clk_period = PTP_CLK_PERIOD_100BT1, + .counters_enable = tja1103_counters_enable, + .ptp_init = tja1103_ptp_init, + .ptp_enable = tja1103_ptp_enable, +}; + static struct phy_driver nxp_c45_driver[] = { { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103), .name = "NXP C45 TJA1103", .features = PHY_BASIC_T1_FEATURES, + .driver_data = &tja1103_phy_data, .probe = nxp_c45_probe, .soft_reset = nxp_c45_soft_reset, .config_aneg = genphy_c45_config_aneg, From patchwork Tue Jun 27 07:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294116 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 A9C8BBA24 for ; Tue, 27 Jun 2023 07:21:23 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1a::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7FE2297C; Tue, 27 Jun 2023 00:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UBLK/n5fFcKS9YutzotuE64sUeHjciINKLDYdZUuceIW7FqRcSId5gomTBscPZVacb8rJYkxJsAAbT1o93xlebTfOoVlosYHTjU85jRkK3wBQjyoAqHhB+UtaaCcAXpzk1mA6GoK98/GxXRZgPVPOYnB61cXgPXicc07vdrRxXhLvs1/bAaYD8BgK7lKaaNn4VGaAnMo7iMrS43Rb7G30ETRX9ptXrWbGc3tSqX6l/dLLFaUc6DidxHmkoVBtbQGXqnXoaikD3w7EXb/z2E3aa0vcV4A29I7FMdwkQ6HPAdO3NPhjYDsJZ9DUlGd21AK90dv7iOdaJ3QrxN/EWgT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5A3TvpPDx6Lw//TvQlhQQhKB3sizd62BWefxoGC1ffI=; b=Mz5DvUa9X2RjY9d5ggZxEfjh+lrfVd6hB5kDQCDfTZpn0fVEI2W0bqlWxIoW0zVF6BHmXGadKJI6/ymOBh64H5qQOSHqDVKpm2eove6RI5QZUDgv6ofpNLGZHMKhAmcevSJ6+HPnfNHNxyp8B5FqqjptglssY3y3bZnjKx/8rds3Yv465PP3dKR1VqhQuSg0+h/DV3LnYl2+PCkLI/ivR7F6JGxtg8bxXaqzylsZ/PMhpVarI18Oy+HPGuH4GQ+Cmy7jDcdceI1vleE74aMI8VZCKywYDk4iUGJQE0GtiNfOmjCnZ6o+brs61cIJmKfYTET6uluDY3gDtp3WcL0O7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5A3TvpPDx6Lw//TvQlhQQhKB3sizd62BWefxoGC1ffI=; b=FVs4xf89ecvHRc4rRf9C2LLA3lVs21aFLQggh4uMqz/n/ocWqQwQ99MUGB0hEabTXCyhzfJNwvapOi/cK3xkybPbLe6+8vuUqpsLLJXYDPJZMmFPIHlxlIDJcanuVmdpQEpgFAUorBFBSSWz2BaTt//fNOHxmTn/Fs0Z5ZYdSIY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:57 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:57 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 04/12] net: phy: c45: detect 100BaseT1 and 1000BaseT1 PMA abilites Date: Tue, 27 Jun 2023 10:18:45 +0300 Message-Id: <20230627071853.106215-5-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c86d571-5a42-407b-a5ee-08db76dee916 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0UuqOOwEw5k9wFA/J3Hp2zORDqXONApvpWimyQQYEe7j1uVhbD+dsDcS275N+K6TQX1qgXC0Md/TWpHczPQYh0Zn/2ImI5Je+IVsJxSI5MdS/HrGRUQmfT6sweFSL35D3B4A5qWGPQsXVBgPMTnLu/9bUz6Jc6MzaP+graXKufVcN9ZpjoRH/dfH15/xY6VdCKhXLPFdBBOvXXOeT7qIYRzvJ98cPx0U7rqkHZyDv/TbrtIqlpEmHVrbcVh1p23exk4C0vY4fk55HObRjc0njUu2pCo5m+X8kL4OjhTr2uf4RFmDytXErf3dhPN/8ZlVjCDN4vtx8wY1qpnceeraeEHYnl0G4OH04I1OpmIVSqjNmK/wBrHG9osuQMfWiG8mVZit86mKX8+t8vBECOQyR1GWW+Yx/HXfhKINO9AxVzUGWdJqQDK4YiA+qojVNWbY3Ag2/dT6sdv3qQO3Na/rDjyvLVwbjCDZw3v4MeeT2YpulW8vBpjxQ2DXKkw2cO52gx10vhvMyz1TmgD3PVNigUUk6EstZTP00tijDrXsOH6JHZv0XkB+9Xo68LZuzkxNhQTLURkoqQRE+f40LkDV1r9ROuy9fUobPfwMYzkA7m7KesAM3IPtNUPOC56sbP4+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d9rUTenTgBzrTPHYcOX1GojaBQhAhhZxSh+nooUyGdjGjxhe/ViIO3+LBYsfdr8MgSEU/X5IEMLX47ovhWQ8onxQS24pdaThWkZia6AMykKY+BuRTqvLfDFo1qgPP1wWlM1MzgP62n4LyQKGt7JI34Ft8EYvje01/gk3e7btJPtZbGf7osV7sn13iyTapmIc1pOoWqklund/8RHiDyTdhnekyAt8HWVaaTmMO9WCXsTqCekOMr3JSh+ZeiHvJOQ/yqfWCPST1UXVWqvzTkxhD6+pb1IkCvMuqa2wB7s7sFJ7SS0CZGqSiguIs/OymNxqFBV52Xn5ExcIwCjJX5IsDAEDXi3qQKMYkKXp/kkr+hVd8i5w5TEu2sHa9QN0e+M5/zLNBJhwmR+EeGKwPQP7vJ9dM9sSeUAmBzo6DW7uGdzVjo0iXUzyPHWBD5ouqxrnFMnrL8LbntWLJVkalOImTO1sscQDBx8Yq9vUvwVLm63hlNz5xYoo3Y6XBlOB8NAZt2NczUxtiYTH2fBrDHYAPU/kDyEvfaAKE+N92Et/bzayapBU3yX91oqcW1v6XHYx6il9mQzFA3DjkKeXi7zGNGLD2xQCdUZap/zkOazg0tEwFU2OHkmRvu9j+2dJ19696ihYjZmai1KbLSZNepnn88xHpNhSLahwMfDu2s2IRt0LRclyi57gMhJIczCpoYY2IJt66iOo3Tc9WGTGcUKBqZ7jsBbklNz/34AlxQEDXbrwPB4pdC440FYqkQa2WKi3XGBR0CpGTyfq56uUrM3Q4g3up9UY43wqNjYcEJ9To/2zE78cLN7oRRtbDa2CbKuNlgwYVP43lAcLfKYen2Ln8ClP+XDcdIVGevSWHRgO2fWvJWRan2bWMxkdd+56i6UNSiJ/ikji6X8yF2rXOKhuEJKl83EkANSOB4pkc9fLxgpZOmeyWElT0PxLQqJggapudA0suVWvOocwt5jX8DgGaR0m+8dUIG2IoWQXpMLjkvTrQG7F/rsVTj30QloGzaoINo1qKf1y+UIPHkKCF7+KJJvW3KdSUic14d77cBGmU/Qk/yk48ZuUz7thpJ+KNIylSl/6voCNYPjAuilcrl6lVWOY5iQuCA6SW9p/vP2NRtXnrFmqllzK7J9RxP04vNhw8URqJDmI9LBd4JQx+HTITJ5sBqfpfDRZpL6W2X+C2522+P8w3MkCB2FwZQfC1cRs+ZPyGddvlua+W6/5ok6YbteWV7WZ7zvYjAu62IwTtd14LcxF8S4Ftcy0RA66IMYF4qaDeyxKYC2Ut+Q9yxFFbaQXLApygVA6XHGFLXSDP9Fi+tv9kHP5WVy1AWM7JTtyCK/pscaqGvBMHMJ3GOUy/coIjddkGWoZ+43LhcxBWX08bULeC5y0MLfW7r5dbpTpCzgKrOcoTS6ShDDZzkfpuGk9vf3ip0aDv0IHXmQuRgdxuWSmWTVo9QDtuTQy3LAEIX0/zmk39dZNLEsfL3YTw19X5t190XprLQfQ/dP9WYEPKoJdu9MQF7BinQ6RE/1u1aG7A+QnC2morElHMkh6CJYgv++Ys/VoGR1W0lb55mN+aD+BnsPFi1ouk2m/Dv7dm/dMAf3DvOAqgXqAZtfZ3Q== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c86d571-5a42-407b-a5ee-08db76dee916 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:57.0291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k995iFH/hbuoWoRve+QlRmuSf444wsx0EFxBH43mZuKwGkUBP8RwGzgR1bnjzoiJwtj2M3fnU+1zTbtUXGM4STAm3f30QBk8LmfrxBaIrpA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Detect 100BaseT1 and 1000BaseT1 PMA abilites using dedicated bits. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 8 ++++++++ include/uapi/linux/mdio.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index fee514b96ab1..1017aeb0599b 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -976,6 +976,14 @@ int genphy_c45_pma_read_abilities(struct phy_device *phydev) phydev->supported, val & MDIO_PMA_PMD_BT1_B10L_ABLE); + linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT, + phydev->supported, + val & MDIO_PMA_PMD_BT1_B100_ABLE); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT1_Full_BIT, + phydev->supported, + val & MDIO_PMA_PMD_BT1_B1000_ABLE); + val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT); if (val < 0) return val; diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index b826598d1e94..82ed363f5268 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -332,6 +332,8 @@ #define MDIO_PCS_10T1L_CTRL_RESET 0x8000 /* PCS reset */ /* BASE-T1 PMA/PMD extended ability register. */ +#define MDIO_PMA_PMD_BT1_B100_ABLE 0x0001 /* 100BASE-T1 Ability */ +#define MDIO_PMA_PMD_BT1_B1000_ABLE 0x0002 /* 1000BASE-T1 Ability */ #define MDIO_PMA_PMD_BT1_B10L_ABLE 0x0004 /* 10BASE-T1L Ability */ /* BASE-T1 auto-negotiation advertisement register [15:0] */ From patchwork Tue Jun 27 07:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294120 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 AB78214A85 for ; Tue, 27 Jun 2023 07:21:51 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1a::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E5CD26BD; Tue, 27 Jun 2023 00:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QpVIW7tpYxlhVEu17YnuG3bQurawgmwIQWdUSrkAtmHFHujkoKOh2HzrKAX5c005pky7/R1vDltU4vmBST38oW4TsQmcgxQlt464kN94hrim8JBGrBEkSxM/S+Tlf/qGXJd6zbdBEIENduQ6zaQF6fRgqcxuGM+eGIX4J2QHHicoJf0Gpjf1fKaXCHUz0KUulFJ6mRAjWuhC4J6jGy+aFHU4TYQWn6fvhnq/H3U91gUl5TBEXitpMxfcwyvagb/qGw3Tpns/v1sYraRDUpER2eMR/fd4+GCscYFWvBnzRE7pEy7mm4E7Vtunjx8519HxTuVaWIdv3zYx79iASqpSiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qzsk+mHGXhbZw7I/759xd9x+ML75II/ApusXCe27GC8=; b=YzqIG94apeItDopC7l1ok53o0H9ySRjyDZ5UcVYOI5LooGFHClwbqc9C2hVDi6e3JliaRSYGHNTI1mITJyzDFduQ4QsCubkAscw82oQ3dasff8SxORvsUlHiIYfJigawdcXlxtZrx8WCFpyeU/GTl7CGhWeu3pErLXMUBFeym1Ja/6TKOCHw162ndQhiA3KZYTWzAxThYdrCsLMvLVRpbuKYXRdEmvdAuMGy2vPTuQo55LjOGUdduc8pqeeD9podUCxwWYAYjKO2BRaUvr2NgfPJ7mJ1lL1/0KfkH0A7QJ58fXsTvqFGAkV0RU8MV6O50/GiQMhikLJbaVymXiXRFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qzsk+mHGXhbZw7I/759xd9x+ML75II/ApusXCe27GC8=; b=Q6HRSs4gwsWmbXjHIo/5+w2wo0WxvFab4cGJDz51kds8qtHS0nCeEI3LaLTNuvmaNPAeDJv319B7PeJHyDOndG9d4CP/jO3ufMrk8NSS9ZZZGvrge8ci1MTlh5iRAnTIxGKOernbmw1Qs9ar+kMztx5zCic5s6rp7W+y2nnKvdo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:58 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:58 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 05/12] net: phy: nxp-c45-tja11xx: use get_features Date: Tue, 27 Jun 2023 10:18:46 +0300 Message-Id: <20230627071853.106215-6-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ee8034f-4f83-48ed-be3d-08db76dee9b8 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HMmMa4EAJLoe2WuTODKA0oPfjwTtA87YLPhykHA5qumwDDizV42YWvsufIStpokqJpc992qas3IOnXWQS7fZvFYMWBSqk7YkVGHBT4sQbpBQ2jlwLi+vVGkfeo7uhlGxye+X53nlwT8xdgWvRt08h+tukhq3TRtcoCS3dRh8zcRPmZDN6uKt9q8c9Y7scXrW8Afkl5wh4Ufx6OGmDlojuSMb9wP+TzsF1RTWm23+6SKf/7BHk14RbVCiDNzC7L1AkkMM/SNnKaOArOtE/hJVnxRm+hlsiI5NuIAnLbE/GvQxL6g6xi1gYL/jg28EGqfNsxPLmBGgV+D1qx7ln0Bf5+AzbN3kePxxnL0gBe+s1NPlEEZGL8Iv1zMvRZZAlOyXVbwe63t1Y2cG7GpabhS4OX36KBgU0FN+HzRMsM1heeMQM3rB+XnGZ5XFWlxJGID15nnUCzyHDpcmZIxUa8/APz73QizIwZpfrXWQz1xI3l0acMN/N9KD8rbHI4otDuZtpWqgji8ZS+lbzLxAlf95oeNrHChrw521A7H3QjG18E867FVfPL4dscnq41zO0+HP3eWB6qDz9LIj+zUeyXX8IVU8JoYYNbTr2cy/sckj5F0YfvVCr96aWbe0dxgj0Dez X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4NFDOlBnm0PlJBBPnO32S3gmDW3D5kgoz+IZ7zf/jh9Sarh416ecAY2mBiNK2pu/JEChoKx5uB0wGMMaZKaS1j15FAYC/+Sof5LksSfS2hUwxT00xW1N4wdul5bsBl68rFkYQ3ePwlwFC2n6M/G+PYQpSzAZxxNlqXp5ZRq6l4xtUT/lOL6kIM9WDs123squhhFMZ/QPs+X2XgoNiejQYdV6/EJpAcXAOd5fyDeG8yg8Bc0SyZpykmRoz0/06KcuFfF/DO5eGZvvkvp4aeeCjMY8fcbrnZewQR6HRk+5SqWE4ZpSrH0rqOmr6TU05PWsNFAYKmiwgEwMaFgIiHeh7KkG6YLuoH0w4WvgsJp8xp687JZ/NWI4gkwmb1hlIyYRxew6RMBUXrlyvxVQ194QqWC9Diy7p28xGm4lnhBipVtIL93keK4qAW02aYH2yN9wB6cDcdfbPNL/KmndW9J1SnvNmNv3Q///eS40ENDxMiu7MbOk3Hqk3gLNFjVb1hFRuC30Rbj3tp5IKzbyhavQE0mD5BdJLnX94S2WLUL8xq9BD8JkvxQAcjZ1o47/rdAZ4JcLiOghXYqwWBg7K8NlIGhPbmsmoE0sU0HLaQQ92x7f+Qfz/G3Vjb8RoOBFMKLX+sJirXDrJBXQPW+LHl2EprAwxbQVD7NqSKl2zEtXF3BcdcmbFGUMDkwLsrE0pttIoIIQ9jSukYTrtNfAKyyMGe85Lm/CVXYfp45cDlNOr85mtpz3WWI51TSZfkRYfkBdAsuc346VW6/HFiRtEl2d5yGJRRXXJRmsGdr0igXHPzRrv2CeEXGUC43kB74CPI4tfDWUVd3RfkOA7mfp6mtdadtueusDlyFI/jvVh1rysMiq3J7mEMnME2UkvMcVieoYaYefAbGi6KCofuHXE3b0DPRmbJXmSnzRpocrXF0rvsUm9bI9j3fxot7s/6YnltIl6Qc8n7asEmZripprH9w0OrnddmL4kSKkAaj/1REd+x/2rT/G9XVXif/gfzWVXNEifiX+A9Zd2NvaY9yh2wckWm4viHOg6UZl1JVtkcfQXiKef25f0EGMxbfsD7AxZek9w2wSATuVAAs6Obb2IUtkMKynorrMWkbCT+9lWspObFT31HJEUZ/S0vVb/L1FGelw94wWnFMjY0pf/FgNakYyv81ODuSQlRI3Vc6OBhElovylHSryPiNlpWaBUr3cuq2SksEgUH4j8LFNltyG+HGLfRksFkvKkg93qG8U00DCOvx/qfNKQPoO4+JnGr2oaVR53696RSMCDwurGbSfPsu+vBbUfiKfyrrRwdsbi1Ue9Khc6gCL+c+UH8P82GTkTXJ1FZ4iKzyDxNpnKxYGwEfGbWD4oOhkvzyfjlv07tC3XT7XRcSr+oKtjUcwRkh+7UVonQxPO0t5BtR1m/0IoayxgqZ65IPD0MbvQud94CZiwj46xbujUf9GNVKFwaNP3m39ud4Bws4iJDkVybiXISbOXZ82wJEQodpK7KtmXmUKGp5JSTgiAjlaPuMaUrV9+/3gk3jJns15IjISnFFPN8XzBbNkl5AEYqClnHyk1FZTtO9wQQDomljLzryTGiVbxovt93St60rgWKalUSw2f/FozQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ee8034f-4f83-48ed-be3d-08db76dee9b8 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:58.0372 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pHDkevAv1hmFxxSfWK3FonOt0RhGotDRl6YMjXv7zN2Tj7Lgj2+Zua/p28EIvdGshvtywuRqgB63MQiv08Koee+BLTc905q1knHn2yYMDHA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org PHY_BASIC_T1_FEATURES are not the right features supported by TJA1103 anymore. For example ethtool reports: [root@alarm ~]# ethtool end0 Settings for end0: Supported ports: [ TP ] Supported link modes: 100baseT1/Full 10baseT1L/Full 10baseT1L/Full is not supported by TJA1103 and supported ports list is not completed. The PHY also have a MII port. genphy_c45_pma_read_abilities implementation can detect the PHY features and they look like this. [root@alarm ~]# ethtool end0 Settings for end0: Supported ports: [ TP MII ] Supported link modes: 100baseT1/Full Supported pause frame use: Symmetric Supports auto-negotiation: No Supported FEC modes: Not reported Advertised link modes: 100baseT1/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: No Advertised FEC modes: Not reported Speed: 100Mb/s Duplex: Full Auto-negotiation: off master-slave cfg: forced master master-slave status: master Port: Twisted Pair PHYAD: 1 Transceiver: external MDI-X: Unknown Supports Wake-on: g Wake-on: d Link detected: yes SQI: 7/7 Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 162886cce08b..11fb5a4f47fb 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -1353,6 +1353,14 @@ static int nxp_c45_config_init(struct phy_device *phydev) return nxp_c45_start_op(phydev); } +static int nxp_c45_get_features(struct phy_device *phydev) +{ + linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, phydev->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, phydev->supported); + + return genphy_c45_pma_read_abilities(phydev); +} + static int nxp_c45_probe(struct phy_device *phydev) { struct nxp_c45_phy *priv; @@ -1507,7 +1515,7 @@ static struct phy_driver nxp_c45_driver[] = { { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103), .name = "NXP C45 TJA1103", - .features = PHY_BASIC_T1_FEATURES, + .get_features = nxp_c45_get_features, .driver_data = &tja1103_phy_data, .probe = nxp_c45_probe, .soft_reset = nxp_c45_soft_reset, From patchwork Tue Jun 27 07:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294121 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 8735E15AC3 for ; Tue, 27 Jun 2023 07:21:55 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2056.outbound.protection.outlook.com [40.107.6.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D9D2726; Tue, 27 Jun 2023 00:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eaiUMfRO/Zsyw+Jjk+pi1LxwPBZgds9AvvgZTB5cLJTCV1C9RyifhYZ41cjVNcKSrEgCrbNoAW4lPfOBFBJklYeHOLWKCoyvvcxmnYm4aWdU7aIvZJ9No0fOBaQzgeuO9Pccxl62edvWQONHZf5BlTDeCwh0nDFFQnz7aNhnvxuQQsmuIkzNjSVUU8qm+yeeF8cki+CKko32QxoVfNWieup231LrmfOiMD7sfcqFOstEfh+XXUmwyQMoHRUMy/TwLQIOgU9wDtV6+6YK+136goQ2nlCvVYXdspfU2nfVe6vSWaMpuPxwV84hy55VEhQhK7/MzBadPMXspYjJTS5uhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lgKnePFJq0TnZ0nhvn5vdN5BPu9wwPhwqUorfcxNVuQ=; b=PBqFdoSRZa6X9zKfMnbGnuUYH4CIffV4JFLgigw2eTZqptVhhfe684lEBY9sSkoEDRwB5RJmL30AAHZvYbDPZnebnv61l6HAT9a4kGNmq3Ywk0D/yynY2HpLtLYL/yQKCOrHwTqRIO1rSx1no7xqO6affB0knObfGQwFLoWtL/B4Fa8hBhxxrjz+pGQevoEYQcOPUS9Y5s6KzEIsNcMYLAOfOlMTaPGxNYjKNrH+NW7Y0EO01H2yrEup9wWqiqNdYIWvisOr9YEyoWMbPLQdrg6vkCOykfZkooYzUoBxZczWkLWzQzpbwHwtJcuWMJqxomgBWstmqHsUMTWWKrHvjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lgKnePFJq0TnZ0nhvn5vdN5BPu9wwPhwqUorfcxNVuQ=; b=A1S03DNA2dcsaEKb8jW9wH2tRmVImZMnbzyKU5MX8xishfst8yW3VaE1hyzIbCOyzH+T+SoTBK0Fc9x0KgnGWuX8OnyqBRVxWNe/AFAOP/XXv4Hj2FlKA1y3SnkEGwEONgLchUBcbwio80vPYE1guZlcfGqTZWkwSU1i2++7zpI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:19:59 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:19:59 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 06/12] net: phy: nxp-c45-tja11xx: add TJA1120 support Date: Tue, 27 Jun 2023 10:18:47 +0300 Message-Id: <20230627071853.106215-7-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 982ef01b-dc4c-4620-eb6f-08db76deea4e X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yTG7aMnXiZekGQ+CsY+13WEX8P9Q4nuxKYaiYwD4WkpvBIiO7aOnq1+F+Kmlz5T+r8aNw/x3QduzBGsNQPvnrgWsaVCT0YaETfN/4uRxHrEjpnpMj2nyyS/pDfdcgPWfKn9+0JnlvChGf8hwXNdeYsEU29b4t2M5A482IGdNuE9iJ1wuUlbH7XmO8IIXIaTibnHBI4AhE8qXFGvDc6nJi10nJjqnLRi82g+G1vpuDP28gGtk6+lM4JALqw6LNxmUCWPZpIYgOcYLg1NLYdwpMk9xtfOLB2lG3E2H8GMdaLLoM+xHDRH336iMUPPlJdJ4NTPZzIKUMCrZa3DJqniXeKB8A911/6dL/j4j0AvzvEHxs6siOnA/OQC/y5g7H9lbfsrPQUDyviqSMehrU9r1LgmaiA2nfsqG3Db9nXzWvJVKMv/8C64Z9+kAyMJILczMKeVvRJjR3TScBJd71t3SOt6mTTneup9IA+pwVQ1ETrLvn9ByevLnStqnPbYJFSoNFpXJaYoohgV8gL6pOEDtPpCc06e9HYHV3wgEnHva8y7VP513XE4JC8tVzVPTGNeEKBi8DP9+c9ihAi6krrYft1qMdkofPTVeFv6M0sTKjZ6s8PxSOE390+lwFnlKUv2Y X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(66574015)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gs2ba0LrfYeohBL1QyfrG1di4pfQGnNVZD1dzqEHJN0s7E7LKkcOOrnDmVteOvEhHmWntl5x8kIu8O2yrdFWUlA5xJgL/F8mlC53Mx5TDi9bGj+aXcvYa8jEntCyKANg4M0T8LKnLkkfhAeqxOvWoOWp9wXxocErU0aHuVUYSnB0uIYo2lJGjiraZUdXFPE1To3j/2s5OhsFwCt4Z6ocdB1ra49ZXfnYQ4Lu2tSTzVX0SKhpo0LyTPVrqjKkQwFp+iBOVZLhUPMLoN0NpPyzGI0yHyNd57Qab15Ai4P8zwv7zi5HS9mzxeykLb61Co6MHcY0rLJSc4aHG0OkFJwz3aQ2PH077/IVZu4VVWxC2OmfcFSsZgHYEzqza12WYQth2I3dK5NymQD7LF+X7uLmwsXeobvf6A0me+NtEnphgC4gbHzcBInhtddsy/OJmJIt7z8sGdoBrKD7Hnw1rxQGjgES4Spn3hf7UMvwdhknQsx1CxU65Jd4dK+wnUCfwCrNMed90pq8MDFZkDUmDr81CNTHI2FeHhfIkibN+UYuZw8Cd4V0KzmqiB5miG7n++PHUWdz718JgptYKRWTxGPV5H4txilPPQ4EGZ7glBfNluRPn+13THSxoM1tiZBH/kU1HQwhC8TPGb52memdJwtWHKtp4Z6mriQnrZzgPPYtSKKHzj09qdWCrZB9bEhQqu1d66IhONAmgeRiObSsdIRyCjx48nEJqkMmceJox+Q+IHZJZcEri8k+mlPHhVNJL6zWn2Dr6wVgpwG6brhUW+bD4URe/F/yeUH1U2KaLCzpzhiRykGYKGWtQZglAYPLuGFBKD+jTTo53eNy7/jnRk+w+I58wIqYyi+6ey6dkXUFzZhtcn77EAeL8C5ejB0j1V3lEBmiQil2wLnWCqFkQiXxP26DHbm7/cInLqhEnQlW2+EXgCLcIN+avIlM6aDNBhGKB9kK6u71RHXuTmP6T0V+SGs2UVi+2hx08+K0dZl3bNx7ydrKtWY5ooO9Ib4lytg7PKRUocOuE2l+3wrjTzXekIWle5VlAAdDAdleoCURCiwtxZlu4uTG/eqeSr2ih99U76FZlArvndHrnJgkgNK2kk66wa2ZNwtYft3B5+lNsijxQkG4B8UzG87eNO7Pg64OqT2n5p3gM5b3T/S0ARwMMG2k3oAPZnKINMnr1Bd17KDNtJzVmeecHYBqRKeFeeVBZUEZp0jI7GSiM5QVtUtiAACcDx0QCgfFiACDVuO3nJAjZNLo6wSCwUZoO9Ur0l6rxFq5izz8+ye95y7HsCOc8r22sFQwU2lCMDAiTa8tplmLlRSO6c6o16b9Fbn9+jIzdDAMuiyHu6bGU6rTd5InSwoSjX3RxM6t76JaF2zR7oDQytyx/p9gQI2B6Q3tsGIiqcKDq1y2iGbFtCHdIiskhvzRaZSPcgoEzOlf+iDxcxvFFVtROd3r55ZZV9iniPnclZ0WLj56z/p35QDk5PCsbbocViqI/gPYmWFPwuv/3WydhWTbSyfT0T+DNP8B/eOxnRY8WurlRfpQpUoqVhssMs14uD9QTecfeCgLvbnbLsUk5tYaTEYjQjfgZqeBvtjBDYrSO6Bv9wLL1Q7zfiTTbg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 982ef01b-dc4c-4620-eb6f-08db76deea4e X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:19:59.0657 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OSjHkBl8x5ArQoOfPil/CGcmX+f4ib66+mK8eaEO8yOiAuSFkWCmNC4kZd2mtj3JjK1Cs6eWKXHztQKGDDDJZKEBQdr4f9vBj50H8aVdXRw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-Patchwork-Delegate: kuba@kernel.org Add TJA1120 driver entry and its driver_data. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/nxp-c45-tja11xx.c | 159 ++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index a40269c17597..aaed6d73f9f5 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -300,7 +300,7 @@ config NXP_C45_TJA11XX_PHY depends on PTP_1588_CLOCK_OPTIONAL help Enable support for NXP C45 TJA11XX PHYs. - Currently supports only the TJA1103 PHY. + Currently supports the TJA1103 and TJA1120 PHYs. config NXP_TJA11XX_PHY tristate "NXP TJA11xx PHYs support" diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 11fb5a4f47fb..47decf2677e1 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -18,12 +18,17 @@ #include #define PHY_ID_TJA_1103 0x001BB010 +#define PHY_ID_TJA_1120 0x001BB031 #define VEND1_DEVICE_CONTROL 0x0040 #define DEVICE_CONTROL_RESET BIT(15) #define DEVICE_CONTROL_CONFIG_GLOBAL_EN BIT(14) #define DEVICE_CONTROL_CONFIG_ALL_EN BIT(13) +#define VEND1_DEVICE_CONFIG 0x0048 + +#define TJA1120_VEND1_EXT_TS_MODE 0x1012 + #define VEND1_PHY_IRQ_ACK 0x80A0 #define VEND1_PHY_IRQ_EN 0x80A1 #define VEND1_PHY_IRQ_STATUS 0x80A2 @@ -76,6 +81,14 @@ #define MII_BASIC_CONFIG_RMII 0x5 #define MII_BASIC_CONFIG_MII 0x4 +#define VEND1_SYMBOL_ERROR_CNT_XTD 0x8351 +#define EXTENDED_CNT_EN BIT(15) +#define VEND1_MONITOR_STATUS 0xAC80 +#define MONITOR_RESET BIT(15) +#define VEND1_MONITOR_CONFIG 0xAC86 +#define LOST_FRAMES_CNT_EN BIT(9) +#define ALL_FRAMES_CNT_EN BIT(8) + #define VEND1_SYMBOL_ERROR_COUNTER 0x8350 #define VEND1_LINK_DROP_COUNTER 0x8352 #define VEND1_LINK_LOSSES_AND_FAILURES 0x8353 @@ -94,6 +107,10 @@ #define VEND1_RX_TS_INSRT_CTRL 0x114D #define TJA1103_RX_TS_INSRT_MODE2 0x02 +#define TJA1120_RX_TS_INSRT_CTRL 0x9012 +#define TJA1120_RX_TS_INSRT_EN BIT(15) +#define TJA1120_TS_INSRT_MODE BIT(4) + #define VEND1_EGR_RING_DATA_0 0x114E #define VEND1_EGR_RING_CTRL 0x1154 @@ -110,6 +127,7 @@ #define PORT_PTP_CONTROL_BYPASS BIT(11) #define PTP_CLK_PERIOD_100BT1 15ULL +#define PTP_CLK_PERIOD_1000BT1 8ULL #define EVENT_MSG_FILT_ALL 0x0F #define EVENT_MSG_FILT_NONE 0x00 @@ -929,6 +947,27 @@ static const struct nxp_c45_phy_stats tja1103_hw_stats[] = { NXP_C45_REG_FIELD(0xAFD1, MDIO_MMD_VEND1, 0, 9), }, }; +static const struct nxp_c45_phy_stats tja1120_hw_stats[] = { + { "phy_symbol_error_cnt_ext", + NXP_C45_REG_FIELD(0x8351, MDIO_MMD_VEND1, 0, 14) }, + { "tx_frames_xtd", + NXP_C45_REG_FIELD(0xACA1, MDIO_MMD_VEND1, 0, 8), }, + { "tx_frames", + NXP_C45_REG_FIELD(0xACA0, MDIO_MMD_VEND1, 0, 16), }, + { "rx_frames_xtd", + NXP_C45_REG_FIELD(0xACA3, MDIO_MMD_VEND1, 0, 8), }, + { "rx_frames", + NXP_C45_REG_FIELD(0xACA2, MDIO_MMD_VEND1, 0, 16), }, + { "tx_lost_frames_xtd", + NXP_C45_REG_FIELD(0xACA5, MDIO_MMD_VEND1, 0, 8), }, + { "tx_lost_frames", + NXP_C45_REG_FIELD(0xACA4, MDIO_MMD_VEND1, 0, 16), }, + { "rx_lost_frames_xtd", + NXP_C45_REG_FIELD(0xACA7, MDIO_MMD_VEND1, 0, 8), }, + { "rx_lost_frames", + NXP_C45_REG_FIELD(0xACA6, MDIO_MMD_VEND1, 0, 16), }, +}; + static int nxp_c45_get_sset_count(struct phy_device *phydev) { const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev); @@ -1511,6 +1550,101 @@ static const struct nxp_c45_phy_data tja1103_phy_data = { .ptp_enable = tja1103_ptp_enable, }; +static void tja1120_counters_enable(struct phy_device *phydev) +{ + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_SYMBOL_ERROR_CNT_XTD, + EXTENDED_CNT_EN); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_MONITOR_STATUS, + MONITOR_RESET); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_MONITOR_CONFIG, + ALL_FRAMES_CNT_EN | LOST_FRAMES_CNT_EN); +} + +static void tja1120_ptp_init(struct phy_device *phydev) +{ + phy_write_mmd(phydev, MDIO_MMD_VEND1, TJA1120_RX_TS_INSRT_CTRL, + TJA1120_RX_TS_INSRT_EN | TJA1120_TS_INSRT_MODE); + phy_write_mmd(phydev, MDIO_MMD_VEND1, TJA1120_VEND1_EXT_TS_MODE, + TJA1120_TS_INSRT_MODE); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_DEVICE_CONFIG, + PTP_ENABLE); +} + +static void tja1120_ptp_enable(struct phy_device *phydev, bool enable) +{ + if (enable) + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_ENABLES, + PTP_ENABLE); + else + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_ENABLES, + PTP_ENABLE); +} + +static const struct nxp_c45_regmap tja1120_regmap = { + .vend1_ptp_clk_period = 0x1020, + .vend1_event_msg_filt = 0x9010, + .pps_enable = + NXP_C45_REG_FIELD(0x1006, MDIO_MMD_VEND1, 4, 1), + .pps_polarity = + NXP_C45_REG_FIELD(0x1006, MDIO_MMD_VEND1, 5, 1), + .ltc_lock_ctrl = + NXP_C45_REG_FIELD(0x1006, MDIO_MMD_VEND1, 2, 1), + .ltc_read = + NXP_C45_REG_FIELD(0x1000, MDIO_MMD_VEND1, 1, 1), + .ltc_write = + NXP_C45_REG_FIELD(0x1000, MDIO_MMD_VEND1, 2, 1), + .vend1_ltc_wr_nsec_0 = 0x1040, + .vend1_ltc_wr_nsec_1 = 0x1041, + .vend1_ltc_wr_sec_0 = 0x1042, + .vend1_ltc_wr_sec_1 = 0x1043, + .vend1_ltc_rd_nsec_0 = 0x1048, + .vend1_ltc_rd_nsec_1 = 0x1049, + .vend1_ltc_rd_sec_0 = 0x104A, + .vend1_ltc_rd_sec_1 = 0x104B, + .vend1_rate_adj_subns_0 = 0x1030, + .vend1_rate_adj_subns_1 = 0x1031, + .irq_egr_ts_en = + NXP_C45_REG_FIELD(0x900A, MDIO_MMD_VEND1, 1, 1), + .irq_egr_ts_status = + NXP_C45_REG_FIELD(0x900C, MDIO_MMD_VEND1, 1, 1), + .domain_number = + NXP_C45_REG_FIELD(0x9061, MDIO_MMD_VEND1, 8, 8), + .msg_type = + NXP_C45_REG_FIELD(0x9061, MDIO_MMD_VEND1, 4, 4), + .sequence_id = + NXP_C45_REG_FIELD(0x9062, MDIO_MMD_VEND1, 0, 16), + .sec_1_0 = + NXP_C45_REG_FIELD(0x9065, MDIO_MMD_VEND1, 0, 2), + .sec_4_2 = + NXP_C45_REG_FIELD(0x9065, MDIO_MMD_VEND1, 2, 3), + .nsec_15_0 = + NXP_C45_REG_FIELD(0x9063, MDIO_MMD_VEND1, 0, 16), + .nsec_29_16 = + NXP_C45_REG_FIELD(0x9064, MDIO_MMD_VEND1, 0, 14), + .vend1_ext_trg_data_0 = 0x1071, + .vend1_ext_trg_data_1 = 0x1072, + .vend1_ext_trg_data_2 = 0x1073, + .vend1_ext_trg_data_3 = 0x1074, + .vend1_ext_trg_ctrl = 0x1075, + .cable_test = 0x8360, + .cable_test_valid = + NXP_C45_REG_FIELD(0x8361, MDIO_MMD_VEND1, 15, 1), + .cable_test_result = + NXP_C45_REG_FIELD(0x8361, MDIO_MMD_VEND1, 0, 3), +}; + +static const struct nxp_c45_phy_data tja1120_phy_data = { + .regmap = &tja1120_regmap, + .stats = tja1120_hw_stats, + .n_stats = ARRAY_SIZE(tja1120_hw_stats), + .ptp_clk_period = PTP_CLK_PERIOD_1000BT1, + .counters_enable = tja1120_counters_enable, + .ptp_init = tja1120_ptp_init, + .ptp_enable = tja1120_ptp_enable, +}; + static struct phy_driver nxp_c45_driver[] = { { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103), @@ -1536,12 +1670,37 @@ static struct phy_driver nxp_c45_driver[] = { .get_sqi_max = nxp_c45_get_sqi_max, .remove = nxp_c45_remove, }, + { + PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120), + .name = "NXP C45 TJA1120", + .get_features = nxp_c45_get_features, + .driver_data = &tja1120_phy_data, + .probe = nxp_c45_probe, + .soft_reset = nxp_c45_soft_reset, + .config_aneg = genphy_c45_config_aneg, + .config_init = nxp_c45_config_init, + .config_intr = nxp_c45_config_intr, + .handle_interrupt = nxp_c45_handle_interrupt, + .read_status = genphy_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = genphy_c45_pma_resume, + .get_sset_count = nxp_c45_get_sset_count, + .get_strings = nxp_c45_get_strings, + .get_stats = nxp_c45_get_stats, + .cable_test_start = nxp_c45_cable_test_start, + .cable_test_get_status = nxp_c45_cable_test_get_status, + .set_loopback = genphy_c45_loopback, + .get_sqi = nxp_c45_get_sqi, + .get_sqi_max = nxp_c45_get_sqi_max, + .remove = nxp_c45_remove, + }, }; module_phy_driver(nxp_c45_driver); static struct mdio_device_id __maybe_unused nxp_c45_tbl[] = { { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103) }, + { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120) }, { /*sentinel*/ }, }; From patchwork Tue Jun 27 07:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294122 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 845A263AE for ; Tue, 27 Jun 2023 07:22:02 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 417CA2D7E; Tue, 27 Jun 2023 00:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4vqLekDfPz2xiWGPVPgFtUCksXFF8cRjUCg5LB1mbEycgJbfj5t/E5Jc0PovZLdWQVwJU+jCrZNhr7x9ras3iiFQb+T4EUS8LZbEo1Jm6lQFFlkd07hid3q5pbXRQ0xuShQIWyYeyEQ+48bXJ1ewZhdk1E6VKDaoE3IoyouZR1/lyx9P3g9uydB7KZUwgO6NEL83ypNrHrh9vnpE2ySzVEs0+KmVLEX9dmFjdSy8m+FH/Yp4LF6jMUZ0Nyi7Uoj3XeQ4TxkP4NXdhLP0jBpsOnBDSQZsxeBEy9OOf54Cth/LM1V2G2aT5KsXu5YKcvq4lEq+babXWWRhv7pRdvKrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=caG9w6+mScE8FYg4vaj8ykQMxUOnnCtAPYAtgRzJuas=; b=d/udJMPUnt1j8fsRhmsdjCxA9P5K/ctE/MxSdZLGiMbOAIS78W4+8l6LH44/OPIKaeVvBOSnbdas9vMEc2Xft/4kWcZg9yZlOdkTdr3lNvbFrS5V2lYnHeUtx65UpwZhfKqdNEKFvopqJ+v4oOkLAAiHeTQkxwiCNno0aP5xcDio3rcv1LKB53avedYW/gEiv8TEdBnfR8SzZm09/KQRfiQEypnKhBmNwlgGpavU69a2ElaRYi6DmhLG3taYRf4i7v5TJD6KTGowARwSaBb2BLla0Ao3xUGFHAgbVVYSD16ebBuIHo0ZyJZaCvqTFyV9XUvrSFvTO6yHCsh0GDPAeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=caG9w6+mScE8FYg4vaj8ykQMxUOnnCtAPYAtgRzJuas=; b=IGKZGMxRS7GW0UPcF0UeAc490CMtOUFTxi6yrDs5t4WxN4FfoNqRgCaIRlQaXMbSEjDQMzbCAf4QK0oLYJ1t2UxgCylUmI5xTBTtsK/P0DOMKbE9nn0RPLBaSp/AjLIeNJAFeqqbSkNvdhYUOFnvldLFvEBcbyOWiyGZdgLsygA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:00 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:00 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 07/12] net: phy: nxp-c45-tja11xx: enable LTC sampling on both ext_ts edges Date: Tue, 27 Jun 2023 10:18:48 +0300 Message-Id: <20230627071853.106215-8-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: fc3d71f6-7022-46b8-a1a5-08db76deeaee X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I0P4vmTNNxfPugbieYm3rlgwdceHgWKscxesnQZoiCgWX/wXNT3AFETQgsgqU5Iidbq258HAIbecnpZfeuHz+6Qm5O3tAf2MykdbK7J2XtkEc7I2iMiLqMLX5kt2UHrGSRLHyPVmfBavslPEs8WN2d1i0KhXKnZAE1sqkN9Njy3tgGNsKRERphCsCvQTqWUjDLXTJkJFKd0Dwb9//lqcD4lCLMAWzmJ1Vb9ERVON4xRiCKAm2qFsT8ln57vn+7sMjur42uns5R6ibPXqEVTQeKIyyfTncFfzXPs/aE/l633RrwqqwmHfI4OCUOdILTxd1G58BZAlwrUlps47GHZ/P3GIYJUptnhOQFmVX+BGsriSlXMvIgTnL9JX8PymDu3q+C0os9OA9jyAmUwnGAxShXuoKRoRuKvWGKMgQtb3bpU5CEhilWkk+FMf3Y7mrzRXmcNaKsbyDoIuwGY9ASc3yc68wml4ekTkNIiBwuXLBe6U7u3NM6sOZipC2uvh8e3k144EqyMHE2kUD0huHfwI+7Xfkz8C0goy3pUZQ5C7pkT99cis5zP1ayVhs/ouh/ZCDx5WNGeq2WOYEqcLngf94ocbHGekTid9czM+oPm0qsf+j6dWRAis5097u3ux+108 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(66574015)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EhGbX3PyJHMsPhman47wiqc2/8JbUjshErPNJvDRhcy/BmtZKl8Cbjei6PmndXYZh3hFVsDLKAcVgFUyp2QEY7MnesM/LRzPwzjkLPaHje0zpGGXK1PPPvBmYZne0BIcVrDhCXxOPLkuQn0rr8qg2+N3KMTSz5YfGmJpDUJDyCwnF/EvkliN+H8p1vYtCrgcRVhXUg3X4tEZGbPlVVfcpii6J3cT9cZN7VFUl53x9EvdMatqIisPDvgUB9QPqZPef+4N2sXlADpbV0hP8hTpQ2lvjyt3Gm8+5DCR6KY1lC8yQ7M7YF5nh3MNHMQZWRfEcto4OZTIBhFZqiT6vr6ln+CG5EZQQqS5z8Op8Ace7DVIhHUgc3QgrKJbUCyE/A9OL/mX2dIF23ncmlrNNnH7b9VHkULbZf8Ui6bG2uqrKJ1+IrhxQBBBU+81TZaA8tRoNMfuWdxQrVCr6o9kIQXaeZiwjKgNvaIEVrJghfBbfbOeeT8f63P3k7s6/lhDMn8Xk81sMDAbTl8J3sn3Y1pjQZ3ABco6BuqJsa4nS/gqKoyqtvEm0H2SHqFee2hu5HiUNnNWyOSzOBcPL6Pf1cn9/OKZ+Z8y69fE0UUWF1BegvUN/BDjOdTNvbhjVfNr3F+4a9lA2SaTu6cSCqZeeHGs3e0AsZ3lJ//OGkJ6qL7uG+K8zLAX8H6RYn6wMECe08rwHngznc2OMZf4w+zVLn7uzqASXK0PEul/e3f8v9U01XJGoi5nw2B31COz6k+xKv/sLgDWlc9FWHBCPCwUiw27Fj2uUsK0+CU/7duGvjdfdL1mt2k94pL7Ual9NkQETkRcYQDuuL6+43pRGLbYJpUdgWv4vIeDR8F/uQ4W2FSIbFiBs5LHjDGGk+pB3hcJRy2/9ZBSz6OE04mEM8lp4WpFOyPNd/V9ALnYiYehPnva5cQt1uCvoS6hzNZZdpGnKESF2L/EAMSZMJsdbAc/q3+ReLQpSEZztezHoIiDLrFbyOlc11Zq8/WfEaGGTtNDaS8pcS3caBuzUuUMraTOdGZfOjY+xIhOXQrabooWZtrXVzKgMEOwBM7Qh+oLFCn1NqgAsxiZLzPRWy2H0hpvHuL9Pb0P6gesLlzSINtVjnECf4CiL3wv1Lx0mx9AxKcdnHadgCrm4W9FC3InzHgA3FGCB5gIFRRGhSg5za8o5o81gQMeUNQ9fM8sqbnmIyvyRHeSQmKsN3VcMmpGJgSDeEzCeYKDqgcIEK+dys170xDXZEJqGEFtZqYgiEOcqQfQZAqWokv2rGybM/UPRg8v50DcOz+VYiAc/bd5DuKSHe2BYr5PS2ZvnoFTG/gRpIcNpFRURReP5Vp02knaV+gRc564YrQbj8rQbTWA8QksCucxpVPuwhbbjn4b5tdneIyHy/lwmiN+Ftu/0YiYoheWEVKKjGNa7eIuK9c4dYxzf21g62y2T1lPSB2hyZL8Jo+XEJ2PZHVPabNPDQ5M4ELJHxFJl57WYHjqXJtFaX3/eazYE30S3bhfslIZvxfAUGOhIidIjCsG2685K0j+6Svm0EBocuobMPTpbVkL/n3Ib+LM0jt7Sf572A1uEoUZD5eQSE20eHOaeAJBz+4qGtxovT4RNQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc3d71f6-7022-46b8-a1a5-08db76deeaee X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:00.1508 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gmYuzr8osoW1dPzRRQOJltVoYGpyb30i2iKy7SApnZ8GM4C6MpUFH6afDd5uND80rbxNbhAYCtzn/dJn4UP2VozSdWV/PAFUiVwbphJhHhk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The external trigger configuration for TJA1120 has changed. The PHY supports sampling of the LTC on rising and on falling edge. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 60 ++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 47decf2677e1..62be1712167e 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -101,6 +101,10 @@ #define VEND1_PTP_CONFIG 0x1102 #define EXT_TRG_EDGE BIT(1) +#define TJA1120_SYNC_TRIG_FILTER 0x1010 +#define PTP_TRIG_RISE_TS BIT(3) +#define PTP_TRIG_FALLING_TS BIT(2) + #define CLK_RATE_ADJ_LD BIT(15) #define CLK_RATE_ADJ_DIR BIT(14) @@ -238,6 +242,7 @@ struct nxp_c45_phy_data { const struct nxp_c45_phy_stats *stats; int n_stats; u8 ptp_clk_period; + bool ext_ts_both_edges; void (*counters_enable)(struct phy_device *phydev); void (*ptp_init)(struct phy_device *phydev); void (*ptp_enable)(struct phy_device *phydev, bool enable); @@ -684,9 +689,48 @@ static int nxp_c45_perout_enable(struct nxp_c45_phy *priv, return 0; } +static void nxp_c45_set_rising_or_falling(struct phy_device *phydev, + struct ptp_extts_request *extts) +{ + if (extts->flags & PTP_RISING_EDGE) + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PTP_CONFIG, EXT_TRG_EDGE); + + if (extts->flags & PTP_FALLING_EDGE) + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PTP_CONFIG, EXT_TRG_EDGE); +} + +static void nxp_c45_set_rising_and_falling(struct phy_device *phydev, + struct ptp_extts_request *extts) +{ + /* PTP_EXTTS_REQUEST may have only the PTP_ENABLE_FEATURE flag set. In + * this case external ts will be enabled on rising edge. + */ + if (extts->flags & PTP_RISING_EDGE || + extts->flags == PTP_ENABLE_FEATURE) + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_SYNC_TRIG_FILTER, + PTP_TRIG_RISE_TS); + else + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_SYNC_TRIG_FILTER, + PTP_TRIG_RISE_TS); + + if (extts->flags & PTP_FALLING_EDGE) + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_SYNC_TRIG_FILTER, + PTP_TRIG_FALLING_TS); + else + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_SYNC_TRIG_FILTER, + PTP_TRIG_FALLING_TS); +} + static int nxp_c45_extts_enable(struct nxp_c45_phy *priv, struct ptp_extts_request *extts, int on) { + const struct nxp_c45_phy_data *data = nxp_c45_get_data(priv->phydev); int pin; if (extts->flags & ~(PTP_ENABLE_FEATURE | @@ -697,7 +741,8 @@ static int nxp_c45_extts_enable(struct nxp_c45_phy *priv, /* Sampling on both edges is not supported */ if ((extts->flags & PTP_RISING_EDGE) && - (extts->flags & PTP_FALLING_EDGE)) + (extts->flags & PTP_FALLING_EDGE) && + !data->ext_ts_both_edges) return -EOPNOTSUPP; pin = ptp_find_pin(priv->ptp_clock, PTP_PF_EXTTS, extts->index); @@ -711,13 +756,10 @@ static int nxp_c45_extts_enable(struct nxp_c45_phy *priv, return 0; } - if (extts->flags & PTP_RISING_EDGE) - phy_clear_bits_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_PTP_CONFIG, EXT_TRG_EDGE); - - if (extts->flags & PTP_FALLING_EDGE) - phy_set_bits_mmd(priv->phydev, MDIO_MMD_VEND1, - VEND1_PTP_CONFIG, EXT_TRG_EDGE); + if (data->ext_ts_both_edges) + nxp_c45_set_rising_and_falling(priv->phydev, extts); + else + nxp_c45_set_rising_or_falling(priv->phydev, extts); nxp_c45_gpio_config(priv, pin, GPIO_EXTTS_OUT_CFG); priv->extts = true; @@ -1545,6 +1587,7 @@ static const struct nxp_c45_phy_data tja1103_phy_data = { .stats = tja1103_hw_stats, .n_stats = ARRAY_SIZE(tja1103_hw_stats), .ptp_clk_period = PTP_CLK_PERIOD_100BT1, + .ext_ts_both_edges = false, .counters_enable = tja1103_counters_enable, .ptp_init = tja1103_ptp_init, .ptp_enable = tja1103_ptp_enable, @@ -1640,6 +1683,7 @@ static const struct nxp_c45_phy_data tja1120_phy_data = { .stats = tja1120_hw_stats, .n_stats = ARRAY_SIZE(tja1120_hw_stats), .ptp_clk_period = PTP_CLK_PERIOD_1000BT1, + .ext_ts_both_edges = true, .counters_enable = tja1120_counters_enable, .ptp_init = tja1120_ptp_init, .ptp_enable = tja1120_ptp_enable, From patchwork Tue Jun 27 07:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294123 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 340B7846A for ; Tue, 27 Jun 2023 07:22:05 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB76D2735; Tue, 27 Jun 2023 00:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FaZDL8L1oqYiVjkuqv8iLIUPG42JhkOL8eybJJzgcX8M79HFxh5GRtESE1kcZnJKsNBQL8ZVsP5dKqf9CuoVLMFvlc5AfBrgQY8Kawqnoj2wY4Jkw45UgDK818ZT3DFvSaRo6iOAl8++SjMNoFwV8fPQK7CkvubNA0YBZ1kunjur9GayIm0zp4XsvKwTkYR9Ge1ZSt+4llSXfQqeA8W7uG49lUwnAMY354eCMPBL7wVg8v6/vA8QBh373u/hNjx/DRVBkI0vfk8oiflst/U0XcchAFO2QFjx/93zUBoo9wx0KJBXUmGbhmjq2nYLZ0BhLyw+covFhnuC6uB2Vi2P5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p9ZhOVvXQBX6vcdkyDC66zUtGeo3HwWNDGX91SbU7eA=; b=DaSWGSFDXWqdX8oVsnt9f+gb8k8oCW4T4ToOEITMCBsT7uhfN9sHhg5eVE9G6c9wY2fotXOFAsuP9z7ARNQ99SXd3iQCdXxSWh2OczPGvCf9UgvNFvbvX8TnYzu5KqWjQ2FhuDdMwN1CJXULO/RWw6BRH+5cUsCUJkqB1XU1kALu1vF1XosEDGcq6tIsNe3F/+KDzAT+pj+x7yXwXn2giCYv5wKqgLsvwyJtNMjpLEEP8c91a3jmRdoCKHAtjuM+0raOwvYdmvCYximoNisX+3R2zYiOBm59ak49J0lhtKpE4wGEfMBD8CF9kfEWHpWbXKUlE/cagvsLwAf7U42odQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p9ZhOVvXQBX6vcdkyDC66zUtGeo3HwWNDGX91SbU7eA=; b=klXOurrvjOBsDOuw/mfLkPIbVYSEx7VL/eeCXXhnGPplMz5ZTXbdtKaYfKtJj7lYl6XgSxHwpvrMHLAsTVEs81BhkCR58Ky/yIZh5YxxoZssTu7Eqp9FxlewZhpBo2z3n3YtLouZXynJcJto+omKJVsQJLZG0ucRio6rp9SVAhw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:01 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:01 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 08/12] net: phy: nxp-c45-tja11xx: read egress ts on TJA1120 Date: Tue, 27 Jun 2023 10:18:49 +0300 Message-Id: <20230627071853.106215-9-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: a547a8e6-e57e-45df-b9fe-08db76deeb90 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RdkX/5KjlTqXFrmWQfiO0SM93MA/r8LSp7eI2MGpsDYJGgrqDw4wAf9bgaHkl7R0x+L7jXDrjHs9f3l5oUKo74SisATt2DvXlr5YN/KTI9Ky21fzp/2MJD9b/48I38FwkXuH9U4bAK/YQWmjxG5ZUMQzMkCJo3nWiVGfslVOe2OMLrFUUFFHOjFxfaUfPjT6R0WU38hGghnW3NBEHLs4hML7FbPVt/3ts4shumL2UbuLx969KCT9nngEgKE61Rn8izzodtcuXyDAPj0xnfImVs6h+kv8eez1VKYl88UrKG0z4ujF6oO64reCm6YWAPwMmSCLbXOuAGN/7ynWmRm/eSQPdZSPc7OlDwuGNGtSr8yJaL6o4/5Ic3eK8tUB4QyV8cIQWN0XLiZxqrrcpn9328Y2YjJSGl8T8rmd5sjB5oJp1tHbcFPbwl815DF/e9tOI5nBMo1xsiwPp5/WTdCPwd9RH+tJrcCGWryXmAyRFHHpJTfPsnpONYQqkjPY6Vsc7yWVI/D7dk00Y6cpS6iOv6EKoq+vlVmT2OCrcsnb8ZEmW23NSLqTpIuocAiiFmI2uzYwBE4uhdbGdpEY1u28rDfWe6BxOz2jGTIkmzWgylvC6aWGVJtVZY+64bm7qjiO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WZLOMBEpI+n+HUkORrjdYgoTl34At+4NhB1tl9d++NhblNIBFhPYAGB9EOLXpywbXE7ZSHGZd+auqJuvMoz6jPn/RH8allarku1qdsazUy2HPnLa7FwfpZUFrkyLxFpZbdZLFOHYsAfTRqmZYGI8Ps7EmAXJBrG0PSnoL+hOeQjTfQS/4HX6QXmSCihw8cqydqPf5dL0L2HkfY9TZKHjM2orv2NkXzrTy8ZQg0BUMvFoVl9TTrL+mJeunzIN8AlJbe6TLPcS9sOre8l6F7mcwUCaBWQE507YlcCd46ELN92yiAU+zakjCpe5/MdO3pj/829FdLn8qh2C8FfsScjiUWjNlpFolVQJIhhoxO81ULErL84sB0WTYoVCmTw6AVZgTlC6XuVn1ck22WSs6/Rbb8bgSH8iC1KEeLmUnTZ10pJGoJTWicHB925zulK/gZpx4X+mJNttDmInZokDeG6hQ0yHCt+KbMYtbuopvJCcSVmVHyqPv26QsgLncVXmbsjRI6HrHQ4j7Z9cru2BYl1mBfbApWg04jLo1R9gb1xjGpmI7J9jY6ldUB6zbH/trvEvE7mgfSCdkWF72L6eD17sEHIXft4XRRaz7445Y7r4UGCMq2qeCAzvhCq3CWzZS/DveqNVcah2XxtdLceVXV+fYDsRhOtLVqTJFd98OIuexFIlYZxbZhhsKYuaI5sOPG0plF8dNdf+lsoHaxoQpWBuSHTb44inZqOQGitlI1GIR0gXd95RYHTdf2ot2IH6wLh6W82i08/qzPle8Ol+xWfNHFfiYYw3v6P6hjiwMhBYJaLVC250gdlP0yNqg/znHTyidCDCu9QqIJb5jqJKbvxChr0kSpQZLMJuLAytOngZODCVB9w8kzRIsGqRRCfkEdbdPx6iFP9rATijC343REpwO/q3bSvNWJ+aFKK2AGjqKDDS4jTa07OLc9AmtEmw9gdDkKxHwgeC4uhyDU8g72kKV/HL4HYNw44NcZIQwseWkT/nf7zABo9gFGkAvo9XpBo4slBV3hBjD5l7dxy4a0/gyv70xqnwbrM0Fhm1rok/cHpD4RuYz/Wpz3neUCcsHJ5BskTMUrtcTLvwCuQCWoXIjRwGyREZd8QIoa1dSUN8Idp0NZtTObsCxHh4joyAaDcjBXuDb0oQFH9ZNm5gGTgntbuCRtts1MLvwljeEVuR4UzKXPQVCRH/SklgIdLK7SpIluuypQaDieuXwcZuVkdR6Ww/nqcD3rDyiv68uzR7fY8fy3gFOEpoMZ8H/Ss1THx4qM0AdUPprRUTfwdJT46j5B7gbjtr9CiloFW2FsGoo36RyRrPkqdoXe6yhZVYXMXQ0TcT8/+G7gOdHZe1TVsRlyLMSew9X442WZ8vzWyk9j6L+h/iM0DMWGd9o0Uz13e9LUMOFy/X8AXDBScKhCrRZHc5DuVUIQGP+z73f2JWsiedmMjhh8+s34Gw8OvhS2TaDMdZPY1jp5E/gTTX60kiNs5Khg5b2gACTncjpHuwSqAsb5Hi9HzwWTOQEEPRrzNyfNfLyRn07LGW1oUIdy6DbYPKuIenLpOYxN7WnlzbEFy+mB0Ev7w/8qknFPWGRmWylRoZraQasZm0BotHdtGPng== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a547a8e6-e57e-45df-b9fe-08db76deeb90 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:01.1477 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UGZ4CyBUoQSo3G7sum/0/dizO66p8x6Xiso5wZTHQJ4vMS8wMRUV9jB40bCxIz9K9Eo+CiadsWkMHZXgRMs0kJD4ctloQPe3AR6z7ejNQYI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 X-Patchwork-Delegate: kuba@kernel.org The egress timestamp FIFO/circular buffer work different on TJA1120 than TJA1103. For TJA1103 the new timestamp should be manually moved from the FIFO to the hardware buffer before checking if the timestamp is valid. For TJA1120 the hardware will move automatically the new timestamp from the FIFO to the buffer and the user should check the valid bit, read the timestamp and unlock the buffer by writing any of the buffer registers(which are read only). Another change for the TJA1120 is the behaviour of the EGR TS IRQ bit. This bit was a self-clear bit for TJA1103, but now should be cleared before reading the timestamp. Signed-off-by: Radu Pirea (NXP OSS) --- drivers/net/phy/nxp-c45-tja11xx.c | 110 +++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 62be1712167e..0567a366af37 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -29,6 +29,11 @@ #define TJA1120_VEND1_EXT_TS_MODE 0x1012 +#define TJA1120_EGRESS_TS_DATA_S 0x9060 +#define TJA1120_EGRESS_TS_END 0x9067 +#define TJA1120_TS_VALID BIT(0) +#define TJA1120_MORE_TS BIT(15) + #define VEND1_PHY_IRQ_ACK 0x80A0 #define VEND1_PHY_IRQ_EN 0x80A1 #define VEND1_PHY_IRQ_STATUS 0x80A2 @@ -59,6 +64,12 @@ #define VEND1_PORT_ABILITIES 0x8046 #define PTP_ABILITY BIT(3) +#define VEND1_PORT_FUNC_IRQ_EN 0x807A +#define PTP_IRQS BIT(3) + +#define VEND1_PTP_IRQ_ACK 0x9008 +#define EGR_TS_IRQ BIT(1) + #define VEND1_PORT_INFRA_CONTROL 0xAC00 #define PORT_INFRA_CONTROL_EN BIT(14) @@ -158,6 +169,8 @@ #define NXP_C45_SKB_CB(skb) ((struct nxp_c45_skb_cb *)(skb)->cb) +struct nxp_c45_phy; + struct nxp_c45_skb_cb { struct ptp_header *header; unsigned int type; @@ -243,7 +256,10 @@ struct nxp_c45_phy_data { int n_stats; u8 ptp_clk_period; bool ext_ts_both_edges; + bool ack_ptp_irq; void (*counters_enable)(struct phy_device *phydev); + bool (*get_egressts)(struct nxp_c45_phy *priv, + struct nxp_c45_hwts *hwts); void (*ptp_init)(struct phy_device *phydev); void (*ptp_enable)(struct phy_device *phydev, bool enable); }; @@ -499,21 +515,11 @@ static void nxp_c45_get_extts(struct nxp_c45_phy *priv, regmap->vend1_ext_trg_ctrl, RING_DONE); } -static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv, - struct nxp_c45_hwts *hwts) +static void nxp_c45_read_egress_ts(struct nxp_c45_phy *priv, + struct nxp_c45_hwts *hwts) { const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); struct phy_device *phydev = priv->phydev; - bool valid; - u16 reg; - - mutex_lock(&priv->ptp_lock); - phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_CTRL, - RING_DONE); - reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_DATA_0); - valid = !!(reg & RING_DATA_0_TS_VALID); - if (!valid) - goto nxp_c45_get_hwtxts_out; hwts->domain_number = nxp_c45_read_reg_field(phydev, ®map->domain_number); @@ -527,12 +533,72 @@ static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv, nxp_c45_read_reg_field(phydev, ®map->nsec_29_16) << 16; hwts->sec = nxp_c45_read_reg_field(phydev, ®map->sec_1_0); hwts->sec |= nxp_c45_read_reg_field(phydev, ®map->sec_4_2) << 2; +} + +static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv, + struct nxp_c45_hwts *hwts) +{ + bool valid; + u16 reg; + mutex_lock(&priv->ptp_lock); + phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_CTRL, + RING_DONE); + reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_DATA_0); + valid = !!(reg & RING_DATA_0_TS_VALID); + if (!valid) + goto nxp_c45_get_hwtxts_out; + + nxp_c45_read_egress_ts(priv, hwts); nxp_c45_get_hwtxts_out: mutex_unlock(&priv->ptp_lock); return valid; } +static bool tja1120_egress_ts_is_valid(struct phy_device *phydev) +{ + bool valid; + u16 reg; + + reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_DATA_S); + valid = !!(reg & TJA1120_TS_VALID); + + return valid; +} + +static bool tja1120_get_hwtxts(struct nxp_c45_phy *priv, + struct nxp_c45_hwts *hwts) +{ + struct phy_device *phydev = priv->phydev; + bool more_ts; + bool valid; + u16 reg; + + mutex_lock(&priv->ptp_lock); + reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_END); + more_ts = !!(reg & TJA1120_MORE_TS); + valid = tja1120_egress_ts_is_valid(phydev); + if (!valid) { + if (!more_ts) + goto tja1120_get_hwtxts_out; + + /* Bug workaround for TJA1120 engineering samples: move the + * new timestamp from the FIFO to the buffer. + */ + phy_write_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_EGRESS_TS_END, TJA1120_TS_VALID); + valid = tja1120_egress_ts_is_valid(phydev); + if (!valid) + goto tja1120_get_hwtxts_out; + } + nxp_c45_read_egress_ts(priv, hwts); + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_DATA_S, + TJA1120_TS_VALID); +tja1120_get_hwtxts_out: + mutex_unlock(&priv->ptp_lock); + return valid; +} + static void nxp_c45_process_txts(struct nxp_c45_phy *priv, struct nxp_c45_hwts *txts) { @@ -571,6 +637,7 @@ static void nxp_c45_process_txts(struct nxp_c45_phy *priv, static long nxp_c45_do_aux_work(struct ptp_clock_info *ptp) { struct nxp_c45_phy *priv = container_of(ptp, struct nxp_c45_phy, caps); + const struct nxp_c45_phy_data *data = nxp_c45_get_data(priv->phydev); bool poll_txts = nxp_c45_poll_txts(priv->phydev); struct skb_shared_hwtstamps *shhwtstamps_rx; struct ptp_clock_event event; @@ -582,7 +649,7 @@ static long nxp_c45_do_aux_work(struct ptp_clock_info *ptp) u32 ts_raw; while (!skb_queue_empty_lockless(&priv->tx_queue) && poll_txts) { - txts_valid = nxp_c45_get_hwtxts(priv, &hwts); + txts_valid = data->get_egressts(priv, &hwts); if (unlikely(!txts_valid)) { /* Still more skbs in the queue */ reschedule = true; @@ -1111,13 +1178,16 @@ static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) ret = IRQ_HANDLED; } - /* There is no need for ACK. - * The irq signal will be asserted until the EGR TS FIFO will be - * emptied. - */ irq = nxp_c45_read_reg_field(phydev, &data->regmap->irq_egr_ts_status); if (irq) { - while (nxp_c45_get_hwtxts(priv, &hwts)) + /* If ack_ptp_irq is false, the IRQ bit is self-clear and will + * be cleared when the EGR TS FIFO is empty. Otherwise, the + * IRQ bit should be cleared before reading the timestamp, + */ + if (data->ack_ptp_irq) + phy_write_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PTP_IRQ_ACK, EGR_TS_IRQ); + while (data->get_egressts(priv, &hwts)) nxp_c45_process_txts(priv, &hwts); ret = IRQ_HANDLED; @@ -1588,7 +1658,9 @@ static const struct nxp_c45_phy_data tja1103_phy_data = { .n_stats = ARRAY_SIZE(tja1103_hw_stats), .ptp_clk_period = PTP_CLK_PERIOD_100BT1, .ext_ts_both_edges = false, + .ack_ptp_irq = false, .counters_enable = tja1103_counters_enable, + .get_egressts = nxp_c45_get_hwtxts, .ptp_init = tja1103_ptp_init, .ptp_enable = tja1103_ptp_enable, }; @@ -1684,7 +1756,9 @@ static const struct nxp_c45_phy_data tja1120_phy_data = { .n_stats = ARRAY_SIZE(tja1120_hw_stats), .ptp_clk_period = PTP_CLK_PERIOD_1000BT1, .ext_ts_both_edges = true, + .ack_ptp_irq = true, .counters_enable = tja1120_counters_enable, + .get_egressts = tja1120_get_hwtxts, .ptp_init = tja1120_ptp_init, .ptp_enable = tja1120_ptp_enable, }; From patchwork Tue Jun 27 07:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294124 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 ACA3763AE for ; Tue, 27 Jun 2023 07:22:14 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1a::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1E7E297B; Tue, 27 Jun 2023 00:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MqPjHKntaAWgk2A1YefeBpbv0RXFnDtx0pbHTWHwot0EaQrzfXdkWHukivpDN8jBha7s3HZJpijecG+6f5a5wiLu2dL9v7BE7Zvx92V5mGnWqLtSSiKM98MtRyEEqKbJ5Pw0LTxm5BF47mn4g598opxN/U3QmK4gj+3dQ/nqc9rDPWI0KD6tPM+WN2vZicALn2+s7vU+B8pEcFlmZh8uG8sToc95XDys0pbl4U8SnUnCFZX9EFdH2ymYfv+boHi0b2ZPYACR+tozWfY/+MEV3GrBEenEdlTOi5hYOfrBs073WoD4wqqef5G+O0/D5AufWktLkUfS+kTwmu6wzwgcHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rMZXnkKBo4A1dquBnTEdn3tY6cHET5be9BRP2PQYBbw=; b=YMFIFTmrxLk1Q2397mqdl8d/AOUoOLqQiV/GpkarHYJg/NFfoBpY2sfsr7EniCnG7HvgkVA5LuQ9vco2iBW/CdbI8pGLk+tnvNuyF/PNfomRaPi+zLlQyCY/dP6iJhnCm9HZ+ZO1gBTeFRopFcwrBVNgFVbjOIVSiteETSZWxJWBAc4gJvM1y78J5ebT1R2jkE0nG2CKmBhyYm/uqqwVUy/QeLlouegXX5EvehCaezFyWS3MN5ApNHQb6O2bQIcBtj5Oj2KGBNwEMCY+ggB64Y92jQAvaanEZHI9Xo13wXuu5NHEXke2XqxvVEvgDIfguifhMMn7/+RoTFIua7K6gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rMZXnkKBo4A1dquBnTEdn3tY6cHET5be9BRP2PQYBbw=; b=d59ndZnE/EYTPxmnp7k0gwi+IaR2uetQUUfIAHZQgfUrmxwphidr2br8EEXAVB33zjcFZ2KW7PpyHr/KIgHJds1ftK7IGwAoZI45XQu7LP9d4Mi6uTR2AMZY59qSejX6QQjirmECFYZ6EhXA4kteshzulDdETSq+7C4NARBrch8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:02 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:02 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 09/12] net: phy: nxp-c45-tja11xx: handle FUSA irq Date: Tue, 27 Jun 2023 10:18:50 +0300 Message-Id: <20230627071853.106215-10-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 958aacac-758d-4988-abb6-08db76deec2b X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jXdj32GxVdS7+qItIGPiPytY2GgG43SNrd+CKfb6d8SUHF3ZMj7EOUF7plN0+30V3vD7B+5jTefntbdufxJyaScWnJCyf1QlK/Hf4MMmT1E1+xfjD3P5IhBaEMgVSkG71zoSDrZOW1ZWQkP4vwKMicRkVc0kU4AAuWJSxZwIj1+yrY+D4pwJ/Ic+r5J/hHjhaimMxzdrOsqieouL5hh6YllRfz6i9wc8ToUK2ikmEIS6g6yp2rB796I4BHyDPPjO4uE0XPv3OTnjjRFEenVXqMNK1G9W1QrczuNxJPocKTy6gXw9DCGj8Q6H6ZpMoq+Cucwhw6qfhLMpx5I2ypm+JvAjUbIofiuhCtGQjOHCWk5iFE8+z8bOTaiDeCW1CQ5GxtK1JG5Ywxd2q2tIGURDvXj//dnu7Y8AUjlrJbJ7Mrl3JR+fDoX5290BGcDXnw/WJP/VUmPfk6M1XDekciy8WzowrwSope98ceOawRLkDQUIq+DXHyOsGX0v4uYCNDQd/ejI18qD/kFjAW4fC5BazX7BJzHPd/usFri+4ocA/Sfvul0Wu4o8S/i4/m+pNhl8OweOCoHR5d+dWHYHbt9eAzEAswm8JcC5QsCZCSDLHQJqWKnco//SUBI/smzsTnPd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w7dghVr/38oVT70WfBTycfIZh+8bf8prrt6XnGM9FO8mG5rUmoiiNIYGI4MSaWhR38rHa8mXwVWZWtUkYgVKLVZJG+J982kOve70O8usnq3piqzZvgCwlBl9hh6LJcTF1PnBj+vz/RbG+jGvDbmrINFvJroxPxukyMP+VINDdfuQoi+P6Tvd+Mcizxg8jZ5PjTtmW5HOSXK8LX1orq6GPrp1WvFg6whjUoZTPKAQXr7KhrDOLOj7L1YnjWuzxa+r3oUDZBIZ1htPIkrM53Yc9WP7cu8R6n6GDDxoFYgLQ6mT4fIUUHAWDS/TdrYIbkKNevtAue3zrydez/7QxnNb/zHBWir2iYeLDoAlbGExh78eAxo7nwPyHHM69Rd1B3AYr5orqeNvblqxRi5PX78UHn7PdTGCiN09AtOri0OY1ozRfWCdooJwHK7Q5ro/DPSslBBClNYW2w3yR8WjyBcCZ2fEjByyHfzzJrXc0AIoZPwAQN5fSJzZp81BwftHprq7HAdmaB3vTxN0LWoQZHOmBmhkmwZ8VcYK/rCQxe/iHN0jFe+mKnINAhEnFOeE5X5bglr+YoCpKhX4gQQnzpz8Ov5jacucj7FIPl1a231WsoZt4rW5Oit/CS0EobDaK9ORlMKfHpfUzwhSblcYuDZI4aIzHUt2x4nYxDALTRJ6aT3ooz3zM3Tz5rDz6j/cP/qR0mXUt75Jw09aBqPd2W4A/5j3AvIdrS+fAl9uD7RO1WjE6QlljJqmpgwxfZSsWhvhAfJVKqFaWha0wQmGzXNcgzYUxA/6EN7NcmN1Td/T/dphzGxWik/+5hFYzdCAOCemVYLRSDylnSRvINklE7rRMZsUJlWT0MWVZswH5l7K/c2LjqA0ed1wwYm2jXYhNo3qNjId4z+kMIETijTPk8fn7YGlvH5GfiDdJBWpWivIJ8vlXBMs/+jjxF5MrWSXKdBWEnRsXuyHaFarKpcW9smwKxJ89qwxd9sM/AJtVBkxx/XON7nWN1abHeI827sXJC3PKMmhp7GcTEWRKKE2/3bFGVM/kixgL6s95Vjt2q0DKDrS04swAFAo3CCX2Mig+cEyCmKBc6ZRNdfiO4vOOhSpc+Jvk1C7J1cchsM0Qt6FKMWcXU5sUMDFIb9SfD+slMPq7LZLA7zlpLKwTcb8nAHvwD/AnL9C6nvkv/w8DqZGzrODMHY/XkajkDj4qRk2d0oYTVj7QwQ0EbcMEiZs89b//JzQSAI3nmYf8o7eI9Ga8uEKmExl2zTstBgeBy/e/q2C3lrTuSREHDbMMOUzlstSRAkLxUyRNuGY+/FHt070N9Z8wRsFofVfLIBfofBRiWA6ydvtKEQ2gQdDFOfQ/yilJb3TnKK5oKfeKKNxIfHrJAHqrxw6SJEaulI1xYPJygd7knztvwaUeHafmcEmEKdDY5hEmYWfbPXuYvz3Ld7N5W29GWx53sSXklSiJjNcZjxXOzHvN+Q5siH1ufE9tJw5qaPC697dYoandlEwlSFFJgriV+/8OPSTNAFTkhMIXWnu9Vqiup7gVirJZKdVWOLT7ONEANRXuBymPQVsPkikscsFZZZroK6i1hI75woahQY8L91qNt9A8JeqSZ7Lm+DEBg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 958aacac-758d-4988-abb6-08db76deec2b X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:02.1582 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0YoG+xD+rKR7wEgq6Y4HJtWn8b3N3Tu6X+0HAi5lVslW5/YhtJ1qtx67MUYe9vL/Hqm/SAwgvgDGKcnRPnZiUlErt8qmUilMhJv3oZbVRHg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org TJA1120 and TJA1103 have a set of functional safety hardware tests executed after every reset, and when the tests are done, the IRQ line is asserted. For the moment, the purpose of these handlers is to acknowledge the IRQ and not to check the FUSA tests status. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 79 ++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 0567a366af37..a826c845ee7d 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -29,6 +29,11 @@ #define TJA1120_VEND1_EXT_TS_MODE 0x1012 +#define TJA1120_GLOBAL_INFRA_IRQ_ACK 0x2C08 +#define TJA1120_GLOBAL_INFRA_IRQ_EN 0x2C0A +#define TJA1120_GLOBAL_INFRA_IRQ_STATUS 0x2C0C +#define TJA1120_DEV_BOOT_DONE BIT(1) + #define TJA1120_EGRESS_TS_DATA_S 0x9060 #define TJA1120_EGRESS_TS_END 0x9067 #define TJA1120_TS_VALID BIT(0) @@ -39,6 +44,9 @@ #define VEND1_PHY_IRQ_STATUS 0x80A2 #define PHY_IRQ_LINK_EVENT BIT(1) +#define VEND1_ALWAYS_ACCESSIBLE 0x801F +#define FUSA_PASS BIT(4) + #define VEND1_PHY_CONTROL 0x8100 #define PHY_CONFIG_EN BIT(14) #define PHY_START_OP BIT(0) @@ -262,6 +270,8 @@ struct nxp_c45_phy_data { struct nxp_c45_hwts *hwts); void (*ptp_init)(struct phy_device *phydev); void (*ptp_enable)(struct phy_device *phydev, bool enable); + void (*nmi_handler)(struct phy_device *phydev, + irqreturn_t *irq_status); }; struct nxp_c45_phy { @@ -1162,6 +1172,37 @@ static int nxp_c45_config_intr(struct phy_device *phydev) VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); } +static int tja1103_config_intr(struct phy_device *phydev) +{ + int ret; + + /* We can't disable the FUSA IRQ for TJA1103, but we can clean it up. */ + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_ALWAYS_ACCESSIBLE, + FUSA_PASS); + if (ret) + return ret; + + return nxp_c45_config_intr(phydev); +} + +static int tja1120_config_intr(struct phy_device *phydev) +{ + int ret; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_GLOBAL_INFRA_IRQ_EN, + TJA1120_DEV_BOOT_DONE); + else + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_GLOBAL_INFRA_IRQ_EN, + TJA1120_DEV_BOOT_DONE); + if (ret) + return ret; + + return nxp_c45_config_intr(phydev); +} + static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) { const struct nxp_c45_phy_data *data = nxp_c45_get_data(phydev); @@ -1193,6 +1234,8 @@ static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) ret = IRQ_HANDLED; } + data->nmi_handler(phydev, &ret); + return ret; } @@ -1599,6 +1642,21 @@ static void tja1103_ptp_enable(struct phy_device *phydev, bool enable) PORT_PTP_CONTROL_BYPASS); } +static void tja1103_nmi_handler(struct phy_device *phydev, + irqreturn_t *irq_status) +{ + int ret; + + ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, + VEND1_ALWAYS_ACCESSIBLE); + if (ret & FUSA_PASS) { + phy_write_mmd(phydev, MDIO_MMD_VEND1, + VEND1_ALWAYS_ACCESSIBLE, + FUSA_PASS); + *irq_status = IRQ_HANDLED; + } +} + static const struct nxp_c45_regmap tja1103_regmap = { .vend1_ptp_clk_period = 0x1104, .vend1_event_msg_filt = 0x1148, @@ -1663,6 +1721,7 @@ static const struct nxp_c45_phy_data tja1103_phy_data = { .get_egressts = nxp_c45_get_hwtxts, .ptp_init = tja1103_ptp_init, .ptp_enable = tja1103_ptp_enable, + .nmi_handler = tja1103_nmi_handler, }; static void tja1120_counters_enable(struct phy_device *phydev) @@ -1697,6 +1756,21 @@ static void tja1120_ptp_enable(struct phy_device *phydev, bool enable) PTP_ENABLE); } +static void tja1120_nmi_handler(struct phy_device *phydev, + irqreturn_t *irq_status) +{ + int ret; + + ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_GLOBAL_INFRA_IRQ_STATUS); + if (ret & TJA1120_DEV_BOOT_DONE) { + phy_write_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_GLOBAL_INFRA_IRQ_ACK, + TJA1120_DEV_BOOT_DONE); + *irq_status = IRQ_HANDLED; + } +} + static const struct nxp_c45_regmap tja1120_regmap = { .vend1_ptp_clk_period = 0x1020, .vend1_event_msg_filt = 0x9010, @@ -1761,6 +1835,7 @@ static const struct nxp_c45_phy_data tja1120_phy_data = { .get_egressts = tja1120_get_hwtxts, .ptp_init = tja1120_ptp_init, .ptp_enable = tja1120_ptp_enable, + .nmi_handler = tja1120_nmi_handler, }; static struct phy_driver nxp_c45_driver[] = { @@ -1773,7 +1848,7 @@ static struct phy_driver nxp_c45_driver[] = { .soft_reset = nxp_c45_soft_reset, .config_aneg = genphy_c45_config_aneg, .config_init = nxp_c45_config_init, - .config_intr = nxp_c45_config_intr, + .config_intr = tja1103_config_intr, .handle_interrupt = nxp_c45_handle_interrupt, .read_status = genphy_c45_read_status, .suspend = genphy_c45_pma_suspend, @@ -1797,7 +1872,7 @@ static struct phy_driver nxp_c45_driver[] = { .soft_reset = nxp_c45_soft_reset, .config_aneg = genphy_c45_config_aneg, .config_init = nxp_c45_config_init, - .config_intr = nxp_c45_config_intr, + .config_intr = tja1120_config_intr, .handle_interrupt = nxp_c45_handle_interrupt, .read_status = genphy_c45_read_status, .suspend = genphy_c45_pma_suspend, From patchwork Tue Jun 27 07:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294125 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 6FEDF1642F for ; Tue, 27 Jun 2023 07:22:18 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2056.outbound.protection.outlook.com [40.107.6.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374252D62; Tue, 27 Jun 2023 00:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FvzsLC2TROFVVQK2l+W2hKXnD7J64CON1mDo/9YCbVCYaaIgwzcalZ7Vwf+5vymYDkaiLhmmROGwScFeH8qAKGvHRTSC6Mnf2oKLjbmCT83GHZ01zmcCejM0+wUNU98iTWU5hzQzBSpWe81XQ067+yeV1GGZZWD/d1UqrmvR8IMx9VUG6jzYRCYLdx0hiGfPn+lRJQGKYJCIj2WmeO3wVDmnQprobukWgR16MpISAOqOZmLH4yQbQfsANhmJwcNS28jKGaSH7ASf4mjhaKydMjR/KOuSkvXQ9IwGV09hyz47xueaExErewc+VKHt0tsD6lNOlk52ggOY1eAwVJ1VsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9TYf3RhJsN4JxynB2bPI2CrQCmJo+10Di484d1szIko=; b=E568vrrHEHzV9Qrazbd/5q1k82svLX4KCN9rImy3YkfUKrdzlPbt68WrwiXVGRsYVpjzNBl5UdiT4wsyVN14eutd2lnV3kYOaD77kJ5fu/A3Mj1rdTBrc+hN65DSExr3HbQRMIsTfqoNhtzIIjJha/MQlrbYhARCpKIw2nHzRljzn4CyFMsTz27oGDM+YIdzbSmUlObERcmoZMG3PTy6dJzWTN2IFyUhjPf7GkhDODxzHxHfT0GxsUDJK8UkxjMMaaDVIhWxW7RFpi/0nxvTul3wle4i//e4siav4h3Aeo6SFhY4oZfwnbFN/TlMZhTn7pOngAkCHSH2CVVH7Ps0Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TYf3RhJsN4JxynB2bPI2CrQCmJo+10Di484d1szIko=; b=Cb87fywyKoKbHqOAVXAvwXbjHayACK2wRvcxRBpVLgcf6h5+gvSgu75CBtZqQKMTUZheOZdUHZW54xAlbe//e8Gh213iRQ+5FHt/GqqMrl3hOyrp5a/bjScb2JOzgUk/5LScKJCySKsHWxtN4MGR4+CtI5gt5iNcWOT3IRUDBV8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:03 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:03 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 10/12] net: phy: nxp-c45-tja11xx: run cable test with the PHY in test mode Date: Tue, 27 Jun 2023 10:18:51 +0300 Message-Id: <20230627071853.106215-11-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: 7268b0b6-bc1d-456b-3b1b-08db76deecc4 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RaTOZs9BFOu4buqIvjQ0Nq15608tt4XiJdQePC2937/Osg7k2ozVpwsrIDW0HqXCF87dt0F5LBE8m6qRw37OC0T014rXj6iEHGy9h+hipGTdo1PwbyK7pz+g3/Jk2X0UaKA1tkUtZeDl1n1sAcvMJ7/6XT9LS1FCt5TOePSps4cBk0XYCcsAvjuyJosyNQicHA7CVNmVwBvfsOh31QMScL54ptr6vggDBMNok8vLQoSDKVzJvn5ZGRvpCVyx4I4r6a3+WTIjgrD6F1Xfvt6dhVdl1wk//byTpJ95uVvN9dCVaet6gEG8Fc5OXb9NJ9DmyfZ+GiTxnzDpaDP7PJl8VovmIx3lskU+wa8On4AVuH0LLzJU7iJ+vUttHoLeeiksVnPJYURxCx7TnyIxk8JkxPjPggbWBcVON1M94TJQEiEfKN5f/ObYBqju9LIiOru9BOWyPxMpvXLytF7ucpVA1Cg8eD63p2OwlzJfnZmCAkvrB/G7AcQS7IcQQZIjSX8tygu7IhEwAB7kYOH5Mxv5jpmQRE7iapE+SRpxScUdkRmTGZ4bI3inTtWYCfsuPzEnSULqTnjAHevdaGo+CnR8K2FNzsxBHgNrM8ys4rWjlP4rfBlHdTYcNCwRC16nI3E2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U9jfoof6UVaEGWl1D63/1Jv/ET5QgpXKVL+9v/uCWbI6YngsVdw/WdNz71iZshkfIKva6xByrfBhnScqOZZ6k/4BYvFVaUKoQuCUOCNMmfzg5QDw+t+OmBX7uUampQvnbwY/KdYpZPGXCn3FFS3px9stbrCWwWes37o4NmGatPgUAVZ+ElwgZCkBVOqbFZ9Jy+7tpVz2GpsABFQ+0xa5j9NVheuJoVpiNUucO9cOeTxD+HR3fSsiVRhVExNE0mz/uBB0T7I1E+n3gw/I4O9z/Q0GDNPXKWMR2N1P4pFTnDdvXkkMGeT5YiLGLiW79ii7aGLt5i15Mp4wUeIRc8XZioJ/wBpbxcs3yoBwNVH1BQ6Rb68/Zz5PnLUJl99PiB5Q8JLo4gtESXtXvU28ytRoe02XyBP/8Q+Ek3bV5VINADklzyIz4Y7P1LEWqdOYaKxtiC/O/W8TQYjVekHv9CRUFLmyKdv2fhLWop0XbX0ljsajyG/PGpfsAjyyxxdZZ8BBhkeAer5nI4PtG1lFLvYPZLx7rOc/lwVD0Dqn0vCYUjupn5kBOwrTO4rS5yZaRZpr4n+yC1ObYKSsRmo717dNvx1SyGkb84rvCF70YARKFoCpv0u0ZRpgieDWlU+qrDCyrrfclYzWybKWvW4nPm1FEh7zYdp08/uCxXBfHBTf77PMEWTNnjXw4xg36bIUvqH6K8Gj3CaNE6i34pbNFOr1M60m3LGt9bycf3j3Mp2/luy6FVejHVeIFni6D2aYuWTEAvlT9WXPjqYlupmM6uYfnAgpK03DoftMuDnBYKfOpicM0OPsZdibKFV38hBJ/nbyWjciRRoa5NMHvQDrh9sEw4yxaMDeGVA/Z9fkKLqySrq4umq4BOo14WrQdCZf0pr0Wn1O2yWFHaPXueIaiCIt9ZUqL0OHvxtgdDxuNZe3JwHDnVwHgI9B8mgkdrl+uD8/RQJTsSQA5wPchCbQbTk/Ucl4PFJtYW7Leit/wZrAdCVhQ4pU4mSVDCg0WPZgj9ONYarXOaFelhruNW6eTyHGCiruq9EgoWPYgzdkxiJROReOhFBvLs4ODa86xfGQ5KWQirudv3hGQO++JIvRZxJ5Dyacz3kft0vH1jG+PTGcwHYy/EddK67y8ucfsAph5ZxKXLlJJ7eeInPlQrsDkyz+fsBkfIpwAm+ix8wClm27T0dCYXQZq2Z/kVMerD+CMxF4fJZXdCxmW3i6VqS3Vfu/6zBE7QaSq0jWyN/3pOOwcyeBver0y6WBGERjCkbMSXNKkjVEoH3g3tU7ood2o4kgi3eJfP8ff4HgP8RKJ8khGgb35wBnGiM1HcPWjZDXVOXvutgkk8ukh8viR9Bv2ch9V3h+kMbkvJleMyToQzkMUaHZ3PTKfuFlqR9Ph8//Ri43wt9qASONRVMqw84jnsRJCmucK8WVTuzbcaRkeN+nbNuqX2Z8o4TGPPMOzsLBa0S9UnsFXSbOQebwaKomjdVkjbNkd5y0bFGxAn2gRwkAgUxlgVebUa1WM7yH3NtZaN0ekx1Ijs3jTdmrL3+RvhvurBhHstwwpU6Q43epTWO5sVhHFRCymapz6wImMd0JP1FgIiVto96jKq9qJEO63l2V+Q== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7268b0b6-bc1d-456b-3b1b-08db76deecc4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:03.1554 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gHlZHM+56nA3N6IJ6HZbHtp8UKbc2GlvEFqYlaO94tu+3SzpZS2YIPWubYn+2xSVpHLQqGUMvyZxOUzR7P2Fb1nIMMZnPOEQKHVE8PVdGF4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-Patchwork-Delegate: kuba@kernel.org For TJA1120, the enable bit for cable test is not writable if the PHY is not in test mode. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index a826c845ee7d..8097ac8d6962 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -145,6 +145,7 @@ #define VEND1_PORT_FUNC_ENABLES 0x8048 #define PTP_ENABLE BIT(3) +#define PHY_TEST_ENABLE BIT(0) #define VEND1_PORT_PTP_CONTROL 0x9000 #define PORT_PTP_CONTROL_BYPASS BIT(11) @@ -1258,6 +1259,8 @@ static int nxp_c45_cable_test_start(struct phy_device *phydev) { const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(phydev); + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_ENABLES, PHY_TEST_ENABLE); return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, regmap->cable_test, CABLE_TEST_ENABLE | CABLE_TEST_START); } @@ -1299,6 +1302,8 @@ static int nxp_c45_cable_test_get_status(struct phy_device *phydev, phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, regmap->cable_test, CABLE_TEST_ENABLE); + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + VEND1_PORT_FUNC_ENABLES, PHY_TEST_ENABLE); return nxp_c45_start_op(phydev); } From patchwork Tue Jun 27 07:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294126 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 F0B4A168A7 for ; Tue, 27 Jun 2023 07:22:25 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C560D30D6; Tue, 27 Jun 2023 00:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=btgw8Vlo1ZeU6gxgWqEjDF/oGShTQNuQzXrneTOllse8e6KcUcMVlQ/7lWvwHc8U8cI2ZuFtb7a1aexdgMAswqWt2mLs9FgxTUJkLC1RGPdjSJiIi4CojlR4yO433/L8KfLIsnFoA/PnLqFQ/v3PpanyBnEt7Hn615yNUd7oa4CjM5Jc5qIEb4W7sxHHPJXOUo0lgjrSUcBU7L2qA39WRjgFdoDoQB8VhctZBJWGxy2FSaL6JS/oF+LuQi/feK9U8ZtoaLkhg3x9wBn8Y2QubrgjYrT9aNTEnpfgzazn71fUk/diQ4/sb7b39Jezjxw3Uftp2eGGiJgvVieh3HJZuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x0i+EqVPH+dSCRPnSwHsB1/280lgau8mOLLHBMZHOtw=; b=Igp+nLPFIukWuin40HA0OgCEhD10ep6Ovz9sG3CU72lJoqxyIa0GbkrAqYgjX4aAMh4NXAMpyujmyLYYq3ari3Y7sJK7+613W0KacMudfwW4GmZZ1zw8EP8NGD1sQty4xXvq4VJH0crxr5qQ1E46TjTJS4ngHrLBgsH80DAhVIA8u9NuDycuU5Wn5z8laoN0GIC/+urQLwNhgaimrLagIQ8mTHHtt8CP8C6Q+0KSjoYQnNMSp/Pc6/LlN7FIqGkmecLDTFnITqgtBEFTZ2fO8KFyp2ZzFS5Zh3MNF8uhuvRSDm/Pgp8UyYAhxGU8Oo+G3betYtAIz8MNmhhdhzrRPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x0i+EqVPH+dSCRPnSwHsB1/280lgau8mOLLHBMZHOtw=; b=GZaMTv0sx8H0VyqxH/YJqCXejW0dzLXPLQHabR1w66L2F+HOAf7bLMJSXLzhx2ACVdj0PyQW+bLQZoKjJqY6ButweotHBjXesEcXVqDIx5xHvdWt2uwfxeckdGCISEdgoTTZBBpN3UdkOJYMJ9L72hzsRsZtvk8+IN3EHUa5fjw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by AM9PR04MB8778.eurprd04.prod.outlook.com (2603:10a6:20b:409::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:04 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:04 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 11/12] net: phy: nxp-c45-tja11xx: read ext trig ts on TJA1120 Date: Tue, 27 Jun 2023 10:18:52 +0300 Message-Id: <20230627071853.106215-12-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|AM9PR04MB8778:EE_ X-MS-Office365-Filtering-Correlation-Id: ebbf3a5a-d43a-4fe5-ca81-08db76deed5c X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1g/AYg59gK7KaH7mGpc1nXHY95ayCb9DkMcbZaxTYwbyeOrHzoha/oMHt5B2000jA5yF8aZdwu2Bz+Z1P2cw9Y96UyEDvbPQSIxee8nlD8O42wuLHYRbq0RaZGXGRjw6ZQkNxazI+BUJulFWeHijDbCwYH6PfnWR4USfgv6IrL7qJo9DhGep8cMUv++U2Bq5iiYeb4IlIr4u9HvnQ8Iv8JHRvh6eIOncf1kZrEk646HdXAzKm4TDh/r37W4ukNlzzpCbuf8I95IlkRrGjPJkhdtPPLFBnuMFt3JdQrvzau5RXaZO7fW2kObOVdUpFgSqkZm73euvA/dw51TSxdEGEdJsEnFhPi8pNe8U5ZVstsL+f/dvCXA8pixG6ptg9bTMhBL4NWu7gfL5gSKig53SSYosUL5OH/FNU48y1ERVNahSHLPq/UZ2ZXBwGuA12jdpkjxiZCLrhkMs4WCusSX8/w3//jFjgNkylfmIRovHDhDOCurg5rUcJZ+ppb8lLSckiY90yLmChaN3UZKgRi8zF/RSkzpwYby1/J9jzqiudVbdnNArcUW+hvyUy5i6a+cIaCAQlKhkR5tds8v8goUp02D6Ihp/xEzmrbPMt5DokRPbyZ4oFHvAgIQ4TL7YDlJh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(366004)(376002)(451199021)(66556008)(66476007)(6506007)(6666004)(478600001)(2616005)(52116002)(83380400001)(26005)(186003)(1076003)(2906002)(6486002)(5660300002)(7416002)(316002)(66946007)(38100700002)(8676002)(86362001)(8936002)(41300700001)(4326008)(38350700002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U3pTC436sEVGEx5vytOCMBIPZPkXvDThbxLcn1EKnEAazD0A1Df3qs/ACNUCfdVp11AJWLP78YkgQ6M4RI5x7GG/sgbqPuJjhkxwcoWZ2mNMqvA2kV4FDt3qeWIcZLLGyiTjEDM+kYyvlWrjv1jMnXfDBBbiSRuxWx/IA+wpW/NyGZXBXyOXfv6sUy8McuF6o3QpJ3Ehj6JIXAn5DtFOs9dr8MXUbUIT/jrxfEEpz6s7kBLWNRPs5sb0OFqfwd8kjaJseAebcKOFayr8Gn6NYug4aCkyiwsAYSazO5qhCEW0QqbV7qOpEcSPoio94KkyIIC5WoGLCFb5wG+T8XkBCZKDYguE1RSUuuV9xViJVNR/qpgmsVyjwkN6F0UHx9oQrj7qOxhafRrYlQvxlfuq+sEfagzvNotPCaonAzieyurJ4GjvSgTOfjqTAFw4/Jm7cLROGqD1jMuVPmVek+gs2qpKDQWNTeaUbQ4qZqibznDeI0dtOZqwgDBW07F/sf3mIwym8teT8NC5t1EGtLd9hnZiBJUB2KzAByTF+uvn3/aL+tGvq/ILHNvX5MIOCRkzUl4L0di4oB2z5yihrlohfvgwEN2GCAx1+V8kBcJDcRuSmkPj8fxI6bmL1UgQJfdgv6JN7s/wth3DiqoVgGS8zL5yH0mnJaCD41NThjYRum5T8HTds8R5NDJ3E79zOgZD/NWHJ6B1DhokI41SB/elHFM7tyiOoliGggF9xt/9wID/wXl2F94zpO6Ppg4B8svsAsG9kyCQz2nacQcuuMRZ36f8KIDbYJOEuU05/SSYkI7Ein4NpSbIbTKOM4uiwC8XUToMmfFuxjhkCxGA6p/YETWfSsI6YHQeV5szN1bJDo28GEjmiqXXazpjhrL80920MY5sQ5XMa7GiEtRGAIaozlj4QNZkXpkkSr/Wh//yGboyma/mnTcFoQF2I8na+0nGdR/SckvtDnTC7xUb2dpUOJe4VBI5yHbRyMfXNMoDAyd9ilHiUm5mWics0VLrADMK9gMQug9keEhHo/UuO/lPgNpelBYX97kzIRoUF3xTHJtHItI7inNAo+K51CxgU5xIHHdtPYyI5ndoUYbpfI8t1VB6n2ZnmVtpKCdSKVDOPwSoj19mIKrJWXfDSk/nDtfDYFFYlOFZO+nYk27WLcwh38tZ8nQ5WQW2sV+1RX1SxEuR7HufjtfSxKniLNVKdUeIK1OyyCE8o87d5QS7esN8Fy1MmNFuCLO4k+HcUa8j9uJZ6s3HMWDRyNSuOK97KV6PcxsMdXyqMHErlSp999kb1pXWJsw8CfVRYgSCB1/AzA36EqQdn/fy1XwHuI18tmR25UNxmgcZb3aXSFgJqf339kKLDhkNjCWqSZ0EbnmnzHGLVPewROttNKmSkV2P/sdDyK1MVd4xpBTqvpELo2Ekg8XK1/dDg03+f6XAC8NCzCF9H7PM3Iz4Kx546n/ODrR5dpP2fV0myy8VhzX7Kp7bzjOkSJMTPJZT8oOge7hLn5BIPv2fh6I+qjY+VeCx+po+X7JomYJjWjT4nltUtWNe1USoAKYCKesG3SKixT7CpOrVnFJqaSi31jwSGmbynkme5+r9HoYEI/ZnSLz+3wXwHw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebbf3a5a-d43a-4fe5-ca81-08db76deed5c X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:04.1520 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zIrmRAwt0zUJ8M27gRSTp1+EYA1hMJVkOSCe9h8ofNW1q8wCx0eNYs48G8JyBtsDzUhhM2mEMuGz8Qv4amJTVl9B8qHCnTHhG/T7KDPJwfY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8778 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org On TJA1120, the external trigger timestamp now has a VALID bit. This changes the logic and we can't use the TJA1103 procedure. For TJA1103, we can always read a valid timestamp from the registers, compare the new timestamp with the old timestamp and, if they are not the same, an event occurred. This logic cannot be applied for TJA1120 because the timestamp is 0 if the VALID bit is not set. Signed-off-by: Radu Pirea (NXP OSS) --- drivers/net/phy/nxp-c45-tja11xx.c | 64 ++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 8097ac8d6962..c21c6aefc705 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -34,6 +34,8 @@ #define TJA1120_GLOBAL_INFRA_IRQ_STATUS 0x2C0C #define TJA1120_DEV_BOOT_DONE BIT(1) +#define TJA1120_VEND1_PTP_TRIG_DATA_S 0x1070 + #define TJA1120_EGRESS_TS_DATA_S 0x9060 #define TJA1120_EGRESS_TS_END 0x9067 #define TJA1120_TS_VALID BIT(0) @@ -269,6 +271,7 @@ struct nxp_c45_phy_data { void (*counters_enable)(struct phy_device *phydev); bool (*get_egressts)(struct nxp_c45_phy *priv, struct nxp_c45_hwts *hwts); + bool (*get_extts)(struct nxp_c45_phy *priv, struct timespec64 *extts); void (*ptp_init)(struct phy_device *phydev); void (*ptp_enable)(struct phy_device *phydev, bool enable); void (*nmi_handler)(struct phy_device *phydev, @@ -509,7 +512,7 @@ static bool nxp_c45_match_ts(struct ptp_header *header, header->domain_number == hwts->domain_number; } -static void nxp_c45_get_extts(struct nxp_c45_phy *priv, +static bool nxp_c45_get_extts(struct nxp_c45_phy *priv, struct timespec64 *extts) { const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); @@ -524,6 +527,53 @@ static void nxp_c45_get_extts(struct nxp_c45_phy *priv, regmap->vend1_ext_trg_data_3) << 16; phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, regmap->vend1_ext_trg_ctrl, RING_DONE); + + return true; +} + +static bool tja1120_extts_is_valid(struct phy_device *phydev) +{ + bool valid; + int reg; + + reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_VEND1_PTP_TRIG_DATA_S); + valid = !!(reg & TJA1120_TS_VALID); + + return valid; +} + +static bool tja1120_get_extts(struct nxp_c45_phy *priv, + struct timespec64 *extts) +{ + const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev); + struct phy_device *phydev = priv->phydev; + bool more_ts; + bool valid; + u16 reg; + + reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, + regmap->vend1_ext_trg_ctrl); + more_ts = !!(reg & TJA1120_MORE_TS); + + valid = tja1120_extts_is_valid(phydev); + if (!valid) { + if (!more_ts) + goto tja1120_get_extts_out; + + /* Bug workaround for TJA1120 engineering samples: move the new + * timestamp from the FIFO to the buffer. + */ + phy_write_mmd(phydev, MDIO_MMD_VEND1, + regmap->vend1_ext_trg_ctrl, RING_DONE); + valid = tja1120_extts_is_valid(phydev); + if (!valid) + goto tja1120_get_extts_out; + } + + nxp_c45_get_extts(priv, extts); +tja1120_get_extts_out: + return valid; } static void nxp_c45_read_egress_ts(struct nxp_c45_phy *priv, @@ -656,12 +706,12 @@ static long nxp_c45_do_aux_work(struct ptp_clock_info *ptp) bool reschedule = false; struct timespec64 ts; struct sk_buff *skb; - bool txts_valid; + bool ts_valid; u32 ts_raw; while (!skb_queue_empty_lockless(&priv->tx_queue) && poll_txts) { - txts_valid = data->get_egressts(priv, &hwts); - if (unlikely(!txts_valid)) { + ts_valid = data->get_egressts(priv, &hwts); + if (unlikely(!ts_valid)) { /* Still more skbs in the queue */ reschedule = true; break; @@ -683,8 +733,8 @@ static long nxp_c45_do_aux_work(struct ptp_clock_info *ptp) } if (priv->extts) { - nxp_c45_get_extts(priv, &ts); - if (timespec64_compare(&ts, &priv->extts_ts) != 0) { + ts_valid = data->get_extts(priv, &ts); + if (ts_valid && timespec64_compare(&ts, &priv->extts_ts) != 0) { priv->extts_ts = ts; event.index = priv->extts_index; event.type = PTP_CLOCK_EXTTS; @@ -1724,6 +1774,7 @@ static const struct nxp_c45_phy_data tja1103_phy_data = { .ack_ptp_irq = false, .counters_enable = tja1103_counters_enable, .get_egressts = nxp_c45_get_hwtxts, + .get_extts = nxp_c45_get_extts, .ptp_init = tja1103_ptp_init, .ptp_enable = tja1103_ptp_enable, .nmi_handler = tja1103_nmi_handler, @@ -1838,6 +1889,7 @@ static const struct nxp_c45_phy_data tja1120_phy_data = { .ack_ptp_irq = true, .counters_enable = tja1120_counters_enable, .get_egressts = tja1120_get_hwtxts, + .get_extts = tja1120_get_extts, .ptp_init = tja1120_ptp_init, .ptp_enable = tja1120_ptp_enable, .nmi_handler = tja1120_nmi_handler, From patchwork Tue Jun 27 07:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Radu Pirea (NXP OSS)" X-Patchwork-Id: 13294114 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 48FD379F2 for ; Tue, 27 Jun 2023 07:21:01 +0000 (UTC) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20612.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaf::612]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09F226A3; Tue, 27 Jun 2023 00:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EqJoi9IRwBKPsUCMMDMGQOjTmowTr63wnohBODtc3rqeiG11wXRZXS+rl042Td3c13EbHlsKYMmccjNrrSuGT9JjnAyBNvuC6/9D1fNjEtgo2lT9wvAxOT/rsJsQPNY4+hL4rlhSMZjXjlROqUdEHCLuw1ThMeXMMwYiqvfoqKLoRB7cXX0J0rAihokxQxyH5ZHdUwTSkWaNirCQjABeFEFID/nYbZPY7e+2zL2F0ww6dEroGp+PwR9LrGMol6f48Y9uwmZjLv6r968EMTfjX1vSg/cSqDUIHJOqEAO3QwjAh1twX/G+82UWV++CqcZ2+k8npHGNQ1lYnQXQYYYahQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0jadCoVrujpc89wNC44EvqDY1NodWAxzqixSXEHnIiQ=; b=fyijb/lHYBKS4vqKdHFM1zsWOVxGr0kZuN2Og2CagwIT0nwg4MMmpS7yxIomGMvnHAi5Qh7NWQ0rg8WZwXeQxaj6pBkERZd9O9g4oSoAffY4Lr+1w9uygP4yOxdA0gr5s7LXmmmzh7mizrtFBq9IkVAwu8ndsWfJbAaEGg4GJUK0V6Un0RYJpRMbIFICSCRE7VDF6FDNp3WCOf6J6KWF4QPJUc3R7shloKE7SNFJP8wT7vjzs9fw66h4RInmIY0RWEqcXfaV1DWix7rTlSX4Gu7Ax3LVzaR+QpxCpAkweH1lbB24c49yrm4JSyGoKPmgNNJTJMj5GrVJcncKAizAJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jadCoVrujpc89wNC44EvqDY1NodWAxzqixSXEHnIiQ=; b=SDgG+vaAfpZumVd+OjMLaMe9DBN8C0KnI5P2++ALB8XyTlfbv3RZiIc3spFh/Zu4IsvkOYKPkEj/B5Da2w8IwwsRHmGoGI5JnNK9zVhXds9ZItajmPFrxvaRjKy4l+BIyDHoM6zepPzlqcnCJRLhqKLtzj4wCldIvbj4vrm9a9s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) by DU2PR04MB8965.eurprd04.prod.outlook.com (2603:10a6:10:2e0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 07:20:05 +0000 Received: from AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29]) by AM9PR04MB8954.eurprd04.prod.outlook.com ([fe80::5356:c79f:ef9f:dc29%4]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 07:20:05 +0000 From: "Radu Pirea (NXP OSS)" To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebastian.tobuschat@nxp.com, "Radu Pirea (NXP OSS)" Subject: [PATCH net-next v3 12/12] net: phy: nxp-c45-tja11xx: reset PCS if the link goes down Date: Tue, 27 Jun 2023 10:18:53 +0300 Message-Id: <20230627071853.106215-13-radu-nicolae.pirea@oss.nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> References: <20230627071853.106215-1-radu-nicolae.pirea@oss.nxp.com> X-ClientProxiedBy: VI1PR10CA0117.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::46) To AM9PR04MB8954.eurprd04.prod.outlook.com (2603:10a6:20b:409::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8954:EE_|DU2PR04MB8965:EE_ X-MS-Office365-Filtering-Correlation-Id: d8663b40-14c1-46e1-e2f3-08db76deedfe X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LrIGaHrWANnyQYNSS+en4LNyNOJj2CCtAaOZxxKcmLM+NyEBiRNxywfpHx6UPb5P8ePtbyeiwjSMiXyFnLMPI0KnVRXbK6e+tJwd3eotRYv6roiEKOLdb33oMhKU5XNHVX9G62GNcl+ArZtXkzUrgDskv2g/nntPaOPIyrm3PYCMkc5UgkdEQRqMNMhMDVci2TsKLk09BRq0mxWLIj7X/jERZGRkcHbZrDkHrCh72NdXYnNCikOBmPGyuU6T6W5bKkkEBFGEnfeJ+FxUO92//0EJAcDSZRdGbyQDnHOLE3qxCI+7pFKQ5gU1eWdzQIHQSz7DGO3i2eQWgsTgR1GQTXt65F4PRH95t5swSiVYElHBVq5ou5v0sr+l2rOHWyqetl7FxkaEe5nuf60pL7N3KqckCpIpsiLADXsvmIx3lbw01zoQ8f+MyI3asamTJhhTxjwc93DPUKIfU8eHJTOReL9GpFBHqvurjrYqPnHkMSiGIj3KY1A3x+Qjp3fyomSAvROJegW4pwdc7pPcpCGzjjX/ie9xscj6EFU3bQhEuAQYeYo+D3Qyjn8UbiKZkgaLCqoWGjrgz6vBBKOsAGPda/icPWs3KlCqdWxG296qgTQLeii2b9y/XgBv+Cz3GXcO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8954.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(366004)(136003)(39860400002)(451199021)(38100700002)(38350700002)(83380400001)(86362001)(478600001)(2616005)(6666004)(52116002)(6486002)(66476007)(66556008)(66946007)(4326008)(316002)(8676002)(8936002)(41300700001)(6512007)(26005)(6506007)(186003)(1076003)(2906002)(7416002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oZ5N69IUOpX1afnGzbyWfeiLqK/gFTVplan64lDrDxjGP4NdedJI3E76ZjK5XRK+EgoN04CnKWiabJPz/StV+/LnLb6I1TvpMjxJ+7NKuZe6ttogKFKNAIlHlahN3yQitkubxbNnuFXMT4N09vWA8jKOjS7BGV4A0PQlkUJivm5/O1l22TGjT/7Bj+ERDxf2+SQTME6DjP08pXBy5mJJyTnmRXDcRaGhvd8Xj44qS1vvuEgU/+YqKFIDc0AySzsdwccHkx+XDWeJE4ZK08U7mvxsoJFyxcwclB2ScyKAx7VAWvHZF0N1+a4320HuKEdO5mtCqywv0tz2e7vAq7zG8wDWvd63mdq1F4Mstr5iE6r8+X/DPhkCt+ZSD1+rsnqyGJpCUPuQugrOkhhFAuW69pxcmBcQ0KhZhCUYzVK1Wo/cKVf1l4nPwW1KJIZsq7RG/GVEmQaAM+57+FmkJc2AZfg1daRhpCrJRtB44TsDvOtP80p4sVIsdN2nNKNuif3GTe+cz/zU86KuhnR3NfOjoUnzQjhG4lf7+/2BwXaIaCWto/hxQzTysvm5w7kfIveecV042q+Uugi7gXibGkhu59csYL5TUbr49kxJIjB+LuQzAYCzZg0UbJ8VFTkoyYoUWka7HzY0hdTBing8k15WFU4Gea+Gh4vrD1LQx1SLuP+CSV+SYVjNhEXsGk69LpgUCkAve2oBPGppeDQYeKnwuw6nafaMHEEIHjphtiauiruB0Lql7HF12NCzjz0hyQolpLOIt+9XJlnFfPOrlVSST9TJk2B+av7rauYemIQUe+4zI5g/rz9QD7p+WnkXZjzEiw3Tn5gnXAnoP7hPMeI1MFxm5olk03PdTP3hVuMrcYYVr0emByfjp6P4SwZM5pGbrLPVqGRK+lkv+mKEo1tcCS5hTsTUOH1WTawP/pYBj0JG2X3vlhLHPg71fn2FXMJOKLEukg8urGVpKEYCkgROk+/6m5OtS/d2if3xGqnqq3yMGUDivn3hnddiuwWK8/cA3KSOs2jsJ7I9r9PompUg5tnpR9Ki2HoDt2dC36FwjkgUTV1JBYZD1m6RATT7n08+AhZG+FN63KCvj2TePn63Lyk/3KUAxUElP39+LnFhOtEC+v8M1Rzx4bs3TzIj0lQxnPsapPN6h9vD2+aIag47O99DgnLwEK+Y+yTBxmhHbbQo8R2YnnuMb9gMdPTnLNusUlTeTCT9FBkFKwXKC3sHmaNFPwo+vFAgpnWfcTeCcmOoPkUgoVyfKqZXFssMAIhLLwrufEmWLuEoKgsS9nMKSgsAwLxYQLgVRholBVBykgwVA9/Q5oKaMY+Qg1yWVl+V/nnFOB/ohgbxa6EchUC551ZsiF2ejcxZURDtXZ3F6dOjcZeGacj8j/g4CUPxA3wsm75f3rdWfgoZewKwGJwu5sxlqChk1eelDuIj0ryvz74ArVhj51CXSs0QwBHS540bvRE+k9T85+CvKdP/s4CXcrQqMMB4FqtIYIog9QF3q9lHAsDKpMfrgvAHfAhLbAOi2xxeNtA25JoZhRkU8QfaMTjVqGQcKIlJJ8iTaLd+XMU78Szw6nGvTt9anpGP2AHa2834kkURbIS/1e5LGVQZZA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8663b40-14c1-46e1-e2f3-08db76deedfe X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8954.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 07:20:05.2721 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bld1TNizT/DNsxlx8MDtzcufwPI8oiA2C6AvDezTx1anMwKZl1Gb0Ncy/s2idNzcfwrL8wD7YwhgIsDcIQl9HEaBC4o0x2zAisNrbCwPmf4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8965 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org During PTP testing on early TJA1120 engineering samples I observed that if the link is lost and recovered, the tx timestamps will be randomly lost. To avoid this HW issue, the PCS should be reseted. Resetting the PCS will break the link and we should reset the PCS on LINK UP -> LINK DOWN transition, otherwise we will trigger and infinite loop of LINK UP -> LINK DOWN events. Signed-off-by: Radu Pirea (NXP OSS) Reviewed-by: Andrew Lunn --- drivers/net/phy/nxp-c45-tja11xx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index c21c6aefc705..af3951e76a47 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -56,6 +56,9 @@ #define VEND1_PHY_CONFIG 0x8108 #define PHY_CONFIG_AUTO BIT(0) +#define TJA1120_EPHY_RESETS 0x810A +#define EPHY_PCS_RESET BIT(3) + #define VEND1_SIGNAL_QUALITY 0x8320 #define SQI_VALID BIT(14) #define SQI_MASK GENMASK(2, 0) @@ -1371,6 +1374,19 @@ static int nxp_c45_get_sqi(struct phy_device *phydev) return reg; } +static void tja1120_link_change_notify(struct phy_device *phydev) +{ + /* Bug workaround for TJA1120 enegineering samples: fix egress + * timestamps lost after link recovery. + */ + if (phydev->state == PHY_NOLINK) { + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_EPHY_RESETS, EPHY_PCS_RESET); + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, + TJA1120_EPHY_RESETS, EPHY_PCS_RESET); + } +} + static int nxp_c45_get_sqi_max(struct phy_device *phydev) { return MAX_SQI; @@ -1932,6 +1948,7 @@ static struct phy_driver nxp_c45_driver[] = { .config_intr = tja1120_config_intr, .handle_interrupt = nxp_c45_handle_interrupt, .read_status = genphy_c45_read_status, + .link_change_notify = tja1120_link_change_notify, .suspend = genphy_c45_pma_suspend, .resume = genphy_c45_pma_resume, .get_sset_count = nxp_c45_get_sset_count,